File: globals.h

package info (click to toggle)
scummvm 2.9.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 450,580 kB
  • sloc: cpp: 4,299,825; asm: 28,322; python: 12,901; sh: 11,302; java: 9,289; xml: 7,895; perl: 2,639; ansic: 2,465; yacc: 1,670; javascript: 1,020; makefile: 933; lex: 578; awk: 275; objc: 82; sed: 11; php: 1
file content (154 lines) | stat: -rw-r--r-- 7,134 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/* Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009 Dean Beeler, Jerome Fisher
 * Copyright (C) 2011-2022 Dean Beeler, Jerome Fisher, Sergey V. Mikayev
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License as published by
 *  the Free Software Foundation, either version 2.1 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef MT32EMU_GLOBALS_H
#define MT32EMU_GLOBALS_H

#include "config.h"

/* Support for compiling shared library.
 * MT32EMU_SHARED and mt32emu_EXPORTS are defined when building a shared library.
 * MT32EMU_SHARED should also be defined for Windows platforms that provides for a small performance benefit,
 * and it _must_ be defined along with MT32EMU_RUNTIME_VERSION_CHECK when using MSVC.
 */
#ifdef MT32EMU_SHARED
#  if defined _WIN32 || defined __CYGWIN__ || defined __OS2__
#    ifdef _MSC_VER
#      ifdef mt32emu_EXPORTS
#        define MT32EMU_EXPORT_ATTRIBUTE _declspec(dllexport)
#      else /* #ifdef mt32emu_EXPORTS */
#        define MT32EMU_EXPORT_ATTRIBUTE _declspec(dllimport)
#      endif /* #ifdef mt32emu_EXPORTS */
#    else /* #ifdef _MSC_VER */
#      ifdef mt32emu_EXPORTS
#        define MT32EMU_EXPORT_ATTRIBUTE __attribute__ ((dllexport))
#      else /* #ifdef mt32emu_EXPORTS */
#        define MT32EMU_EXPORT_ATTRIBUTE __attribute__ ((dllimport))
#      endif /* #ifdef mt32emu_EXPORTS */
#    endif /* #ifdef _MSC_VER */
#  else /* #if defined _WIN32 || defined __CYGWIN__ || defined __OS2__ */
#    ifdef mt32emu_EXPORTS
#      define MT32EMU_EXPORT_ATTRIBUTE __attribute__ ((visibility("default")))
#    else /* #ifdef mt32emu_EXPORTS */
#      define MT32EMU_EXPORT_ATTRIBUTE
#    endif /* #ifdef mt32emu_EXPORTS */
#  endif /* #if defined _WIN32 || defined __CYGWIN__ || defined __OS2__ */
#else /* #ifdef MT32EMU_SHARED */
#  define MT32EMU_EXPORT_ATTRIBUTE
#endif /* #ifdef MT32EMU_SHARED */

#if MT32EMU_EXPORTS_TYPE == 1 || MT32EMU_EXPORTS_TYPE == 2
#define MT32EMU_EXPORT
#else
#define MT32EMU_EXPORT MT32EMU_EXPORT_ATTRIBUTE
#endif

/* Facilitates easier tracking of the library version when an external symbol was introduced.
 * Particularly useful for shared library builds on POSIX systems that support symbol versioning,
 * so that the version map file can be generated automatically.
 */
#define MT32EMU_EXPORT_V(symbol_version_tag) MT32EMU_EXPORT

/* Helpers for compile-time version checks */

/* Encodes the given version components to a single integer value to simplify further checks. */
#define MT32EMU_VERSION_INT(major, minor, patch) ((major << 16) | (minor << 8) | patch)

/* The version of this library build, as an integer. */
#define MT32EMU_CURRENT_VERSION_INT MT32EMU_VERSION_INT(MT32EMU_VERSION_MAJOR, MT32EMU_VERSION_MINOR, MT32EMU_VERSION_PATCH)

/* Compares the current library version with the given version components. Intended for feature checks. */
#define MT32EMU_VERSION_ATLEAST(major, minor, patch) (MT32EMU_CURRENT_VERSION_INT >= MT32EMU_VERSION_INT(major, minor, patch))

/* Implements a simple version check that ensures full API compatibility of this library build
 * with the application requirements. The latter can be derived from the versions of used public symbols.
 *
 * Note: This macro is intended for a quick compile-time check. To ensure compatibility of an application
 * linked with a shared library, an automatic version check can be engaged with help of the build option
 * libmt32emu_WITH_VERSION_TAGGING. For a fine-grained feature checking in run-time, see functions
 * mt32emu_get_library_version_int and Synth::getLibraryVersionInt.
 */
#define MT32EMU_IS_COMPATIBLE(major, minor) (MT32EMU_VERSION_MAJOR == major && MT32EMU_VERSION_MINOR >= minor)

/* Useful constants */

/* Sample rate to use in mixing. With the progress of development, we've found way too many thing dependent.
 * In order to achieve further advance in emulation accuracy, sample rate made fixed throughout the emulator,
 * except the emulation of analogue path.
 * The output from the synth is supposed to be resampled externally in order to convert to the desired sample rate.
 */
#define MT32EMU_SAMPLE_RATE 32000

/* The default value for the maximum number of partials playing simultaneously. */
#define MT32EMU_DEFAULT_MAX_PARTIALS 32

/* The higher this number, the more memory will be used, but the more samples can be processed in one run -
 * various parts of sample generation can be processed more efficiently in a single run.
 * A run's maximum length is that given to Synth::render(), so giving a value here higher than render() is ever
 * called with will give no gain (but simply waste the memory).
 * Note that this value does *not* in any way impose limitations on the length given to render(), and has no effect
 * on the generated audio.
 * This value must be >= 1.
 */
#define MT32EMU_MAX_SAMPLES_PER_RUN 4096

/* The default size of the internal MIDI event queue.
 * It holds the incoming MIDI events before the rendering engine actually processes them.
 * The main goal is to fairly emulate the real hardware behaviour which obviously
 * uses an internal MIDI event queue to gather incoming data as well as the delays
 * introduced by transferring data via the MIDI interface.
 * This also facilitates building of an external rendering loop
 * as the queue stores timestamped MIDI events.
 */
#define MT32EMU_DEFAULT_MIDI_EVENT_QUEUE_SIZE 1024

/* Maximum allowed size of MIDI parser input stream buffer.
 * Should suffice for any reasonable bulk dump SysEx, as the h/w units have only 32K of RAM onboard.
 */
#define MT32EMU_MAX_STREAM_BUFFER_SIZE 32768

/* This should correspond to the MIDI buffer size used in real h/w devices.
 * CM-32L control ROM is using 1000 bytes, and MT-32 GEN0 is using only 240 bytes (semi-confirmed by now).
 */
#define MT32EMU_SYSEX_BUFFER_SIZE 1000

#if defined(__cplusplus) && MT32EMU_API_TYPE != 1

namespace MT32Emu
{
const unsigned int SAMPLE_RATE = MT32EMU_SAMPLE_RATE;
#undef MT32EMU_SAMPLE_RATE

const unsigned int DEFAULT_MAX_PARTIALS = MT32EMU_DEFAULT_MAX_PARTIALS;
#undef MT32EMU_DEFAULT_MAX_PARTIALS

const unsigned int MAX_SAMPLES_PER_RUN = MT32EMU_MAX_SAMPLES_PER_RUN;
#undef MT32EMU_MAX_SAMPLES_PER_RUN

const unsigned int DEFAULT_MIDI_EVENT_QUEUE_SIZE = MT32EMU_DEFAULT_MIDI_EVENT_QUEUE_SIZE;
#undef MT32EMU_DEFAULT_MIDI_EVENT_QUEUE_SIZE

const unsigned int MAX_STREAM_BUFFER_SIZE = MT32EMU_MAX_STREAM_BUFFER_SIZE;
#undef MT32EMU_MAX_STREAM_BUFFER_SIZE

const unsigned int SYSEX_BUFFER_SIZE = MT32EMU_SYSEX_BUFFER_SIZE;
#undef MT32EMU_SYSEX_BUFFER_SIZE
}

#endif /* #if defined(__cplusplus) && MT32EMU_API_TYPE != 1 */

#endif /* #ifndef MT32EMU_GLOBALS_H */