aboutsummaryrefslogtreecommitdiff
path: root/audio/softsynth/mt32/c_interface
diff options
context:
space:
mode:
authorTarek Soliman2017-12-23 15:40:30 -0600
committerTarek Soliman2018-01-03 10:40:23 -0600
commit50d79c5f265aad592ae7f17209653ccbb1fde488 (patch)
tree1951526e3ff2910acb0588f3a23ba0e9e7e66544 /audio/softsynth/mt32/c_interface
parentbb5e8d3a11711d409f89739cf3f054cd5bac8c4f (diff)
downloadscummvm-rg350-50d79c5f265aad592ae7f17209653ccbb1fde488.tar.gz
scummvm-rg350-50d79c5f265aad592ae7f17209653ccbb1fde488.tar.bz2
scummvm-rg350-50d79c5f265aad592ae7f17209653ccbb1fde488.zip
MT32: Update to munt 2.3.0
This uses upstream commit 939cc986d9ffd044f8c6149361127ad5d94e430f Closes gh-1091
Diffstat (limited to 'audio/softsynth/mt32/c_interface')
-rw-r--r--audio/softsynth/mt32/c_interface/c_interface.cpp115
-rw-r--r--audio/softsynth/mt32/c_interface/c_interface.h104
-rw-r--r--audio/softsynth/mt32/c_interface/c_types.h196
-rw-r--r--audio/softsynth/mt32/c_interface/cpp_interface.h79
4 files changed, 370 insertions, 124 deletions
diff --git a/audio/softsynth/mt32/c_interface/c_interface.cpp b/audio/softsynth/mt32/c_interface/c_interface.cpp
index 6ae252bea5..adb1cb6b26 100644
--- a/audio/softsynth/mt32/c_interface/c_interface.cpp
+++ b/audio/softsynth/mt32/c_interface/c_interface.cpp
@@ -1,5 +1,5 @@
/* Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009 Dean Beeler, Jerome Fisher
- * Copyright (C) 2011-2016 Dean Beeler, Jerome Fisher, Sergey V. Mikayev
+ * Copyright (C) 2011-2017 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
@@ -22,6 +22,7 @@
#include "../ROMInfo.h"
#include "../Synth.h"
#include "../MidiStreamParser.h"
+#include "../SampleRateConverter.h"
#include "c_types.h"
#include "c_interface.h"
@@ -30,11 +31,17 @@ using namespace MT32Emu;
namespace MT32Emu {
+struct SamplerateConversionState {
+ double outputSampleRate;
+ SamplerateConversionQuality srcQuality;
+ SampleRateConverter *src;
+};
+
static mt32emu_service_version getSynthVersionID(mt32emu_service_i) {
return MT32EMU_SERVICE_VERSION_CURRENT;
}
-static const mt32emu_service_i_v0 SERVICE_VTABLE = {
+static const mt32emu_service_i_v2 SERVICE_VTABLE = {
getSynthVersionID,
mt32emu_get_supported_report_handler_version,
mt32emu_get_supported_midi_receiver_version,
@@ -95,7 +102,17 @@ static const mt32emu_service_i_v0 SERVICE_VTABLE = {
mt32emu_get_partial_states,
mt32emu_get_playing_notes,
mt32emu_get_patch_name,
- mt32emu_read_memory
+ mt32emu_read_memory,
+ mt32emu_get_best_analog_output_mode,
+ mt32emu_set_stereo_output_samplerate,
+ mt32emu_set_samplerate_conversion_quality,
+ mt32emu_select_renderer_type,
+ mt32emu_get_selected_renderer_type,
+ mt32emu_convert_output_to_synth_timestamp,
+ mt32emu_convert_synth_to_output_timestamp,
+ mt32emu_get_internal_rendered_sample_count,
+ mt32emu_set_nice_amp_ramp_enabled,
+ mt32emu_is_nice_amp_ramp_enabled
};
} // namespace MT32Emu
@@ -108,6 +125,7 @@ struct mt32emu_data {
DefaultMidiStreamParser *midiParser;
Bit32u partialCount;
AnalogOutputMode analogOutputMode;
+ SamplerateConversionState *srcState;
};
// Internal C++ utility stuff
@@ -303,8 +321,9 @@ static mt32emu_return_code addROMFile(mt32emu_data *data, File *file) {
extern "C" {
-const mt32emu_service_i mt32emu_get_service_i() {
- mt32emu_service_i i = { &SERVICE_VTABLE };
+mt32emu_service_i mt32emu_get_service_i() {
+ mt32emu_service_i i;
+ i.v2 = &SERVICE_VTABLE;
return i;
}
@@ -328,6 +347,10 @@ mt32emu_bit32u mt32emu_get_stereo_output_samplerate(const mt32emu_analog_output_
return Synth::getStereoOutputSampleRate(static_cast<AnalogOutputMode>(analog_output_mode));
}
+mt32emu_analog_output_mode mt32emu_get_best_analog_output_mode(const double target_samplerate) {
+ return mt32emu_analog_output_mode(SampleRateConverter::getBestAnalogOutputMode(target_samplerate));
+}
+
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;
@@ -337,11 +360,23 @@ mt32emu_context mt32emu_create_context(mt32emu_report_handler_i report_handler,
data->pcmROMImage = NULL;
data->partialCount = DEFAULT_MAX_PARTIALS;
data->analogOutputMode = AnalogOutputMode_COARSE;
+
+ data->srcState = new SamplerateConversionState;
+ data->srcState->outputSampleRate = 0.0;
+ data->srcState->srcQuality = SamplerateConversionQuality_GOOD;
+ data->srcState->src = NULL;
+
return data;
}
void mt32emu_free_context(mt32emu_context data) {
if (data == NULL) return;
+
+ delete data->srcState->src;
+ data->srcState->src = NULL;
+ delete data->srcState;
+ data->srcState = NULL;
+
if (data->controlROMImage != NULL) {
delete data->controlROMImage->getFile();
ROMImage::freeROMImage(data->controlROMImage);
@@ -414,18 +449,39 @@ void mt32emu_set_analog_output_mode(mt32emu_context context, const mt32emu_analo
context->analogOutputMode = static_cast<AnalogOutputMode>(analog_output_mode);
}
+void mt32emu_set_stereo_output_samplerate(mt32emu_context context, const double samplerate) {
+ context->srcState->outputSampleRate = SampleRateConverter::getSupportedOutputSampleRate(samplerate);
+}
+
+void mt32emu_set_samplerate_conversion_quality(mt32emu_context context, const mt32emu_samplerate_conversion_quality quality) {
+ context->srcState->srcQuality = SamplerateConversionQuality(quality);
+}
+
+void mt32emu_select_renderer_type(mt32emu_context context, const mt32emu_renderer_type renderer_type) {
+ context->synth->selectRendererType(static_cast<RendererType>(renderer_type));
+}
+
+mt32emu_renderer_type mt32emu_get_selected_renderer_type(mt32emu_context context) {
+ return static_cast<mt32emu_renderer_type>(context->synth->getSelectedRendererType());
+}
+
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;
+ if (!context->synth->open(*context->controlROMImage, *context->pcmROMImage, context->partialCount, context->analogOutputMode)) {
+ return MT32EMU_RC_FAILED;
}
- return MT32EMU_RC_FAILED;
+ SamplerateConversionState &srcState = *context->srcState;
+ const double outputSampleRate = (0.0 < srcState.outputSampleRate) ? srcState.outputSampleRate : context->synth->getStereoOutputSampleRate();
+ srcState.src = new SampleRateConverter(*context->synth, outputSampleRate, srcState.srcQuality);
+ return MT32EMU_RC_OK;
}
void mt32emu_close_synth(mt32emu_const_context context) {
context->synth->close();
+ delete context->srcState->src;
+ context->srcState->src = NULL;
}
mt32emu_boolean mt32emu_is_open(mt32emu_const_context context) {
@@ -433,7 +489,24 @@ mt32emu_boolean mt32emu_is_open(mt32emu_const_context context) {
}
mt32emu_bit32u mt32emu_get_actual_stereo_output_samplerate(mt32emu_const_context context) {
- return context->synth->getStereoOutputSampleRate();
+ if (context->srcState->src == NULL) {
+ return context->synth->getStereoOutputSampleRate();
+ }
+ return mt32emu_bit32u(0.5 + context->srcState->src->convertSynthToOutputTimestamp(SAMPLE_RATE));
+}
+
+mt32emu_bit32u mt32emu_convert_output_to_synth_timestamp(mt32emu_const_context context, mt32emu_bit32u output_timestamp) {
+ if (context->srcState->src == NULL) {
+ return output_timestamp;
+ }
+ return mt32emu_bit32u(0.5 + context->srcState->src->convertOutputToSynthTimestamp(output_timestamp));
+}
+
+mt32emu_bit32u mt32emu_convert_synth_to_output_timestamp(mt32emu_const_context context, mt32emu_bit32u synth_timestamp) {
+ if (context->srcState->src == NULL) {
+ return synth_timestamp;
+ }
+ return mt32emu_bit32u(0.5 + context->srcState->src->convertSynthToOutputTimestamp(synth_timestamp));
}
void mt32emu_flush_midi_queue(mt32emu_const_context context) {
@@ -449,6 +522,10 @@ void mt32emu_set_midi_receiver(mt32emu_context context, mt32emu_midi_receiver_i
context->midiParser = (midi_receiver.v0 != NULL) ? new DelegatingMidiStreamParser(context, midi_receiver, instance_data) : new DefaultMidiStreamParser(*context->synth);
}
+mt32emu_bit32u mt32emu_get_internal_rendered_sample_count(mt32emu_const_context context) {
+ return context->synth->getInternalRenderedSampleCount();
+}
+
void mt32emu_parse_stream(mt32emu_const_context context, const mt32emu_bit8u *stream, mt32emu_bit32u length) {
context->midiParser->resetTimestamp();
context->midiParser->parseStream(stream, length);
@@ -573,12 +650,28 @@ mt32emu_boolean mt32emu_is_reversed_stereo_enabled(mt32emu_const_context context
return context->synth->isReversedStereoEnabled() ? MT32EMU_BOOL_TRUE : MT32EMU_BOOL_FALSE;
}
+void mt32emu_set_nice_amp_ramp_enabled(mt32emu_const_context context, const mt32emu_boolean enabled) {
+ context->synth->setNiceAmpRampEnabled(enabled != MT32EMU_BOOL_FALSE);
+}
+
+mt32emu_boolean mt32emu_is_nice_amp_ramp_enabled(mt32emu_const_context context) {
+ return context->synth->isNiceAmpRampEnabled() ? 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);
+ if (context->srcState->src != NULL) {
+ context->srcState->src->getOutputSamples(stream, len);
+ } else {
+ context->synth->render(stream, len);
+ }
}
void mt32emu_render_float(mt32emu_const_context context, float *stream, mt32emu_bit32u len) {
- context->synth->render(stream, len);
+ if (context->srcState->src != NULL) {
+ context->srcState->src->getOutputSamples(stream, len);
+ } else {
+ context->synth->render(stream, len);
+ }
}
void mt32emu_render_bit16s_streams(mt32emu_const_context context, const mt32emu_dac_output_bit16s_streams *streams, mt32emu_bit32u len) {
diff --git a/audio/softsynth/mt32/c_interface/c_interface.h b/audio/softsynth/mt32/c_interface/c_interface.h
index a2bdcb1254..f736400370 100644
--- a/audio/softsynth/mt32/c_interface/c_interface.h
+++ b/audio/softsynth/mt32/c_interface/c_interface.h
@@ -1,5 +1,5 @@
/* Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009 Dean Beeler, Jerome Fisher
- * Copyright (C) 2011-2016 Dean Beeler, Jerome Fisher, Sergey V. Mikayev
+ * Copyright (C) 2011-2017 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
@@ -35,7 +35,7 @@ extern "C" {
/* === Interface handling === */
/** Returns mt32emu_service_i interface. */
-MT32EMU_EXPORT const mt32emu_service_i mt32emu_get_service_i();
+MT32EMU_EXPORT mt32emu_service_i mt32emu_get_service_i(void);
#if MT32EMU_EXPORTS_TYPE == 2
#undef MT32EMU_EXPORT
@@ -46,13 +46,13 @@ MT32EMU_EXPORT const mt32emu_service_i mt32emu_get_service_i();
* Returns the version ID of mt32emu_report_handler_i interface the library has been compiled with.
* This allows a client to fall-back gracefully instead of silently not receiving expected event reports.
*/
-MT32EMU_EXPORT mt32emu_report_handler_version mt32emu_get_supported_report_handler_version();
+MT32EMU_EXPORT mt32emu_report_handler_version mt32emu_get_supported_report_handler_version(void);
/**
* Returns the version ID of mt32emu_midi_receiver_version_i interface the library has been compiled with.
* This allows a client to fall-back gracefully instead of silently not receiving expected MIDI messages.
*/
-MT32EMU_EXPORT mt32emu_midi_receiver_version mt32emu_get_supported_midi_receiver_version();
+MT32EMU_EXPORT mt32emu_midi_receiver_version mt32emu_get_supported_midi_receiver_version(void);
/**
* Returns library version as an integer in format: 0x00MMmmpp, where:
@@ -60,12 +60,12 @@ MT32EMU_EXPORT mt32emu_midi_receiver_version mt32emu_get_supported_midi_receiver
* mm - minor version number
* pp - patch number
*/
-MT32EMU_EXPORT mt32emu_bit32u mt32emu_get_library_version_int();
+MT32EMU_EXPORT mt32emu_bit32u mt32emu_get_library_version_int(void);
/**
* Returns library version as a C-string in format: "MAJOR.MINOR.PATCH".
*/
-MT32EMU_EXPORT const char *mt32emu_get_library_version_string();
+MT32EMU_EXPORT const char *mt32emu_get_library_version_string(void);
/**
* Returns output sample rate used in emulation of stereo analog circuitry of hardware units for particular analog_output_mode.
@@ -73,6 +73,13 @@ MT32EMU_EXPORT const char *mt32emu_get_library_version_string();
*/
MT32EMU_EXPORT mt32emu_bit32u mt32emu_get_stereo_output_samplerate(const mt32emu_analog_output_mode analog_output_mode);
+/**
+ * Returns the value of analog_output_mode for which the output signal may retain its full frequency spectrum
+ * at the sample rate specified by the target_samplerate argument.
+ * See comment for mt32emu_analog_output_mode.
+ */
+MT32EMU_EXPORT mt32emu_analog_output_mode mt32emu_get_best_analog_output_mode(const double target_samplerate);
+
/* == Context-dependent functions == */
/** Initialises a new emulation context and installs custom report handler if non-NULL. */
@@ -105,17 +112,50 @@ MT32EMU_EXPORT void mt32emu_get_rom_info(mt32emu_const_context context, mt32emu_
/**
* Allows to override the default maximum number of partials playing simultaneously within the emulation session.
- * This function doesn't immediately change the state of already opened synth. Newly set vale will take effect upon next call of mt32emu_open_synth().
+ * This function doesn't immediately change the state of already opened synth. Newly set value will take effect upon next call of mt32emu_open_synth().
*/
MT32EMU_EXPORT void mt32emu_set_partial_count(mt32emu_context context, const mt32emu_bit32u partial_count);
/**
* Allows to override the default mode for emulation of analogue circuitry of the hardware units within the emulation session.
- * This function doesn't immediately change the state of already opened synth. Newly set vale will take effect upon next call of mt32emu_open_synth().
+ * This function doesn't immediately change the state of already opened synth. Newly set value will take effect upon next call of mt32emu_open_synth().
*/
MT32EMU_EXPORT void mt32emu_set_analog_output_mode(mt32emu_context context, const mt32emu_analog_output_mode analog_output_mode);
/**
+ * Allows to convert the synthesiser output to any desired sample rate. The samplerate conversion
+ * processes the completely mixed stereo output signal as it passes the analogue circuit emulation,
+ * so emulating the synthesiser output signal passing further through an ADC. When the samplerate
+ * argument is set to 0, the default output sample rate is used which depends on the current
+ * mode of analog circuitry emulation. See mt32emu_analog_output_mode.
+ * This function doesn't immediately change the state of already opened synth.
+ * Newly set value will take effect upon next call of mt32emu_open_synth().
+ */
+MT32EMU_EXPORT void mt32emu_set_stereo_output_samplerate(mt32emu_context context, const double samplerate);
+
+/**
+ * Several samplerate conversion quality options are provided which allow to trade-off the conversion speed vs.
+ * the retained passband width. All the options except FASTEST guarantee full suppression of the aliasing noise
+ * in terms of the 16-bit integer samples.
+ * This function doesn't immediately change the state of already opened synth.
+ * Newly set value will take effect upon next call of mt32emu_open_synth().
+ */
+MT32EMU_EXPORT void mt32emu_set_samplerate_conversion_quality(mt32emu_context context, const mt32emu_samplerate_conversion_quality quality);
+
+/**
+ * Selects new type of the wave generator and renderer to be used during subsequent calls to mt32emu_open_synth().
+ * By default, MT32EMU_RT_BIT16S is selected.
+ * See mt32emu_renderer_type for details.
+ */
+MT32EMU_EXPORT void mt32emu_select_renderer_type(mt32emu_context context, const mt32emu_renderer_type renderer_type);
+
+/**
+ * Returns previously selected type of the wave generator and renderer.
+ * See mt32emu_renderer_type for details.
+ */
+MT32EMU_EXPORT mt32emu_renderer_type mt32emu_get_selected_renderer_type(mt32emu_context context);
+
+/**
* Prepares the emulation context to receive MIDI messages and produce output audio data using aforehand added set of ROMs,
* and optionally set the maximum partial count and the analog output mode.
* Returns MT32EMU_RC_OK upon success.
@@ -129,11 +169,28 @@ MT32EMU_EXPORT void mt32emu_close_synth(mt32emu_const_context context);
MT32EMU_EXPORT mt32emu_boolean mt32emu_is_open(mt32emu_const_context context);
/**
- * Returns actual output sample rate used in emulation of stereo analog circuitry of hardware units.
- * See comment for mt32emu_analog_output_mode.
+ * Returns actual sample rate of the fully processed output stereo signal.
+ * If samplerate conversion is used (i.e. when mt32emu_set_stereo_output_samplerate() has been invoked with a non-zero value),
+ * the returned value is the desired output samplerate rounded down to the closest integer.
+ * Otherwise, the output samplerate is choosen depending on the emulation mode of stereo analog circuitry of hardware units.
+ * See comment for mt32emu_analog_output_mode for more info.
*/
MT32EMU_EXPORT mt32emu_bit32u mt32emu_get_actual_stereo_output_samplerate(mt32emu_const_context context);
+/**
+ * Returns the number of samples produced at the internal synth sample rate (32000 Hz)
+ * that correspond to the given number of samples at the output sample rate.
+ * Intended to facilitate audio time synchronisation.
+ */
+MT32EMU_EXPORT mt32emu_bit32u mt32emu_convert_output_to_synth_timestamp(mt32emu_const_context context, mt32emu_bit32u output_timestamp);
+
+/**
+ * Returns the number of samples produced at the output sample rate
+ * that correspond to the given number of samples at the internal synth sample rate (32000 Hz).
+ * Intended to facilitate audio time synchronisation.
+ */
+MT32EMU_EXPORT mt32emu_bit32u mt32emu_convert_synth_to_output_timestamp(mt32emu_const_context context, mt32emu_bit32u synth_timestamp);
+
/** All the enqueued events are processed by the synth immediately. */
MT32EMU_EXPORT void mt32emu_flush_midi_queue(mt32emu_const_context context);
@@ -152,6 +209,12 @@ MT32EMU_EXPORT mt32emu_bit32u mt32emu_set_midi_event_queue_size(mt32emu_const_co
*/
MT32EMU_EXPORT void mt32emu_set_midi_receiver(mt32emu_context context, mt32emu_midi_receiver_i midi_receiver, void *instance_data);
+/**
+ * Returns current value of the global counter of samples rendered since the synth was created (at the native sample rate 32000 Hz).
+ * This method helps to compute accurate timestamp of a MIDI message to use with the methods below.
+ */
+MT32EMU_EXPORT mt32emu_bit32u mt32emu_get_internal_rendered_sample_count(mt32emu_const_context context);
+
/* Enqueues a MIDI event for subsequent playback.
* The MIDI event will be processed not before the specified timestamp.
* The timestamp is measured as the global rendered sample count since the synth was created (at the native sample rate 32000 Hz).
@@ -267,7 +330,6 @@ MT32EMU_EXPORT mt32emu_midi_delay_mode mt32emu_get_midi_delay_mode(mt32emu_const
* Sets output gain factor for synth output channels. Applied to all output samples and unrelated with the synth's Master volume,
* it rather corresponds to the gain of the output analog circuitry of the hardware units. However, together with mt32emu_set_reverb_output_gain()
* it offers to the user a capability to control the gain of reverb and non-reverb output channels independently.
- * Ignored in MT32EMU_DAC_PURE mode.
*/
MT32EMU_EXPORT void mt32emu_set_output_gain(mt32emu_const_context context, float gain);
/** Returns current output gain factor for synth output channels. */
@@ -282,7 +344,6 @@ MT32EMU_EXPORT float mt32emu_get_output_gain(mt32emu_const_context context);
* corresponds to the level of digital capture. Although, according to the CM-64 PCB schematic,
* there is a difference in the reverb analogue circuit, and the resulting output gain is 0.68
* of that for LA32 analogue output. This factor is applied to the reverb output gain.
- * Ignored in MT32EMU_DAC_PURE mode.
*/
MT32EMU_EXPORT void mt32emu_set_reverb_output_gain(mt32emu_const_context context, float gain);
/** Returns current output gain factor for reverb wet output channels. */
@@ -294,10 +355,21 @@ MT32EMU_EXPORT void mt32emu_set_reversed_stereo_enabled(mt32emu_const_context co
MT32EMU_EXPORT mt32emu_boolean mt32emu_is_reversed_stereo_enabled(mt32emu_const_context context);
/**
- * Renders samples to the specified output stream as if they were sampled at the analog stereo output.
- * When mt32emu_analog_output_mode is set to ACCURATE (OVERSAMPLED), the output signal is upsampled to 48 (96) kHz in order
- * to retain emulation accuracy in whole audible frequency spectra. Otherwise, native digital signal sample rate is retained.
- * mt32emu_get_actual_stereo_output_samplerate() can be used to query actual sample rate of the output signal.
+ * Allows to toggle the NiceAmpRamp mode.
+ * In this mode, we want to ensure that amp ramp never jumps to the target
+ * value and always gradually increases or decreases. It seems that real units
+ * do not bother to always check if a newly started ramp leads to a jump.
+ * We also prefer the quality improvement over the emulation accuracy,
+ * so this mode is enabled by default.
+ */
+MT32EMU_EXPORT void mt32emu_set_nice_amp_ramp_enabled(mt32emu_const_context context, const mt32emu_boolean enabled);
+/** Returns whether NiceAmpRamp mode is enabled. */
+MT32EMU_EXPORT mt32emu_boolean mt32emu_is_nice_amp_ramp_enabled(mt32emu_const_context context);
+
+/**
+ * Renders samples to the specified output stream as if they were sampled at the analog stereo output at the desired sample rate.
+ * If the output sample rate is not specified explicitly, the default output sample rate is used which depends on the current
+ * mode of analog circuitry emulation. See mt32emu_analog_output_mode.
* The length is in frames, not bytes (in 16-bit stereo, one frame is 4 bytes). Uses NATIVE byte ordering.
*/
MT32EMU_EXPORT void mt32emu_render_bit16s(mt32emu_const_context context, mt32emu_bit16s *stream, mt32emu_bit32u len);
diff --git a/audio/softsynth/mt32/c_interface/c_types.h b/audio/softsynth/mt32/c_interface/c_types.h
index 3cd8744235..dada610bd4 100644
--- a/audio/softsynth/mt32/c_interface/c_types.h
+++ b/audio/softsynth/mt32/c_interface/c_types.h
@@ -1,5 +1,5 @@
/* Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009 Dean Beeler, Jerome Fisher
- * Copyright (C) 2011-2016 Dean Beeler, Jerome Fisher, Sergey V. Mikayev
+ * Copyright (C) 2011-2017 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
@@ -68,6 +68,8 @@ typedef enum mt32emu_analog_output_mode mt32emu_analog_output_mode;
typedef enum mt32emu_dac_input_mode mt32emu_dac_input_mode;
typedef enum mt32emu_midi_delay_mode mt32emu_midi_delay_mode;
typedef enum mt32emu_partial_state mt32emu_partial_state;
+typedef enum mt32emu_samplerate_conversion_quality mt32emu_samplerate_conversion_quality;
+typedef enum mt32emu_renderer_type mt32emu_renderer_type;
#endif
/** Contains identifiers and descriptions of ROM files being used. */
@@ -117,7 +119,9 @@ typedef enum {
/** Synth interface versions */
typedef enum {
MT32EMU_SERVICE_VERSION_0 = 0,
- MT32EMU_SERVICE_VERSION_CURRENT = MT32EMU_SERVICE_VERSION_0
+ MT32EMU_SERVICE_VERSION_1 = 1,
+ MT32EMU_SERVICE_VERSION_2 = 2,
+ MT32EMU_SERVICE_VERSION_CURRENT = MT32EMU_SERVICE_VERSION_2
} mt32emu_service_version;
/* === Report Handler Interface === */
@@ -164,7 +168,7 @@ typedef struct {
/**
* Extensible interface for handling reported events.
* Union intended to view an interface of any subsequent version as any parent interface not requiring a cast.
- * Elements are to be addressed using the tag of the interface version when they were introduced.
+ * It is caller's responsibility to check the actual interface version in runtime using the getVersionID() method.
*/
union mt32emu_report_handler_i {
const mt32emu_report_handler_i_v0 *v0;
@@ -192,7 +196,7 @@ typedef struct {
/**
* Extensible interface for receiving MIDI messages.
* Union intended to view an interface of any subsequent version as any parent interface not requiring a cast.
- * Elements are to be addressed using the tag of the interface version when they were introduced.
+ * It is caller's responsibility to check the actual interface version in runtime using the getVersionID() method.
*/
union mt32emu_midi_receiver_i {
const mt32emu_midi_receiver_i_v0 *v0;
@@ -209,90 +213,124 @@ typedef union mt32emu_service_i mt32emu_service_i;
* to bind to mt32emu_get_service_i() function instead of binding to each function it needs to use.
* See c_interface.h for parameter description.
*/
-typedef struct {
- /** Returns the actual interface version ID */
- mt32emu_service_version (*getVersionID)(mt32emu_service_i i);
- mt32emu_report_handler_version (*getSupportedReportHandlerVersionID)();
- mt32emu_midi_receiver_version (*getSupportedMIDIReceiverVersionID)();
-
- mt32emu_bit32u (*getLibraryVersionInt)();
- const char *(*getLibraryVersionString)();
-
- mt32emu_bit32u (*getStereoOutputSamplerate)(const mt32emu_analog_output_mode analog_output_mode);
-
- mt32emu_context (*createContext)(mt32emu_report_handler_i report_handler, void *instance_data);
- void (*freeContext)(mt32emu_context context);
- mt32emu_return_code (*addROMData)(mt32emu_context context, const mt32emu_bit8u *data, size_t data_size, const mt32emu_sha1_digest *sha1_digest);
- mt32emu_return_code (*addROMFile)(mt32emu_context context, const char *filename);
- void (*getROMInfo)(mt32emu_const_context context, mt32emu_rom_info *rom_info);
- void (*setPartialCount)(mt32emu_context context, const mt32emu_bit32u partial_count);
- void (*setAnalogOutputMode)(mt32emu_context context, const mt32emu_analog_output_mode analog_output_mode);
- mt32emu_return_code (*openSynth)(mt32emu_const_context context);
- void (*closeSynth)(mt32emu_const_context context);
- mt32emu_boolean (*isOpen)(mt32emu_const_context context);
- mt32emu_bit32u (*getActualStereoOutputSamplerate)(mt32emu_const_context context);
- void (*flushMIDIQueue)(mt32emu_const_context context);
- mt32emu_bit32u (*setMIDIEventQueueSize)(mt32emu_const_context context, const mt32emu_bit32u queue_size);
- void (*setMIDIReceiver)(mt32emu_context context, mt32emu_midi_receiver_i midi_receiver, void *instance_data);
-
- void (*parseStream)(mt32emu_const_context context, const mt32emu_bit8u *stream, mt32emu_bit32u length);
- void (*parseStream_At)(mt32emu_const_context context, const mt32emu_bit8u *stream, mt32emu_bit32u length, mt32emu_bit32u timestamp);
- void (*playShortMessage)(mt32emu_const_context context, mt32emu_bit32u message);
- void (*playShortMessageAt)(mt32emu_const_context context, mt32emu_bit32u message, mt32emu_bit32u timestamp);
- mt32emu_return_code (*playMsg)(mt32emu_const_context context, mt32emu_bit32u msg);
- mt32emu_return_code (*playSysex)(mt32emu_const_context context, const mt32emu_bit8u *sysex, mt32emu_bit32u len);
- mt32emu_return_code (*playMsgAt)(mt32emu_const_context context, mt32emu_bit32u msg, mt32emu_bit32u timestamp);
- mt32emu_return_code (*playSysexAt)(mt32emu_const_context context, const mt32emu_bit8u *sysex, mt32emu_bit32u len, mt32emu_bit32u timestamp);
-
- void (*playMsgNow)(mt32emu_const_context context, mt32emu_bit32u msg);
- void (*playMsgOnPart)(mt32emu_const_context context, mt32emu_bit8u part, mt32emu_bit8u code, mt32emu_bit8u note, mt32emu_bit8u velocity);
- void (*playSysexNow)(mt32emu_const_context context, const mt32emu_bit8u *sysex, mt32emu_bit32u len);
- void (*writeSysex)(mt32emu_const_context context, mt32emu_bit8u channel, const mt32emu_bit8u *sysex, mt32emu_bit32u len);
-
- void (*setReverbEnabled)(mt32emu_const_context context, const mt32emu_boolean reverb_enabled);
- mt32emu_boolean (*isReverbEnabled)(mt32emu_const_context context);
- void (*setReverbOverridden)(mt32emu_const_context context, const mt32emu_boolean reverb_overridden);
- mt32emu_boolean (*isReverbOverridden)(mt32emu_const_context context);
- void (*setReverbCompatibilityMode)(mt32emu_const_context context, const mt32emu_boolean mt32_compatible_mode);
- mt32emu_boolean (*isMT32ReverbCompatibilityMode)(mt32emu_const_context context);
- mt32emu_boolean (*isDefaultReverbMT32Compatible)(mt32emu_const_context context);
-
- void (*setDACInputMode)(mt32emu_const_context context, const mt32emu_dac_input_mode mode);
- mt32emu_dac_input_mode (*getDACInputMode)(mt32emu_const_context context);
-
- void (*setMIDIDelayMode)(mt32emu_const_context context, const mt32emu_midi_delay_mode mode);
- mt32emu_midi_delay_mode (*getMIDIDelayMode)(mt32emu_const_context context);
-
- void (*setOutputGain)(mt32emu_const_context context, float gain);
- float (*getOutputGain)(mt32emu_const_context context);
- void (*setReverbOutputGain)(mt32emu_const_context context, float gain);
- float (*getReverbOutputGain)(mt32emu_const_context context);
-
- void (*setReversedStereoEnabled)(mt32emu_const_context context, const mt32emu_boolean enabled);
- mt32emu_boolean (*isReversedStereoEnabled)(mt32emu_const_context context);
-
- void (*renderBit16s)(mt32emu_const_context context, mt32emu_bit16s *stream, mt32emu_bit32u len);
- void (*renderFloat)(mt32emu_const_context context, float *stream, mt32emu_bit32u len);
- void (*renderBit16sStreams)(mt32emu_const_context context, const mt32emu_dac_output_bit16s_streams *streams, mt32emu_bit32u len);
- void (*renderFloatStreams)(mt32emu_const_context context, const mt32emu_dac_output_float_streams *streams, mt32emu_bit32u len);
-
- mt32emu_boolean (*hasActivePartials)(mt32emu_const_context context);
- mt32emu_boolean (*isActive)(mt32emu_const_context context);
- mt32emu_bit32u (*getPartialCount)(mt32emu_const_context context);
- mt32emu_bit32u (*getPartStates)(mt32emu_const_context context);
- void (*getPartialStates)(mt32emu_const_context context, mt32emu_bit8u *partial_states);
- mt32emu_bit32u (*getPlayingNotes)(mt32emu_const_context context, mt32emu_bit8u part_number, mt32emu_bit8u *keys, mt32emu_bit8u *velocities);
- const char *(*getPatchName)(mt32emu_const_context context, mt32emu_bit8u part_number);
+#define MT32EMU_SERVICE_I_V0 \
+ /** Returns the actual interface version ID */ \
+ mt32emu_service_version (*getVersionID)(mt32emu_service_i i); \
+ mt32emu_report_handler_version (*getSupportedReportHandlerVersionID)(void); \
+ mt32emu_midi_receiver_version (*getSupportedMIDIReceiverVersionID)(void); \
+\
+ mt32emu_bit32u (*getLibraryVersionInt)(void); \
+ const char *(*getLibraryVersionString)(void); \
+\
+ mt32emu_bit32u (*getStereoOutputSamplerate)(const mt32emu_analog_output_mode analog_output_mode); \
+\
+ mt32emu_context (*createContext)(mt32emu_report_handler_i report_handler, void *instance_data); \
+ void (*freeContext)(mt32emu_context context); \
+ mt32emu_return_code (*addROMData)(mt32emu_context context, const mt32emu_bit8u *data, size_t data_size, const mt32emu_sha1_digest *sha1_digest); \
+ mt32emu_return_code (*addROMFile)(mt32emu_context context, const char *filename); \
+ void (*getROMInfo)(mt32emu_const_context context, mt32emu_rom_info *rom_info); \
+ void (*setPartialCount)(mt32emu_context context, const mt32emu_bit32u partial_count); \
+ void (*setAnalogOutputMode)(mt32emu_context context, const mt32emu_analog_output_mode analog_output_mode); \
+ mt32emu_return_code (*openSynth)(mt32emu_const_context context); \
+ void (*closeSynth)(mt32emu_const_context context); \
+ mt32emu_boolean (*isOpen)(mt32emu_const_context context); \
+ mt32emu_bit32u (*getActualStereoOutputSamplerate)(mt32emu_const_context context); \
+ void (*flushMIDIQueue)(mt32emu_const_context context); \
+ mt32emu_bit32u (*setMIDIEventQueueSize)(mt32emu_const_context context, const mt32emu_bit32u queue_size); \
+ void (*setMIDIReceiver)(mt32emu_context context, mt32emu_midi_receiver_i midi_receiver, void *instance_data); \
+\
+ void (*parseStream)(mt32emu_const_context context, const mt32emu_bit8u *stream, mt32emu_bit32u length); \
+ void (*parseStream_At)(mt32emu_const_context context, const mt32emu_bit8u *stream, mt32emu_bit32u length, mt32emu_bit32u timestamp); \
+ void (*playShortMessage)(mt32emu_const_context context, mt32emu_bit32u message); \
+ void (*playShortMessageAt)(mt32emu_const_context context, mt32emu_bit32u message, mt32emu_bit32u timestamp); \
+ mt32emu_return_code (*playMsg)(mt32emu_const_context context, mt32emu_bit32u msg); \
+ mt32emu_return_code (*playSysex)(mt32emu_const_context context, const mt32emu_bit8u *sysex, mt32emu_bit32u len); \
+ mt32emu_return_code (*playMsgAt)(mt32emu_const_context context, mt32emu_bit32u msg, mt32emu_bit32u timestamp); \
+ mt32emu_return_code (*playSysexAt)(mt32emu_const_context context, const mt32emu_bit8u *sysex, mt32emu_bit32u len, mt32emu_bit32u timestamp); \
+\
+ void (*playMsgNow)(mt32emu_const_context context, mt32emu_bit32u msg); \
+ void (*playMsgOnPart)(mt32emu_const_context context, mt32emu_bit8u part, mt32emu_bit8u code, mt32emu_bit8u note, mt32emu_bit8u velocity); \
+ void (*playSysexNow)(mt32emu_const_context context, const mt32emu_bit8u *sysex, mt32emu_bit32u len); \
+ void (*writeSysex)(mt32emu_const_context context, mt32emu_bit8u channel, const mt32emu_bit8u *sysex, mt32emu_bit32u len); \
+\
+ void (*setReverbEnabled)(mt32emu_const_context context, const mt32emu_boolean reverb_enabled); \
+ mt32emu_boolean (*isReverbEnabled)(mt32emu_const_context context); \
+ void (*setReverbOverridden)(mt32emu_const_context context, const mt32emu_boolean reverb_overridden); \
+ mt32emu_boolean (*isReverbOverridden)(mt32emu_const_context context); \
+ void (*setReverbCompatibilityMode)(mt32emu_const_context context, const mt32emu_boolean mt32_compatible_mode); \
+ mt32emu_boolean (*isMT32ReverbCompatibilityMode)(mt32emu_const_context context); \
+ mt32emu_boolean (*isDefaultReverbMT32Compatible)(mt32emu_const_context context); \
+\
+ void (*setDACInputMode)(mt32emu_const_context context, const mt32emu_dac_input_mode mode); \
+ mt32emu_dac_input_mode (*getDACInputMode)(mt32emu_const_context context); \
+\
+ void (*setMIDIDelayMode)(mt32emu_const_context context, const mt32emu_midi_delay_mode mode); \
+ mt32emu_midi_delay_mode (*getMIDIDelayMode)(mt32emu_const_context context); \
+\
+ void (*setOutputGain)(mt32emu_const_context context, float gain); \
+ float (*getOutputGain)(mt32emu_const_context context); \
+ void (*setReverbOutputGain)(mt32emu_const_context context, float gain); \
+ float (*getReverbOutputGain)(mt32emu_const_context context); \
+\
+ void (*setReversedStereoEnabled)(mt32emu_const_context context, const mt32emu_boolean enabled); \
+ mt32emu_boolean (*isReversedStereoEnabled)(mt32emu_const_context context); \
+\
+ void (*renderBit16s)(mt32emu_const_context context, mt32emu_bit16s *stream, mt32emu_bit32u len); \
+ void (*renderFloat)(mt32emu_const_context context, float *stream, mt32emu_bit32u len); \
+ void (*renderBit16sStreams)(mt32emu_const_context context, const mt32emu_dac_output_bit16s_streams *streams, mt32emu_bit32u len); \
+ void (*renderFloatStreams)(mt32emu_const_context context, const mt32emu_dac_output_float_streams *streams, mt32emu_bit32u len); \
+\
+ mt32emu_boolean (*hasActivePartials)(mt32emu_const_context context); \
+ mt32emu_boolean (*isActive)(mt32emu_const_context context); \
+ mt32emu_bit32u (*getPartialCount)(mt32emu_const_context context); \
+ mt32emu_bit32u (*getPartStates)(mt32emu_const_context context); \
+ void (*getPartialStates)(mt32emu_const_context context, mt32emu_bit8u *partial_states); \
+ mt32emu_bit32u (*getPlayingNotes)(mt32emu_const_context context, mt32emu_bit8u part_number, mt32emu_bit8u *keys, mt32emu_bit8u *velocities); \
+ const char *(*getPatchName)(mt32emu_const_context context, mt32emu_bit8u part_number); \
void (*readMemory)(mt32emu_const_context context, mt32emu_bit32u addr, mt32emu_bit32u len, mt32emu_bit8u *data);
+
+#define MT32EMU_SERVICE_I_V1 \
+ mt32emu_analog_output_mode (*getBestAnalogOutputMode)(const double target_samplerate); \
+ void (*setStereoOutputSampleRate)(mt32emu_context context, const double samplerate); \
+ void (*setSamplerateConversionQuality)(mt32emu_context context, const mt32emu_samplerate_conversion_quality quality); \
+ void (*selectRendererType)(mt32emu_context context, mt32emu_renderer_type renderer_type); \
+ mt32emu_renderer_type (*getSelectedRendererType)(mt32emu_context context); \
+ mt32emu_bit32u (*convertOutputToSynthTimestamp)(mt32emu_const_context context, mt32emu_bit32u output_timestamp); \
+ mt32emu_bit32u (*convertSynthToOutputTimestamp)(mt32emu_const_context context, mt32emu_bit32u synth_timestamp);
+
+#define MT32EMU_SERVICE_I_V2 \
+ mt32emu_bit32u (*getInternalRenderedSampleCount)(mt32emu_const_context context); \
+ void (*setNiceAmpRampEnabled)(mt32emu_const_context context, const mt32emu_boolean enabled); \
+ mt32emu_boolean (*isNiceAmpRampEnabled)(mt32emu_const_context context);
+
+typedef struct {
+ MT32EMU_SERVICE_I_V0
} mt32emu_service_i_v0;
+typedef struct {
+ MT32EMU_SERVICE_I_V0
+ MT32EMU_SERVICE_I_V1
+} mt32emu_service_i_v1;
+
+typedef struct {
+ MT32EMU_SERVICE_I_V0
+ MT32EMU_SERVICE_I_V1
+ MT32EMU_SERVICE_I_V2
+} mt32emu_service_i_v2;
+
/**
* Extensible interface for all the library services.
* Union intended to view an interface of any subsequent version as any parent interface not requiring a cast.
- * Elements are to be addressed using the tag of the interface version when they were introduced.
+ * It is caller's responsibility to check the actual interface version in runtime using the getVersionID() method.
*/
union mt32emu_service_i {
const mt32emu_service_i_v0 *v0;
+ const mt32emu_service_i_v1 *v1;
+ const mt32emu_service_i_v2 *v2;
};
+#undef MT32EMU_SERVICE_I_V0
+#undef MT32EMU_SERVICE_I_V1
+#undef MT32EMU_SERVICE_I_V2
+
#endif /* #ifndef MT32EMU_C_TYPES_H */
diff --git a/audio/softsynth/mt32/c_interface/cpp_interface.h b/audio/softsynth/mt32/c_interface/cpp_interface.h
index 3e86322faa..3b02c03258 100644
--- a/audio/softsynth/mt32/c_interface/cpp_interface.h
+++ b/audio/softsynth/mt32/c_interface/cpp_interface.h
@@ -1,5 +1,5 @@
/* Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009 Dean Beeler, Jerome Fisher
- * Copyright (C) 2011-2016 Dean Beeler, Jerome Fisher, Sergey V. Mikayev
+ * Copyright (C) 2011-2017 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
@@ -28,11 +28,19 @@
#if MT32EMU_API_TYPE == 2
+extern "C" {
+
+/** Returns mt32emu_service_i interface. */
+mt32emu_service_i mt32emu_get_service_i();
+
+}
+
#define mt32emu_get_supported_report_handler_version i.v0->getSupportedReportHandlerVersionID
#define mt32emu_get_supported_midi_receiver_version i.v0->getSupportedMIDIReceiverVersionID
#define mt32emu_get_library_version_int i.v0->getLibraryVersionInt
#define mt32emu_get_library_version_string i.v0->getLibraryVersionString
#define mt32emu_get_stereo_output_samplerate i.v0->getStereoOutputSamplerate
+#define mt32emu_get_best_analog_output_mode iV1()->getBestAnalogOutputMode
#define mt32emu_create_context i.v0->createContext
#define mt32emu_free_context i.v0->freeContext
#define mt32emu_add_rom_data i.v0->addROMData
@@ -40,13 +48,20 @@
#define mt32emu_get_rom_info i.v0->getROMInfo
#define mt32emu_set_partial_count i.v0->setPartialCount
#define mt32emu_set_analog_output_mode i.v0->setAnalogOutputMode
+#define mt32emu_set_stereo_output_samplerate iV1()->setStereoOutputSampleRate
+#define mt32emu_set_samplerate_conversion_quality iV1()->setSamplerateConversionQuality
+#define mt32emu_select_renderer_type iV1()->selectRendererType
+#define mt32emu_get_selected_renderer_type iV1()->getSelectedRendererType
#define mt32emu_open_synth i.v0->openSynth
#define mt32emu_close_synth i.v0->closeSynth
#define mt32emu_is_open i.v0->isOpen
#define mt32emu_get_actual_stereo_output_samplerate i.v0->getActualStereoOutputSamplerate
+#define mt32emu_convert_output_to_synth_timestamp iV1()->convertOutputToSynthTimestamp
+#define mt32emu_convert_synth_to_output_timestamp iV1()->convertSynthToOutputTimestamp
#define mt32emu_flush_midi_queue i.v0->flushMIDIQueue
#define mt32emu_set_midi_event_queue_size i.v0->setMIDIEventQueueSize
#define mt32emu_set_midi_receiver i.v0->setMIDIReceiver
+#define mt32emu_get_internal_rendered_sample_count iV2()->getInternalRenderedSampleCount
#define mt32emu_parse_stream i.v0->parseStream
#define mt32emu_parse_stream_at i.v0->parseStream_At
#define mt32emu_play_short_message i.v0->playShortMessage
@@ -76,6 +91,8 @@
#define mt32emu_get_reverb_output_gain i.v0->getReverbOutputGain
#define mt32emu_set_reversed_stereo_enabled i.v0->setReversedStereoEnabled
#define mt32emu_is_reversed_stereo_enabled i.v0->isReversedStereoEnabled
+#define mt32emu_set_nice_amp_ramp_enabled iV2()->setNiceAmpRampEnabled
+#define mt32emu_is_nice_amp_ramp_enabled iV2()->isNiceAmpRampEnabled
#define mt32emu_render_bit16s i.v0->renderBit16s
#define mt32emu_render_float i.v0->renderFloat
#define mt32emu_render_bit16s_streams i.v0->renderBit16sStreams
@@ -171,6 +188,7 @@ public:
const char *getLibraryVersionString() { return mt32emu_get_library_version_string(); }
Bit32u getStereoOutputSamplerate(const AnalogOutputMode analog_output_mode) { return mt32emu_get_stereo_output_samplerate(static_cast<mt32emu_analog_output_mode>(analog_output_mode)); }
+ AnalogOutputMode getBestAnalogOutputMode(const double target_samplerate) { return static_cast<AnalogOutputMode>(mt32emu_get_best_analog_output_mode(target_samplerate)); }
// Context-dependent methods
@@ -183,15 +201,22 @@ public:
void getROMInfo(mt32emu_rom_info *rom_info) { mt32emu_get_rom_info(c, rom_info); }
void setPartialCount(const Bit32u partial_count) { mt32emu_set_partial_count(c, partial_count); }
void setAnalogOutputMode(const AnalogOutputMode analog_output_mode) { mt32emu_set_analog_output_mode(c, static_cast<mt32emu_analog_output_mode>(analog_output_mode)); }
+ void setStereoOutputSampleRate(const double samplerate) { mt32emu_set_stereo_output_samplerate(c, samplerate); }
+ void setSamplerateConversionQuality(const SamplerateConversionQuality quality) { mt32emu_set_samplerate_conversion_quality(c, static_cast<mt32emu_samplerate_conversion_quality>(quality)); }
+ void selectRendererType(const RendererType newRendererType) { mt32emu_select_renderer_type(c, static_cast<mt32emu_renderer_type>(newRendererType)); }
+ RendererType getSelectedRendererType() { return static_cast<RendererType>(mt32emu_get_selected_renderer_type(c)); }
mt32emu_return_code openSynth() { return mt32emu_open_synth(c); }
void closeSynth() { mt32emu_close_synth(c); }
bool isOpen() { return mt32emu_is_open(c) != MT32EMU_BOOL_FALSE; }
Bit32u getActualStereoOutputSamplerate() { return mt32emu_get_actual_stereo_output_samplerate(c); }
+ Bit32u convertOutputToSynthTimestamp(Bit32u output_timestamp) { return mt32emu_convert_output_to_synth_timestamp(c, output_timestamp); }
+ Bit32u convertSynthToOutputTimestamp(Bit32u synth_timestamp) { return mt32emu_convert_synth_to_output_timestamp(c, synth_timestamp); }
void flushMIDIQueue() { mt32emu_flush_midi_queue(c); }
Bit32u setMIDIEventQueueSize(const Bit32u queue_size) { return mt32emu_set_midi_event_queue_size(c, queue_size); }
void setMIDIReceiver(mt32emu_midi_receiver_i midi_receiver, void *instance_data) { mt32emu_set_midi_receiver(c, midi_receiver, instance_data); }
void setMIDIReceiver(IMidiReceiver &midi_receiver) { setMIDIReceiver(CppInterfaceImpl::getMidiReceiverThunk(), &midi_receiver); }
+ Bit32u getInternalRenderedSampleCount() { return mt32emu_get_internal_rendered_sample_count(c); }
void parseStream(const Bit8u *stream, Bit32u length) { mt32emu_parse_stream(c, stream, length); }
void parseStream_At(const Bit8u *stream, Bit32u length, Bit32u timestamp) { mt32emu_parse_stream_at(c, stream, length, timestamp); }
void playShortMessage(Bit32u message) { mt32emu_play_short_message(c, message); }
@@ -228,6 +253,9 @@ public:
void setReversedStereoEnabled(const bool enabled) { mt32emu_set_reversed_stereo_enabled(c, enabled ? MT32EMU_BOOL_TRUE : MT32EMU_BOOL_FALSE); }
bool isReversedStereoEnabled() { return mt32emu_is_reversed_stereo_enabled(c) != MT32EMU_BOOL_FALSE; }
+ void setNiceAmpRampEnabled(const bool enabled) { mt32emu_set_nice_amp_ramp_enabled(c, enabled ? MT32EMU_BOOL_TRUE : MT32EMU_BOOL_FALSE); }
+ bool isNiceAmpRampEnabled() { return mt32emu_is_nice_amp_ramp_enabled(c) != MT32EMU_BOOL_FALSE; }
+
void renderBit16s(Bit16s *stream, Bit32u len) { mt32emu_render_bit16s(c, stream, len); }
void renderFloat(float *stream, Bit32u len) { mt32emu_render_float(c, stream, len); }
void renderBit16sStreams(const mt32emu_dac_output_bit16s_streams *streams, Bit32u len) { mt32emu_render_bit16s_streams(c, streams, len); }
@@ -247,6 +275,11 @@ private:
const mt32emu_service_i i;
#endif
mt32emu_context c;
+
+#if MT32EMU_API_TYPE == 2
+ const mt32emu_service_i_v1 *iV1() { return (getVersionID() < MT32EMU_SERVICE_VERSION_1) ? NULL : i.v1; }
+ const mt32emu_service_i_v2 *iV2() { return (getVersionID() < MT32EMU_SERVICE_VERSION_2) ? NULL : i.v2; }
+#endif
};
namespace CppInterfaceImpl {
@@ -256,59 +289,59 @@ static mt32emu_report_handler_version getReportHandlerVersionID(mt32emu_report_h
}
static void printDebug(void *instance_data, const char *fmt, va_list list) {
- ((IReportHandler *)instance_data)->printDebug(fmt, list);
+ static_cast<IReportHandler *>(instance_data)->printDebug(fmt, list);
}
static void onErrorControlROM(void *instance_data) {
- ((IReportHandler *)instance_data)->onErrorControlROM();
+ static_cast<IReportHandler *>(instance_data)->onErrorControlROM();
}
static void onErrorPCMROM(void *instance_data) {
- ((IReportHandler *)instance_data)->onErrorPCMROM();
+ static_cast<IReportHandler *>(instance_data)->onErrorPCMROM();
}
static void showLCDMessage(void *instance_data, const char *message) {
- ((IReportHandler *)instance_data)->showLCDMessage(message);
+ static_cast<IReportHandler *>(instance_data)->showLCDMessage(message);
}
static void onMIDIMessagePlayed(void *instance_data) {
- ((IReportHandler *)instance_data)->onMIDIMessagePlayed();
+ static_cast<IReportHandler *>(instance_data)->onMIDIMessagePlayed();
}
static mt32emu_boolean onMIDIQueueOverflow(void *instance_data) {
- return ((IReportHandler *)instance_data)->onMIDIQueueOverflow() ? MT32EMU_BOOL_TRUE : MT32EMU_BOOL_FALSE;
+ return static_cast<IReportHandler *>(instance_data)->onMIDIQueueOverflow() ? MT32EMU_BOOL_TRUE : MT32EMU_BOOL_FALSE;
}
static void onMIDISystemRealtime(void *instance_data, mt32emu_bit8u system_realtime) {
- ((IReportHandler *)instance_data)->onMIDISystemRealtime(system_realtime);
+ static_cast<IReportHandler *>(instance_data)->onMIDISystemRealtime(system_realtime);
}
static void onDeviceReset(void *instance_data) {
- ((IReportHandler *)instance_data)->onDeviceReset();
+ static_cast<IReportHandler *>(instance_data)->onDeviceReset();
}
static void onDeviceReconfig(void *instance_data) {
- ((IReportHandler *)instance_data)->onDeviceReconfig();
+ static_cast<IReportHandler *>(instance_data)->onDeviceReconfig();
}
static void onNewReverbMode(void *instance_data, mt32emu_bit8u mode) {
- ((IReportHandler *)instance_data)->onNewReverbMode(mode);
+ static_cast<IReportHandler *>(instance_data)->onNewReverbMode(mode);
}
static void onNewReverbTime(void *instance_data, mt32emu_bit8u time) {
- ((IReportHandler *)instance_data)->onNewReverbTime(time);
+ static_cast<IReportHandler *>(instance_data)->onNewReverbTime(time);
}
static void onNewReverbLevel(void *instance_data, mt32emu_bit8u level) {
- ((IReportHandler *)instance_data)->onNewReverbLevel(level);
+ static_cast<IReportHandler *>(instance_data)->onNewReverbLevel(level);
}
static void onPolyStateChanged(void *instance_data, mt32emu_bit8u part_num) {
- ((IReportHandler *)instance_data)->onPolyStateChanged(part_num);
+ static_cast<IReportHandler *>(instance_data)->onPolyStateChanged(part_num);
}
static void onProgramChanged(void *instance_data, mt32emu_bit8u part_num, const char *sound_group_name, const char *patch_name) {
- ((IReportHandler *)instance_data)->onProgramChanged(part_num, sound_group_name, patch_name);
+ static_cast<IReportHandler *>(instance_data)->onProgramChanged(part_num, sound_group_name, patch_name);
}
static mt32emu_report_handler_i getReportHandlerThunk() {
@@ -340,15 +373,15 @@ static mt32emu_midi_receiver_version getMidiReceiverVersionID(mt32emu_midi_recei
}
static void handleShortMessage(void *instance_data, const mt32emu_bit32u message) {
- ((IMidiReceiver *)instance_data)->handleShortMessage(message);
+ static_cast<IMidiReceiver *>(instance_data)->handleShortMessage(message);
}
static void handleSysex(void *instance_data, const mt32emu_bit8u stream[], const mt32emu_bit32u length) {
- ((IMidiReceiver *)instance_data)->handleSysex(stream, length);
+ static_cast<IMidiReceiver *>(instance_data)->handleSysex(stream, length);
}
static void handleSystemRealtimeMessage(void *instance_data, const mt32emu_bit8u realtime) {
- ((IMidiReceiver *)instance_data)->handleSystemRealtimeMessage(realtime);
+ static_cast<IMidiReceiver *>(instance_data)->handleSystemRealtimeMessage(realtime);
}
static mt32emu_midi_receiver_i getMidiReceiverThunk() {
@@ -375,6 +408,7 @@ static mt32emu_midi_receiver_i getMidiReceiverThunk() {
#undef mt32emu_get_library_version_int
#undef mt32emu_get_library_version_string
#undef mt32emu_get_stereo_output_samplerate
+#undef mt32emu_get_best_analog_output_mode
#undef mt32emu_create_context
#undef mt32emu_free_context
#undef mt32emu_add_rom_data
@@ -382,13 +416,20 @@ static mt32emu_midi_receiver_i getMidiReceiverThunk() {
#undef mt32emu_get_rom_info
#undef mt32emu_set_partial_count
#undef mt32emu_set_analog_output_mode
+#undef mt32emu_set_stereo_output_samplerate
+#undef mt32emu_set_samplerate_conversion_quality
+#undef mt32emu_select_renderer_type
+#undef mt32emu_get_selected_renderer_type
#undef mt32emu_open_synth
#undef mt32emu_close_synth
#undef mt32emu_is_open
#undef mt32emu_get_actual_stereo_output_samplerate
+#undef mt32emu_convert_output_to_synth_timestamp
+#undef mt32emu_convert_synth_to_output_timestamp
#undef mt32emu_flush_midi_queue
#undef mt32emu_set_midi_event_queue_size
#undef mt32emu_set_midi_receiver
+#undef mt32emu_get_internal_rendered_sample_count
#undef mt32emu_parse_stream
#undef mt32emu_parse_stream_at
#undef mt32emu_play_short_message
@@ -418,6 +459,8 @@ static mt32emu_midi_receiver_i getMidiReceiverThunk() {
#undef mt32emu_get_reverb_output_gain
#undef mt32emu_set_reversed_stereo_enabled
#undef mt32emu_is_reversed_stereo_enabled
+#undef mt32emu_set_nice_amp_ramp_enabled
+#undef mt32emu_is_nice_amp_ramp_enabled
#undef mt32emu_render_bit16s
#undef mt32emu_render_float
#undef mt32emu_render_bit16s_streams