ScummVM API documentation
globals.h
1 /* Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009 Dean Beeler, Jerome Fisher
2  * Copyright (C) 2011-2022 Dean Beeler, Jerome Fisher, Sergey V. Mikayev
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation, either version 2.1 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef MT32EMU_GLOBALS_H
19 #define MT32EMU_GLOBALS_H
20 
21 #include "config.h"
22 
23 /* Support for compiling shared library.
24  * MT32EMU_SHARED and mt32emu_EXPORTS are defined when building a shared library.
25  * MT32EMU_SHARED should also be defined for Windows platforms that provides for a small performance benefit,
26  * and it _must_ be defined along with MT32EMU_RUNTIME_VERSION_CHECK when using MSVC.
27  */
28 #ifdef MT32EMU_SHARED
29 # if defined _WIN32 || defined __CYGWIN__ || defined __OS2__
30 # ifdef _MSC_VER
31 # ifdef mt32emu_EXPORTS
32 # define MT32EMU_EXPORT_ATTRIBUTE _declspec(dllexport)
33 # else /* #ifdef mt32emu_EXPORTS */
34 # define MT32EMU_EXPORT_ATTRIBUTE _declspec(dllimport)
35 # endif /* #ifdef mt32emu_EXPORTS */
36 # else /* #ifdef _MSC_VER */
37 # ifdef mt32emu_EXPORTS
38 # define MT32EMU_EXPORT_ATTRIBUTE __attribute__ ((dllexport))
39 # else /* #ifdef mt32emu_EXPORTS */
40 # define MT32EMU_EXPORT_ATTRIBUTE __attribute__ ((dllimport))
41 # endif /* #ifdef mt32emu_EXPORTS */
42 # endif /* #ifdef _MSC_VER */
43 # else /* #if defined _WIN32 || defined __CYGWIN__ || defined __OS2__ */
44 # ifdef mt32emu_EXPORTS
45 # define MT32EMU_EXPORT_ATTRIBUTE __attribute__ ((visibility("default")))
46 # else /* #ifdef mt32emu_EXPORTS */
47 # define MT32EMU_EXPORT_ATTRIBUTE
48 # endif /* #ifdef mt32emu_EXPORTS */
49 # endif /* #if defined _WIN32 || defined __CYGWIN__ || defined __OS2__ */
50 #else /* #ifdef MT32EMU_SHARED */
51 # define MT32EMU_EXPORT_ATTRIBUTE
52 #endif /* #ifdef MT32EMU_SHARED */
53 
54 #if MT32EMU_EXPORTS_TYPE == 1 || MT32EMU_EXPORTS_TYPE == 2
55 #define MT32EMU_EXPORT
56 #else
57 #define MT32EMU_EXPORT MT32EMU_EXPORT_ATTRIBUTE
58 #endif
59 
60 /* Facilitates easier tracking of the library version when an external symbol was introduced.
61  * Particularly useful for shared library builds on POSIX systems that support symbol versioning,
62  * so that the version map file can be generated automatically.
63  */
64 #define MT32EMU_EXPORT_V(symbol_version_tag) MT32EMU_EXPORT
65 
66 /* Helpers for compile-time version checks */
67 
68 /* Encodes the given version components to a single integer value to simplify further checks. */
69 #define MT32EMU_VERSION_INT(major, minor, patch) ((major << 16) | (minor << 8) | patch)
70 
71 /* The version of this library build, as an integer. */
72 #define MT32EMU_CURRENT_VERSION_INT MT32EMU_VERSION_INT(MT32EMU_VERSION_MAJOR, MT32EMU_VERSION_MINOR, MT32EMU_VERSION_PATCH)
73 
74 /* Compares the current library version with the given version components. Intended for feature checks. */
75 #define MT32EMU_VERSION_ATLEAST(major, minor, patch) (MT32EMU_CURRENT_VERSION_INT >= MT32EMU_VERSION_INT(major, minor, patch))
76 
77 /* Implements a simple version check that ensures full API compatibility of this library build
78  * with the application requirements. The latter can be derived from the versions of used public symbols.
79  *
80  * Note: This macro is intended for a quick compile-time check. To ensure compatibility of an application
81  * linked with a shared library, an automatic version check can be engaged with help of the build option
82  * libmt32emu_WITH_VERSION_TAGGING. For a fine-grained feature checking in run-time, see functions
83  * mt32emu_get_library_version_int and Synth::getLibraryVersionInt.
84  */
85 #define MT32EMU_IS_COMPATIBLE(major, minor) (MT32EMU_VERSION_MAJOR == major && MT32EMU_VERSION_MINOR >= minor)
86 
87 /* Useful constants */
88 
89 /* Sample rate to use in mixing. With the progress of development, we've found way too many thing dependent.
90  * In order to achieve further advance in emulation accuracy, sample rate made fixed throughout the emulator,
91  * except the emulation of analogue path.
92  * The output from the synth is supposed to be resampled externally in order to convert to the desired sample rate.
93  */
94 #define MT32EMU_SAMPLE_RATE 32000
95 
96 /* The default value for the maximum number of partials playing simultaneously. */
97 #define MT32EMU_DEFAULT_MAX_PARTIALS 32
98 
99 /* The higher this number, the more memory will be used, but the more samples can be processed in one run -
100  * various parts of sample generation can be processed more efficiently in a single run.
101  * A run's maximum length is that given to Synth::render(), so giving a value here higher than render() is ever
102  * called with will give no gain (but simply waste the memory).
103  * Note that this value does *not* in any way impose limitations on the length given to render(), and has no effect
104  * on the generated audio.
105  * This value must be >= 1.
106  */
107 #define MT32EMU_MAX_SAMPLES_PER_RUN 4096
108 
109 /* The default size of the internal MIDI event queue.
110  * It holds the incoming MIDI events before the rendering engine actually processes them.
111  * The main goal is to fairly emulate the real hardware behaviour which obviously
112  * uses an internal MIDI event queue to gather incoming data as well as the delays
113  * introduced by transferring data via the MIDI interface.
114  * This also facilitates building of an external rendering loop
115  * as the queue stores timestamped MIDI events.
116  */
117 #define MT32EMU_DEFAULT_MIDI_EVENT_QUEUE_SIZE 1024
118 
119 /* Maximum allowed size of MIDI parser input stream buffer.
120  * Should suffice for any reasonable bulk dump SysEx, as the h/w units have only 32K of RAM onboard.
121  */
122 #define MT32EMU_MAX_STREAM_BUFFER_SIZE 32768
123 
124 /* This should correspond to the MIDI buffer size used in real h/w devices.
125  * CM-32L control ROM is using 1000 bytes, and MT-32 GEN0 is using only 240 bytes (semi-confirmed by now).
126  */
127 #define MT32EMU_SYSEX_BUFFER_SIZE 1000
128 
129 #if defined(__cplusplus) && MT32EMU_API_TYPE != 1
130 
131 namespace MT32Emu
132 {
133 const unsigned int SAMPLE_RATE = MT32EMU_SAMPLE_RATE;
134 #undef MT32EMU_SAMPLE_RATE
135 
136 const unsigned int DEFAULT_MAX_PARTIALS = MT32EMU_DEFAULT_MAX_PARTIALS;
137 #undef MT32EMU_DEFAULT_MAX_PARTIALS
138 
139 const unsigned int MAX_SAMPLES_PER_RUN = MT32EMU_MAX_SAMPLES_PER_RUN;
140 #undef MT32EMU_MAX_SAMPLES_PER_RUN
141 
142 const unsigned int DEFAULT_MIDI_EVENT_QUEUE_SIZE = MT32EMU_DEFAULT_MIDI_EVENT_QUEUE_SIZE;
143 #undef MT32EMU_DEFAULT_MIDI_EVENT_QUEUE_SIZE
144 
145 const unsigned int MAX_STREAM_BUFFER_SIZE = MT32EMU_MAX_STREAM_BUFFER_SIZE;
146 #undef MT32EMU_MAX_STREAM_BUFFER_SIZE
147 
148 const unsigned int SYSEX_BUFFER_SIZE = MT32EMU_SYSEX_BUFFER_SIZE;
149 #undef MT32EMU_SYSEX_BUFFER_SIZE
150 }
151 
152 #endif /* #if defined(__cplusplus) && MT32EMU_API_TYPE != 1 */
153 
154 #endif /* #ifndef MT32EMU_GLOBALS_H */
Definition: Analog.h:26