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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
|
/* Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009 Dean Beeler, Jerome Fisher
* Copyright (C) 2011-2016 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/>.
*/
#include "../globals.h"
#include "../Types.h"
#include "../File.h"
#include "../FileStream.h"
#include "../ROMInfo.h"
#include "../Synth.h"
#include "../MidiStreamParser.h"
#include "c_types.h"
#include "c_interface.h"
using namespace MT32Emu;
namespace MT32Emu {
static mt32emu_service_version getSynthVersionID(mt32emu_service_i) {
return MT32EMU_SERVICE_VERSION_CURRENT;
}
static const mt32emu_service_i_v0 SERVICE_VTABLE = {
getSynthVersionID,
mt32emu_get_supported_report_handler_version,
mt32emu_get_supported_midi_receiver_version,
mt32emu_get_library_version_int,
mt32emu_get_library_version_string,
mt32emu_get_stereo_output_samplerate,
mt32emu_create_context,
mt32emu_free_context,
mt32emu_add_rom_data,
mt32emu_add_rom_file,
mt32emu_get_rom_info,
mt32emu_set_partial_count,
mt32emu_set_analog_output_mode,
mt32emu_open_synth,
mt32emu_close_synth,
mt32emu_is_open,
mt32emu_get_actual_stereo_output_samplerate,
mt32emu_flush_midi_queue,
mt32emu_set_midi_event_queue_size,
mt32emu_set_midi_receiver,
mt32emu_parse_stream,
mt32emu_parse_stream_at,
mt32emu_play_short_message,
mt32emu_play_short_message_at,
mt32emu_play_msg,
mt32emu_play_sysex,
mt32emu_play_msg_at,
mt32emu_play_sysex_at,
mt32emu_play_msg_now,
mt32emu_play_msg_on_part,
mt32emu_play_sysex_now,
mt32emu_write_sysex,
mt32emu_set_reverb_enabled,
mt32emu_is_reverb_enabled,
mt32emu_set_reverb_overridden,
mt32emu_is_reverb_overridden,
mt32emu_set_reverb_compatibility_mode,
mt32emu_is_mt32_reverb_compatibility_mode,
mt32emu_is_default_reverb_mt32_compatible,
mt32emu_set_dac_input_mode,
mt32emu_get_dac_input_mode,
mt32emu_set_midi_delay_mode,
mt32emu_get_midi_delay_mode,
mt32emu_set_output_gain,
mt32emu_get_output_gain,
mt32emu_set_reverb_output_gain,
mt32emu_get_reverb_output_gain,
mt32emu_set_reversed_stereo_enabled,
mt32emu_is_reversed_stereo_enabled,
mt32emu_render_bit16s,
mt32emu_render_float,
mt32emu_render_bit16s_streams,
mt32emu_render_float_streams,
mt32emu_has_active_partials,
mt32emu_is_active,
mt32emu_get_partial_count,
mt32emu_get_part_states,
mt32emu_get_partial_states,
mt32emu_get_playing_notes,
mt32emu_get_patch_name,
mt32emu_read_memory
};
} // namespace MT32Emu
struct mt32emu_data {
ReportHandler *reportHandler;
Synth *synth;
const ROMImage *controlROMImage;
const ROMImage *pcmROMImage;
DefaultMidiStreamParser *midiParser;
Bit32u partialCount;
AnalogOutputMode analogOutputMode;
};
// Internal C++ utility stuff
namespace MT32Emu {
class DelegatingReportHandlerAdapter : public ReportHandler {
public:
DelegatingReportHandlerAdapter(mt32emu_report_handler_i useReportHandler, void *useInstanceData) :
delegate(useReportHandler), instanceData(useInstanceData) {}
protected:
const mt32emu_report_handler_i delegate;
void * const instanceData;
private:
void printDebug(const char *fmt, va_list list) {
if (delegate.v0->printDebug == NULL) {
ReportHandler::printDebug(fmt, list);
} else {
delegate.v0->printDebug(instanceData, fmt, list);
}
}
void onErrorControlROM() {
if (delegate.v0->onErrorControlROM == NULL) {
ReportHandler::onErrorControlROM();
} else {
delegate.v0->onErrorControlROM(instanceData);
}
}
void onErrorPCMROM() {
if (delegate.v0->onErrorPCMROM == NULL) {
ReportHandler::onErrorPCMROM();
} else {
delegate.v0->onErrorPCMROM(instanceData);
}
}
void showLCDMessage(const char *message) {
if (delegate.v0->showLCDMessage == NULL) {
ReportHandler::showLCDMessage(message);
} else {
delegate.v0->showLCDMessage(instanceData, message);
}
}
void onMIDIMessagePlayed() {
if (delegate.v0->onMIDIMessagePlayed == NULL) {
ReportHandler::onMIDIMessagePlayed();
} else {
delegate.v0->onMIDIMessagePlayed(instanceData);
}
}
bool onMIDIQueueOverflow() {
if (delegate.v0->onMIDIQueueOverflow == NULL) {
return ReportHandler::onMIDIQueueOverflow();
}
return delegate.v0->onMIDIQueueOverflow(instanceData) != MT32EMU_BOOL_FALSE;
}
void onMIDISystemRealtime(Bit8u systemRealtime) {
if (delegate.v0->onMIDISystemRealtime == NULL) {
ReportHandler::onMIDISystemRealtime(systemRealtime);
} else {
delegate.v0->onMIDISystemRealtime(instanceData, systemRealtime);
}
}
void onDeviceReset() {
if (delegate.v0->onDeviceReset == NULL) {
ReportHandler::onDeviceReset();
} else {
delegate.v0->onDeviceReset(instanceData);
}
}
void onDeviceReconfig() {
if (delegate.v0->onDeviceReconfig == NULL) {
ReportHandler::onDeviceReconfig();
} else {
delegate.v0->onDeviceReconfig(instanceData);
}
}
void onNewReverbMode(Bit8u mode) {
if (delegate.v0->onNewReverbMode == NULL) {
ReportHandler::onNewReverbMode(mode);
} else {
delegate.v0->onNewReverbMode(instanceData, mode);
}
}
void onNewReverbTime(Bit8u time) {
if (delegate.v0->onNewReverbTime == NULL) {
ReportHandler::onNewReverbTime(time);
} else {
delegate.v0->onNewReverbTime(instanceData, time);
}
}
void onNewReverbLevel(Bit8u level) {
if (delegate.v0->onNewReverbLevel == NULL) {
ReportHandler::onNewReverbLevel(level);
} else {
delegate.v0->onNewReverbLevel(instanceData, level);
}
}
void onPolyStateChanged(Bit8u partNum) {
if (delegate.v0->onPolyStateChanged == NULL) {
ReportHandler::onPolyStateChanged(partNum);
} else {
delegate.v0->onPolyStateChanged(instanceData, partNum);
}
}
void onProgramChanged(Bit8u partNum, const char *soundGroupName, const char *patchName) {
if (delegate.v0->onProgramChanged == NULL) {
ReportHandler::onProgramChanged(partNum, soundGroupName, patchName);
} else {
delegate.v0->onProgramChanged(instanceData, partNum, soundGroupName, patchName);
}
}
};
class DelegatingMidiStreamParser : public DefaultMidiStreamParser {
public:
DelegatingMidiStreamParser(const mt32emu_data *useData, mt32emu_midi_receiver_i useMIDIReceiver, void *useInstanceData) :
DefaultMidiStreamParser(*useData->synth), delegate(useMIDIReceiver), instanceData(useInstanceData) {}
protected:
mt32emu_midi_receiver_i delegate;
void *instanceData;
private:
void handleShortMessage(const Bit32u message) {
if (delegate.v0->handleShortMessage == NULL) {
DefaultMidiStreamParser::handleShortMessage(message);
} else {
delegate.v0->handleShortMessage(instanceData, message);
}
}
void handleSysex(const Bit8u *stream, const Bit32u length) {
if (delegate.v0->handleSysex == NULL) {
DefaultMidiStreamParser::handleSysex(stream, length);
} else {
delegate.v0->handleSysex(instanceData, stream, length);
}
}
void handleSystemRealtimeMessage(const Bit8u realtime) {
if (delegate.v0->handleSystemRealtimeMessage == NULL) {
DefaultMidiStreamParser::handleSystemRealtimeMessage(realtime);
} else {
delegate.v0->handleSystemRealtimeMessage(instanceData, realtime);
}
}
};
static mt32emu_return_code addROMFile(mt32emu_data *data, File *file) {
const ROMImage *image = ROMImage::makeROMImage(file);
const ROMInfo *info = image->getROMInfo();
if (info == NULL) {
ROMImage::freeROMImage(image);
return MT32EMU_RC_ROM_NOT_IDENTIFIED;
}
if (info->type == ROMInfo::Control) {
if (data->controlROMImage != NULL) {
delete data->controlROMImage->getFile();
ROMImage::freeROMImage(data->controlROMImage);
}
data->controlROMImage = image;
return MT32EMU_RC_ADDED_CONTROL_ROM;
} else if (info->type == ROMInfo::PCM) {
if (data->pcmROMImage != NULL) {
delete data->pcmROMImage->getFile();
ROMImage::freeROMImage(data->pcmROMImage);
}
data->pcmROMImage = image;
return MT32EMU_RC_ADDED_PCM_ROM;
}
ROMImage::freeROMImage(image);
return MT32EMU_RC_OK; // No support for reverb ROM yet.
}
} // namespace MT32Emu
// C-visible implementation
extern "C" {
const mt32emu_service_i mt32emu_get_service_i() {
mt32emu_service_i i = { &SERVICE_VTABLE };
return i;
}
mt32emu_report_handler_version mt32emu_get_supported_report_handler_version() {
return MT32EMU_REPORT_HANDLER_VERSION_CURRENT;
}
mt32emu_midi_receiver_version mt32emu_get_supported_midi_receiver_version() {
return MT32EMU_MIDI_RECEIVER_VERSION_CURRENT;
}
mt32emu_bit32u mt32emu_get_library_version_int() {
return Synth::getLibraryVersionInt();
}
const char *mt32emu_get_library_version_string() {
return Synth::getLibraryVersionString();
}
mt32emu_bit32u mt32emu_get_stereo_output_samplerate(const mt32emu_analog_output_mode analog_output_mode) {
return Synth::getStereoOutputSampleRate(static_cast<AnalogOutputMode>(analog_output_mode));
}
mt32emu_context mt32emu_create_context(mt32emu_report_handler_i report_handler, void *instance_data) {
mt32emu_data *data = new mt32emu_data;
data->reportHandler = (report_handler.v0 != NULL) ? new DelegatingReportHandlerAdapter(report_handler, instance_data) : new ReportHandler;
data->synth = new Synth(data->reportHandler);
data->midiParser = new DefaultMidiStreamParser(*data->synth);
data->controlROMImage = NULL;
data->pcmROMImage = NULL;
data->partialCount = DEFAULT_MAX_PARTIALS;
data->analogOutputMode = AnalogOutputMode_COARSE;
return data;
}
void mt32emu_free_context(mt32emu_context data) {
if (data == NULL) return;
if (data->controlROMImage != NULL) {
delete data->controlROMImage->getFile();
ROMImage::freeROMImage(data->controlROMImage);
data->controlROMImage = NULL;
}
if (data->pcmROMImage != NULL) {
delete data->pcmROMImage->getFile();
ROMImage::freeROMImage(data->pcmROMImage);
data->pcmROMImage = NULL;
}
delete data->midiParser;
data->midiParser = NULL;
delete data->synth;
data->synth = NULL;
delete data->reportHandler;
data->reportHandler = NULL;
delete data;
}
mt32emu_return_code mt32emu_add_rom_data(mt32emu_context context, const mt32emu_bit8u *data, size_t data_size, const mt32emu_sha1_digest *sha1_digest) {
if (sha1_digest == NULL) return addROMFile(context, new ArrayFile(data, data_size));
return addROMFile(context, new ArrayFile(data, data_size, *sha1_digest));
}
mt32emu_return_code mt32emu_add_rom_file(mt32emu_context context, const char *filename) {
mt32emu_return_code rc = MT32EMU_RC_OK;
FileStream *fs = new FileStream;
if (fs->open(filename)) {
if (fs->getData() != NULL) {
rc = addROMFile(context, fs);
if (rc > 0) return rc;
} else {
rc = MT32EMU_RC_FILE_NOT_LOADED;
}
} else {
rc = MT32EMU_RC_FILE_NOT_FOUND;
}
delete fs;
return rc;
}
void mt32emu_get_rom_info(mt32emu_const_context context, mt32emu_rom_info *rom_info) {
const ROMInfo *romInfo = context->controlROMImage == NULL ? NULL : context->controlROMImage->getROMInfo();
if (romInfo != NULL) {
rom_info->control_rom_id = romInfo->shortName;
rom_info->control_rom_description = romInfo->description;
rom_info->control_rom_sha1_digest = romInfo->sha1Digest;
} else {
rom_info->control_rom_id = NULL;
rom_info->control_rom_description = NULL;
rom_info->control_rom_sha1_digest = NULL;
}
romInfo = context->pcmROMImage == NULL ? NULL : context->pcmROMImage->getROMInfo();
if (romInfo != NULL) {
rom_info->pcm_rom_id = romInfo->shortName;
rom_info->pcm_rom_description = romInfo->description;
rom_info->pcm_rom_sha1_digest = romInfo->sha1Digest;
} else {
rom_info->pcm_rom_id = NULL;
rom_info->pcm_rom_description = NULL;
rom_info->pcm_rom_sha1_digest = NULL;
}
}
void mt32emu_set_partial_count(mt32emu_context context, const mt32emu_bit32u partial_count) {
context->partialCount = partial_count;
}
void mt32emu_set_analog_output_mode(mt32emu_context context, const mt32emu_analog_output_mode analog_output_mode) {
context->analogOutputMode = static_cast<AnalogOutputMode>(analog_output_mode);
}
mt32emu_return_code mt32emu_open_synth(mt32emu_const_context context) {
if ((context->controlROMImage == NULL) || (context->pcmROMImage == NULL)) {
return MT32EMU_RC_MISSING_ROMS;
}
if (context->synth->open(*context->controlROMImage, *context->pcmROMImage, context->partialCount, context->analogOutputMode)) {
return MT32EMU_RC_OK;
}
return MT32EMU_RC_FAILED;
}
void mt32emu_close_synth(mt32emu_const_context context) {
context->synth->close();
}
mt32emu_boolean mt32emu_is_open(mt32emu_const_context context) {
return context->synth->isOpen() ? MT32EMU_BOOL_TRUE : MT32EMU_BOOL_FALSE;
}
mt32emu_bit32u mt32emu_get_actual_stereo_output_samplerate(mt32emu_const_context context) {
return context->synth->getStereoOutputSampleRate();
}
void mt32emu_flush_midi_queue(mt32emu_const_context context) {
context->synth->flushMIDIQueue();
}
mt32emu_bit32u mt32emu_set_midi_event_queue_size(mt32emu_const_context context, const mt32emu_bit32u queue_size) {
return context->synth->setMIDIEventQueueSize(queue_size);
}
void mt32emu_set_midi_receiver(mt32emu_context context, mt32emu_midi_receiver_i midi_receiver, void *instance_data) {
delete context->midiParser;
context->midiParser = (midi_receiver.v0 != NULL) ? new DelegatingMidiStreamParser(context, midi_receiver, instance_data) : new DefaultMidiStreamParser(*context->synth);
}
void mt32emu_parse_stream(mt32emu_const_context context, const mt32emu_bit8u *stream, mt32emu_bit32u length) {
context->midiParser->resetTimestamp();
context->midiParser->parseStream(stream, length);
}
void mt32emu_parse_stream_at(mt32emu_const_context context, const mt32emu_bit8u *stream, mt32emu_bit32u length, mt32emu_bit32u timestamp) {
context->midiParser->setTimestamp(timestamp);
context->midiParser->parseStream(stream, length);
}
void mt32emu_play_short_message(mt32emu_const_context context, mt32emu_bit32u message) {
context->midiParser->resetTimestamp();
context->midiParser->processShortMessage(message);
}
void mt32emu_play_short_message_at(mt32emu_const_context context, mt32emu_bit32u message, mt32emu_bit32u timestamp) {
context->midiParser->setTimestamp(timestamp);
context->midiParser->processShortMessage(message);
}
mt32emu_return_code mt32emu_play_msg(mt32emu_const_context context, mt32emu_bit32u msg) {
if (!context->synth->isOpen()) return MT32EMU_RC_NOT_OPENED;
return (context->synth->playMsg(msg)) ? MT32EMU_RC_OK : MT32EMU_RC_QUEUE_FULL;
}
mt32emu_return_code mt32emu_play_sysex(mt32emu_const_context context, const mt32emu_bit8u *sysex, mt32emu_bit32u len) {
if (!context->synth->isOpen()) return MT32EMU_RC_NOT_OPENED;
return (context->synth->playSysex(sysex, len)) ? MT32EMU_RC_OK : MT32EMU_RC_QUEUE_FULL;
}
mt32emu_return_code mt32emu_play_msg_at(mt32emu_const_context context, mt32emu_bit32u msg, mt32emu_bit32u timestamp) {
if (!context->synth->isOpen()) return MT32EMU_RC_NOT_OPENED;
return (context->synth->playMsg(msg, timestamp)) ? MT32EMU_RC_OK : MT32EMU_RC_QUEUE_FULL;
}
mt32emu_return_code mt32emu_play_sysex_at(mt32emu_const_context context, const mt32emu_bit8u *sysex, mt32emu_bit32u len, mt32emu_bit32u timestamp) {
if (!context->synth->isOpen()) return MT32EMU_RC_NOT_OPENED;
return (context->synth->playSysex(sysex, len, timestamp)) ? MT32EMU_RC_OK : MT32EMU_RC_QUEUE_FULL;
}
void mt32emu_play_msg_now(mt32emu_const_context context, mt32emu_bit32u msg) {
context->synth->playMsgNow(msg);
}
void mt32emu_play_msg_on_part(mt32emu_const_context context, mt32emu_bit8u part, mt32emu_bit8u code, mt32emu_bit8u note, mt32emu_bit8u velocity) {
context->synth->playMsgOnPart(part, code, note, velocity);
}
void mt32emu_play_sysex_now(mt32emu_const_context context, const mt32emu_bit8u *sysex, mt32emu_bit32u len) {
context->synth->playSysexNow(sysex, len);
}
void mt32emu_write_sysex(mt32emu_const_context context, mt32emu_bit8u channel, const mt32emu_bit8u *sysex, mt32emu_bit32u len) {
context->synth->writeSysex(channel, sysex, len);
}
void mt32emu_set_reverb_enabled(mt32emu_const_context context, const mt32emu_boolean reverb_enabled) {
context->synth->setReverbEnabled(reverb_enabled != MT32EMU_BOOL_FALSE);
}
mt32emu_boolean mt32emu_is_reverb_enabled(mt32emu_const_context context) {
return context->synth->isReverbEnabled() ? MT32EMU_BOOL_TRUE : MT32EMU_BOOL_FALSE;
}
void mt32emu_set_reverb_overridden(mt32emu_const_context context, const mt32emu_boolean reverb_overridden) {
context->synth->setReverbOverridden(reverb_overridden != MT32EMU_BOOL_FALSE);
}
mt32emu_boolean mt32emu_is_reverb_overridden(mt32emu_const_context context) {
return context->synth->isReverbOverridden() ? MT32EMU_BOOL_TRUE : MT32EMU_BOOL_FALSE;
}
void mt32emu_set_reverb_compatibility_mode(mt32emu_const_context context, const mt32emu_boolean mt32_compatible_mode) {
context->synth->setReverbCompatibilityMode(mt32_compatible_mode != MT32EMU_BOOL_FALSE);
}
mt32emu_boolean mt32emu_is_mt32_reverb_compatibility_mode(mt32emu_const_context context) {
return context->synth->isMT32ReverbCompatibilityMode() ? MT32EMU_BOOL_TRUE : MT32EMU_BOOL_FALSE;
}
mt32emu_boolean mt32emu_is_default_reverb_mt32_compatible(mt32emu_const_context context) {
return context->synth->isDefaultReverbMT32Compatible() ? MT32EMU_BOOL_TRUE : MT32EMU_BOOL_FALSE;
}
void mt32emu_set_dac_input_mode(mt32emu_const_context context, const mt32emu_dac_input_mode mode) {
context->synth->setDACInputMode(static_cast<DACInputMode>(mode));
}
mt32emu_dac_input_mode mt32emu_get_dac_input_mode(mt32emu_const_context context) {
return static_cast<mt32emu_dac_input_mode>(context->synth->getDACInputMode());
}
void mt32emu_set_midi_delay_mode(mt32emu_const_context context, const mt32emu_midi_delay_mode mode) {
context->synth->setMIDIDelayMode(static_cast<MIDIDelayMode>(mode));
}
mt32emu_midi_delay_mode mt32emu_get_midi_delay_mode(mt32emu_const_context context) {
return static_cast<mt32emu_midi_delay_mode>(context->synth->getMIDIDelayMode());
}
void mt32emu_set_output_gain(mt32emu_const_context context, float gain) {
context->synth->setOutputGain(gain);
}
float mt32emu_get_output_gain(mt32emu_const_context context) {
return context->synth->getOutputGain();
}
void mt32emu_set_reverb_output_gain(mt32emu_const_context context, float gain) {
context->synth->setReverbOutputGain(gain);
}
float mt32emu_get_reverb_output_gain(mt32emu_const_context context) {
return context->synth->getReverbOutputGain();
}
void mt32emu_set_reversed_stereo_enabled(mt32emu_const_context context, const mt32emu_boolean enabled) {
context->synth->setReversedStereoEnabled(enabled != MT32EMU_BOOL_FALSE);
}
mt32emu_boolean mt32emu_is_reversed_stereo_enabled(mt32emu_const_context context) {
return context->synth->isReversedStereoEnabled() ? MT32EMU_BOOL_TRUE : MT32EMU_BOOL_FALSE;
}
void mt32emu_render_bit16s(mt32emu_const_context context, mt32emu_bit16s *stream, mt32emu_bit32u len) {
context->synth->render(stream, len);
}
void mt32emu_render_float(mt32emu_const_context context, float *stream, mt32emu_bit32u len) {
context->synth->render(stream, len);
}
void mt32emu_render_bit16s_streams(mt32emu_const_context context, const mt32emu_dac_output_bit16s_streams *streams, mt32emu_bit32u len) {
context->synth->renderStreams(*reinterpret_cast<const DACOutputStreams<Bit16s> *>(streams), len);
}
void mt32emu_render_float_streams(mt32emu_const_context context, const mt32emu_dac_output_float_streams *streams, mt32emu_bit32u len) {
context->synth->renderStreams(*reinterpret_cast<const DACOutputStreams<float> *>(streams), len);
}
mt32emu_boolean mt32emu_has_active_partials(mt32emu_const_context context) {
return context->synth->hasActivePartials() ? MT32EMU_BOOL_TRUE : MT32EMU_BOOL_FALSE;
}
mt32emu_boolean mt32emu_is_active(mt32emu_const_context context) {
return context->synth->isActive() ? MT32EMU_BOOL_TRUE : MT32EMU_BOOL_FALSE;
}
mt32emu_bit32u mt32emu_get_partial_count(mt32emu_const_context context) {
return context->synth->getPartialCount();
}
mt32emu_bit32u mt32emu_get_part_states(mt32emu_const_context context) {
return context->synth->getPartStates();
}
void mt32emu_get_partial_states(mt32emu_const_context context, mt32emu_bit8u *partial_states) {
context->synth->getPartialStates(partial_states);
}
mt32emu_bit32u mt32emu_get_playing_notes(mt32emu_const_context context, mt32emu_bit8u part_number, mt32emu_bit8u *keys, mt32emu_bit8u *velocities) {
return context->synth->getPlayingNotes(part_number, keys, velocities);
}
const char *mt32emu_get_patch_name(mt32emu_const_context context, mt32emu_bit8u part_number) {
return context->synth->getPatchName(part_number);
}
void mt32emu_read_memory(mt32emu_const_context context, mt32emu_bit32u addr, mt32emu_bit32u len, mt32emu_bit8u *data) {
context->synth->readMemory(addr, len, data);
}
} // extern "C"
|