ReactOS 0.4.17-dev-923-g4c9a150
soundfont.h
Go to the documentation of this file.
1/*
2 * Copyright 2023 Rémi Bernon for CodeWeavers
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (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 GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 */
18
19#include "stdarg.h"
20#include "stddef.h"
21
22#include "windef.h"
23#include "winbase.h"
24
25#include "wine/debug.h"
26
27#include <pshpack1.h>
28
29/* SoundFont 2.04 data structures, from http://www.synthfont.com/sfspec24.pdf */
30
32{
35};
36
38{
41};
42
43C_ASSERT(sizeof(union sf_amount) == 2);
44
45enum
46{
55};
57
58enum
59{
74
78
100
107
113
117
119};
121
122static inline const char *debugstr_sf_generator(sf_generator oper)
123{
124 switch (oper)
125 {
126 case SF_GEN_START_ADDRS_OFFSET: return "start_addrs_offset";
127 case SF_GEN_END_ADDRS_OFFSET: return "end_addrs_offset";
128 case SF_GEN_STARTLOOP_ADDRS_OFFSET: return "startloop_addrs_offset";
129 case SF_GEN_ENDLOOP_ADDRS_OFFSET: return "endloop_addrs_offset";
130 case SF_GEN_START_ADDRS_COARSE_OFFSET: return "start_addrs_coarse_offset";
131 case SF_GEN_MOD_LFO_TO_PITCH: return "mod_lfo_to_pitch";
132 case SF_GEN_VIB_LFO_TO_PITCH: return "vib_lfo_to_pitch";
133 case SF_GEN_MOD_ENV_TO_PITCH: return "mod_env_to_pitch";
134 case SF_GEN_INITIAL_FILTER_FC: return "initial_filter_fc";
135 case SF_GEN_INITIAL_FILTER_Q: return "initial_filter_q";
136 case SF_GEN_MOD_LFO_TO_FILTER_FC: return "mod_lfo_to_filter_fc";
137 case SF_GEN_MOD_ENV_TO_FILTER_FC: return "mod_env_to_filter_fc";
138 case SF_GEN_END_ADDRS_COARSE_OFFSET: return "end_addrs_coarse_offset";
139 case SF_GEN_MOD_LFO_TO_VOLUME: return "mod_lfo_to_volume";
140 case SF_GEN_CHORUS_EFFECTS_SEND: return "chorus_effects_send";
141 case SF_GEN_REVERB_EFFECTS_SEND: return "reverb_effects_send";
142 case SF_GEN_PAN: return "pan";
143 case SF_GEN_DELAY_MOD_LFO: return "delay_mod_lfo";
144 case SF_GEN_FREQ_MOD_LFO: return "freq_mod_lfo";
145 case SF_GEN_DELAY_VIB_LFO: return "delay_vib_lfo";
146 case SF_GEN_FREQ_VIB_LFO: return "freq_vib_lfo";
147 case SF_GEN_DELAY_MOD_ENV: return "delay_mod_env";
148 case SF_GEN_ATTACK_MOD_ENV: return "attack_mod_env";
149 case SF_GEN_HOLD_MOD_ENV: return "hold_mod_env";
150 case SF_GEN_DECAY_MOD_ENV: return "decay_mod_env";
151 case SF_GEN_SUSTAIN_MOD_ENV: return "sustain_mod_env";
152 case SF_GEN_RELEASE_MOD_ENV: return "release_mod_env";
153 case SF_GEN_KEYNUM_TO_MOD_ENV_HOLD: return "keynum_to_mod_env_hold";
154 case SF_GEN_KEYNUM_TO_MOD_ENV_DECAY: return "keynum_to_mod_env_decay";
155 case SF_GEN_DELAY_VOL_ENV: return "delay_vol_env";
156 case SF_GEN_ATTACK_VOL_ENV: return "attack_vol_env";
157 case SF_GEN_HOLD_VOL_ENV: return "hold_vol_env";
158 case SF_GEN_DECAY_VOL_ENV: return "decay_vol_env";
159 case SF_GEN_SUSTAIN_VOL_ENV: return "sustain_vol_env";
160 case SF_GEN_RELEASE_VOL_ENV: return "release_vol_env";
161 case SF_GEN_KEYNUM_TO_VOL_ENV_HOLD: return "keynum_to_vol_env_hold";
162 case SF_GEN_KEYNUM_TO_VOL_ENV_DECAY: return "keynum_to_vol_env_decay";
163 case SF_GEN_INSTRUMENT: return "instrument";
164 case SF_GEN_KEY_RANGE: return "key_range";
165 case SF_GEN_VEL_RANGE: return "vel_range";
166 case SF_GEN_STARTLOOP_ADDRS_COARSE_OFFSET: return "startloop_addrs_coarse_offset";
167 case SF_GEN_KEYNUM: return "keynum";
168 case SF_GEN_VELOCITY: return "velocity";
169 case SF_GEN_INITIAL_ATTENUATION: return "initial_attenuation";
170 case SF_GEN_ENDLOOP_ADDRS_COARSE_OFFSET: return "endloop_addrs_coarse_offset";
171 case SF_GEN_COARSE_TUNE: return "coarse_tune";
172 case SF_GEN_FINE_TUNE: return "fine_tune";
173 case SF_GEN_SAMPLE_ID: return "sample_id";
174 case SF_GEN_SAMPLE_MODES: return "sample_modes";
175 case SF_GEN_SCALE_TUNING: return "scale_tuning";
176 case SF_GEN_EXCLUSIVE_CLASS: return "exclusive_class";
177 case SF_GEN_OVERRIDING_ROOT_KEY: return "overriding_root_key";
178 case SF_GEN_END_OPER: return "end_oper";
179 }
180
181 return wine_dbg_sprintf("%u", oper);
182}
183
184enum
185{
186 /* sf_modulator is a set of flags ored together */
187
196
198 SF_MOD_CTRL_MIDI = 1 << 7, /* with LSB: MIDI CC */
199
202
205
210};
212
213enum
214{
217};
219
220struct sf_preset /* <phdr-rec> */
221{
222 char name[20];
229};
230
231C_ASSERT(sizeof(struct sf_preset) == 38);
232
233struct sf_bag /* <pbag-rec> / <ibag-rec> */
234{
237};
238
239C_ASSERT(sizeof(struct sf_bag) == 4);
240
241struct sf_mod /* <pmod-rec> / <imod-rec> */
242{
248};
249
250C_ASSERT(sizeof(struct sf_mod) == 10);
251
252static inline const char *debugstr_sf_mod(struct sf_mod *mod)
253{
254 const char *dest_name = debugstr_sf_generator(mod->dest_gen);
255 return wine_dbg_sprintf("%#x x %#x -> %s: %d (%#x)", mod->src_mod, mod->amount_src_mod, dest_name, mod->amount, mod->transform);
256}
257
258struct sf_gen /* <pgen-rec> / <igen-rec> */
259{
262};
263
264C_ASSERT(sizeof(struct sf_gen) == 4);
265
266static inline const char *debugstr_sf_gen(struct sf_gen *gen)
267{
268 const char *name = debugstr_sf_generator(gen->oper);
269
270 switch (gen->oper)
271 {
272 case SF_GEN_KEY_RANGE:
273 case SF_GEN_VEL_RANGE:
274 return wine_dbg_sprintf("%s: %u-%u", name, gen->amount.range.low, gen->amount.range.high);
275 default:
276 return wine_dbg_sprintf("%s: %u", name, gen->amount.value);
277 }
278}
279
280struct sf_instrument /* <inst-rec> */
281{
282 char name[20];
284};
285
286C_ASSERT(sizeof(struct sf_instrument) == 22);
287
288struct sf_sample /* <shdr-rec> */
289{
290 char name[20];
300};
301
302C_ASSERT(sizeof(struct sf_sample) == 46);
303
304#include <poppack.h>
305
307{
310 struct sf_bag *pbag;
311 struct sf_mod *pmod;
312 struct sf_gen *pgen;
313
316 struct sf_bag *ibag;
317 struct sf_mod *imod;
318 struct sf_gen *igen;
319
323};
std::map< E_MODULE, HMODULE > mod
Definition: LocaleTests.cpp:68
range
Definition: d3dx9_private.h:58
const char * wine_dbg_sprintf(const char *format,...)
Definition: compat.c:296
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned int UINT
Definition: sysinfo.c:13
#define C_ASSERT(e)
Definition: intsafe.h:73
short SHORT
Definition: pedump.c:59
WORD sf_generator
Definition: soundfont.h:120
static const char * debugstr_sf_gen(struct sf_gen *gen)
Definition: soundfont.h:266
WORD sf_sample_type
Definition: soundfont.h:56
@ SF_TRAN_ABSOLUTE
Definition: soundfont.h:216
@ SF_TRAN_LINEAR
Definition: soundfont.h:215
@ SF_GEN_CHORUS_EFFECTS_SEND
Definition: soundfont.h:75
@ SF_GEN_SUSTAIN_VOL_ENV
Definition: soundfont.h:95
@ SF_GEN_STARTLOOP_ADDRS_OFFSET
Definition: soundfont.h:62
@ SF_GEN_MOD_ENV_TO_FILTER_FC
Definition: soundfont.h:71
@ SF_GEN_MOD_LFO_TO_PITCH
Definition: soundfont.h:65
@ SF_GEN_RELEASE_VOL_ENV
Definition: soundfont.h:96
@ SF_GEN_FREQ_VIB_LFO
Definition: soundfont.h:82
@ SF_GEN_STARTLOOP_ADDRS_COARSE_OFFSET
Definition: soundfont.h:103
@ SF_GEN_PAN
Definition: soundfont.h:77
@ SF_GEN_MOD_LFO_TO_VOLUME
Definition: soundfont.h:73
@ SF_GEN_KEYNUM
Definition: soundfont.h:104
@ SF_GEN_SAMPLE_MODES
Definition: soundfont.h:112
@ SF_GEN_KEYNUM_TO_MOD_ENV_DECAY
Definition: soundfont.h:90
@ SF_GEN_ENDLOOP_ADDRS_OFFSET
Definition: soundfont.h:63
@ SF_GEN_INITIAL_ATTENUATION
Definition: soundfont.h:106
@ SF_GEN_DELAY_VOL_ENV
Definition: soundfont.h:91
@ SF_GEN_KEY_RANGE
Definition: soundfont.h:101
@ SF_GEN_COARSE_TUNE
Definition: soundfont.h:109
@ SF_GEN_KEYNUM_TO_VOL_ENV_HOLD
Definition: soundfont.h:97
@ SF_GEN_MOD_ENV_TO_PITCH
Definition: soundfont.h:67
@ SF_GEN_INITIAL_FILTER_Q
Definition: soundfont.h:69
@ SF_GEN_START_ADDRS_COARSE_OFFSET
Definition: soundfont.h:64
@ SF_GEN_FREQ_MOD_LFO
Definition: soundfont.h:80
@ SF_GEN_REVERB_EFFECTS_SEND
Definition: soundfont.h:76
@ SF_GEN_MOD_LFO_TO_FILTER_FC
Definition: soundfont.h:70
@ SF_GEN_DELAY_VIB_LFO
Definition: soundfont.h:81
@ SF_GEN_KEYNUM_TO_VOL_ENV_DECAY
Definition: soundfont.h:98
@ SF_GEN_INITIAL_FILTER_FC
Definition: soundfont.h:68
@ SF_GEN_DELAY_MOD_LFO
Definition: soundfont.h:79
@ SF_GEN_END_ADDRS_COARSE_OFFSET
Definition: soundfont.h:72
@ SF_GEN_HOLD_MOD_ENV
Definition: soundfont.h:85
@ SF_GEN_SAMPLE_ID
Definition: soundfont.h:111
@ SF_GEN_SCALE_TUNING
Definition: soundfont.h:114
@ SF_GEN_VIB_LFO_TO_PITCH
Definition: soundfont.h:66
@ SF_GEN_ATTACK_MOD_ENV
Definition: soundfont.h:84
@ SF_GEN_SUSTAIN_MOD_ENV
Definition: soundfont.h:87
@ SF_GEN_OVERRIDING_ROOT_KEY
Definition: soundfont.h:116
@ SF_GEN_KEYNUM_TO_MOD_ENV_HOLD
Definition: soundfont.h:89
@ SF_GEN_START_ADDRS_OFFSET
Definition: soundfont.h:60
@ SF_GEN_VELOCITY
Definition: soundfont.h:105
@ SF_GEN_DELAY_MOD_ENV
Definition: soundfont.h:83
@ SF_GEN_VEL_RANGE
Definition: soundfont.h:102
@ SF_GEN_DECAY_VOL_ENV
Definition: soundfont.h:94
@ SF_GEN_END_ADDRS_OFFSET
Definition: soundfont.h:61
@ SF_GEN_FINE_TUNE
Definition: soundfont.h:110
@ SF_GEN_HOLD_VOL_ENV
Definition: soundfont.h:93
@ SF_GEN_DECAY_MOD_ENV
Definition: soundfont.h:86
@ SF_GEN_ATTACK_VOL_ENV
Definition: soundfont.h:92
@ SF_GEN_END_OPER
Definition: soundfont.h:118
@ SF_GEN_ENDLOOP_ADDRS_COARSE_OFFSET
Definition: soundfont.h:108
@ SF_GEN_EXCLUSIVE_CLASS
Definition: soundfont.h:115
@ SF_GEN_INSTRUMENT
Definition: soundfont.h:99
@ SF_GEN_RELEASE_MOD_ENV
Definition: soundfont.h:88
WORD sf_modulator
Definition: soundfont.h:211
@ SF_MOD_CTRL_GEN_POLY_PRESSURE
Definition: soundfont.h:191
@ SF_MOD_DIR_INCREASING
Definition: soundfont.h:200
@ SF_MOD_POL_BIPOLAR
Definition: soundfont.h:204
@ SF_MOD_POL_UNIPOLAR
Definition: soundfont.h:203
@ SF_MOD_CTRL_GEN_PITCH_WHEEL_SENSITIVITY
Definition: soundfont.h:194
@ SF_MOD_DIR_DECREASING
Definition: soundfont.h:201
@ SF_MOD_CTRL_GEN_NONE
Definition: soundfont.h:188
@ SF_MOD_CTRL_GEN_VELOCITY
Definition: soundfont.h:189
@ SF_MOD_CTRL_GEN_CHAN_PRESSURE
Definition: soundfont.h:192
@ SF_MOD_SRC_CONCAVE
Definition: soundfont.h:207
@ SF_MOD_SRC_SWITCH
Definition: soundfont.h:209
@ SF_MOD_SRC_LINEAR
Definition: soundfont.h:206
@ SF_MOD_CTRL_GEN_PITCH_WHEEL
Definition: soundfont.h:193
@ SF_MOD_CTRL_MIDI
Definition: soundfont.h:198
@ SF_MOD_CTRL_GEN_LINK
Definition: soundfont.h:195
@ SF_MOD_SRC_CONVEX
Definition: soundfont.h:208
@ SF_MOD_CTRL_GEN
Definition: soundfont.h:197
@ SF_MOD_CTRL_GEN_KEY
Definition: soundfont.h:190
static const char * debugstr_sf_mod(struct sf_mod *mod)
Definition: soundfont.h:252
@ SF_SAMPLE_LEFT
Definition: soundfont.h:49
@ SF_SAMPLE_MONO
Definition: soundfont.h:47
@ SF_SAMPLE_ROM_RIGHT
Definition: soundfont.h:52
@ SF_SAMPLE_ROM_MONO
Definition: soundfont.h:51
@ SF_SAMPLE_LINKED
Definition: soundfont.h:50
@ SF_SAMPLE_ROM_LINKED
Definition: soundfont.h:54
@ SF_SAMPLE_ROM_LEFT
Definition: soundfont.h:53
@ SF_SAMPLE_RIGHT
Definition: soundfont.h:48
WORD sf_transform
Definition: soundfont.h:218
static const char * debugstr_sf_generator(sf_generator oper)
Definition: soundfont.h:122
Definition: name.c:39
WORD gen_ndx
Definition: soundfont.h:235
WORD mod_ndx
Definition: soundfont.h:236
union sf_amount amount
Definition: soundfont.h:261
sf_generator oper
Definition: soundfont.h:260
sf_modulator src_mod
Definition: soundfont.h:243
sf_generator dest_gen
Definition: soundfont.h:244
sf_modulator amount_src_mod
Definition: soundfont.h:246
sf_transform transform
Definition: soundfont.h:247
SHORT amount
Definition: soundfont.h:245
WORD bank
Definition: soundfont.h:224
DWORD genre
Definition: soundfont.h:227
DWORD morphology
Definition: soundfont.h:228
WORD bag_ndx
Definition: soundfont.h:225
WORD preset
Definition: soundfont.h:223
DWORD library
Definition: soundfont.h:226
BYTE high
Definition: soundfont.h:34
BYTE low
Definition: soundfont.h:33
BYTE original_key
Definition: soundfont.h:296
DWORD end_loop
Definition: soundfont.h:294
WORD sample_link
Definition: soundfont.h:298
DWORD end
Definition: soundfont.h:292
DWORD start_loop
Definition: soundfont.h:293
char correction
Definition: soundfont.h:297
sf_sample_type sample_type
Definition: soundfont.h:299
DWORD sample_rate
Definition: soundfont.h:295
DWORD start
Definition: soundfont.h:291
struct sf_gen * igen
Definition: soundfont.h:318
struct sf_mod * imod
Definition: soundfont.h:317
struct sf_gen * pgen
Definition: soundfont.h:312
UINT preset_count
Definition: soundfont.h:308
UINT sample_count
Definition: soundfont.h:320
struct sf_instrument * inst
Definition: soundfont.h:315
BYTE * sdta
Definition: soundfont.h:322
struct sf_bag * ibag
Definition: soundfont.h:316
struct sf_preset * phdr
Definition: soundfont.h:309
struct sf_bag * pbag
Definition: soundfont.h:310
UINT instrument_count
Definition: soundfont.h:314
struct sf_sample * shdr
Definition: soundfont.h:321
struct sf_mod * pmod
Definition: soundfont.h:311
WORD value
Definition: soundfont.h:40
struct sf_range range
Definition: soundfont.h:39
unsigned char BYTE
Definition: xxhash.c:193