- added a configuration record that can be used by the client to set up the needed data structures, allowing to deal with internal changes without having to recompile against a more recent version.

Also added the missing defaults for the Dumb config and renamed a few things.
This commit is contained in:
Christoph Oelckers 2020-01-04 19:03:42 +01:00
parent fb0d3ac183
commit 778d0c8faa
3 changed files with 138 additions and 23 deletions

View file

@ -140,7 +140,7 @@ enum EIntConfigKey
enum EFloatConfigKey
{
zmusic_fluid_gain,
zmusic_fluid_gain = 1000,
zmusic_fluid_reverb_roomsize,
zmusic_fluid_reverb_damping,
zmusic_fluid_reverb_width,
@ -151,7 +151,7 @@ enum EFloatConfigKey
zmusic_timidity_drum_power,
zmusic_timidity_tempo_adjust,
zmusic_min_sustain_time,
zmusic_timidity_min_sustain_time,
zmusic_gme_stereodepth,
zmusic_mod_dumb_mastervolume,
@ -165,7 +165,7 @@ enum EFloatConfigKey
enum EStringConfigKey
{
zmusic_adl_custom_bank,
zmusic_adl_custom_bank = 2000,
zmusic_fluid_lib,
zmusic_fluid_patchset,
zmusic_opn_custom_bank,
@ -188,14 +188,14 @@ struct ZMusicCustomReader
void (*close)(struct ZMusicCustomReader* handle);
};
struct MidiOutDevice
struct ZMusicMidiOutDevice
{
char *Name;
int ID;
int Technology;
};
struct Callbacks
struct ZMusicCallbacks
{
// Callbacks the client can install to capture messages from the backends
// or to provide sound font data.
@ -231,6 +231,22 @@ struct Callbacks
const char *(*NicePath)(const char* path);
};
enum ZMusicVariableType
{
ZMUSIC_VAR_INT,
ZMUSIC_VAR_BOOL,
ZMUSIC_VAR_FLOAT,
ZMUSIC_VAR_STRING,
};
struct ZMusicConfigurationSetting
{
const char* name;
int identifier;
ZMusicVariableType type;
float defaultVal;
const char* defaultString;
};
#ifndef ZMUSIC_INTERNAL
#ifdef _MSC_VER
@ -251,7 +267,7 @@ extern "C"
DLL_IMPORT const char* ZMusic_GetLastError();
// Sets callbacks for functionality that the client needs to provide.
DLL_IMPORT void ZMusic_SetCallbacks(const Callbacks* callbacks);
DLL_IMPORT void ZMusic_SetCallbacks(const ZMusicCallbacks* callbacks);
// Sets GenMidi data for OPL playback. If this isn't provided the OPL synth will not work.
DLL_IMPORT void ZMusic_SetGenMidi(const uint8_t* data);
// Set default bank for OPN. Without this OPN only works with custom banks.
@ -259,6 +275,9 @@ extern "C"
// Set DMXGUS data for running the GUS synth in actual GUS mode.
DLL_IMPORT void ZMusic_SetDmxGus(const void* data, unsigned len);
// Returns an array with all available configuration options - terminated with an empty entry where all elements are 0.
DLL_IMPORT const ZMusicConfigurationSetting* ZMusic_GetConfiguration();
// These exports are needed by the MIDI dumpers which need to remain on the client side because the need access to the client's file system.
DLL_IMPORT EMIDIType ZMusic_IdentifyMIDIType(uint32_t* id, int size);
DLL_IMPORT ZMusic_MidiSource ZMusic_CreateMIDISource(const uint8_t* data, size_t length, EMIDIType miditype);
@ -298,7 +317,7 @@ extern "C"
DLL_IMPORT void FindLoopTags(const uint8_t* data, size_t size, uint32_t* start, bool* startass, uint32_t* end, bool* endass);
// The rest of the decoder interface is only useful for streaming music.
DLL_IMPORT const MidiOutDevice *ZMusic_GetMidiDevices(int *pAmount);
DLL_IMPORT const ZMusicMidiOutDevice *ZMusic_GetMidiDevices(int *pAmount);
#ifdef __cplusplus
}

View file

@ -59,7 +59,7 @@ struct Dummy
MiscConfig miscConfig;
Callbacks musicCallbacks;
ZMusicCallbacks musicCallbacks;
class SoundFontWrapperInterface : public MusicIO::SoundFontReaderInterface
{
@ -104,7 +104,7 @@ namespace MusicIO {
}
DLL_EXPORT void ZMusic_SetCallbacks(const Callbacks* cb)
DLL_EXPORT void ZMusic_SetCallbacks(const ZMusicCallbacks* cb)
{
musicCallbacks = *cb;
// If not all these are set the sound font interface is not usable.
@ -155,7 +155,7 @@ int ZMusic_EnumerateMidiDevices()
struct MidiDeviceList
{
std::vector<MidiOutDevice> devices;
std::vector<ZMusicMidiOutDevice> devices;
~MidiDeviceList()
{
for (auto& device : devices)
@ -194,7 +194,7 @@ struct MidiDeviceList
auto& dev = sequencer.GetInternalDevices();
for (auto& d : dev)
{
MidiOutDevice mdev = { strdup(d.Name.c_str()), d.ID, MIDIDEV_MAPPER }; // fixme: Correctly determine the type of the device.
ZMusicMidiOutDevice mdev = { strdup(d.Name.c_str()), d.ID, MIDIDEV_MAPPER }; // fixme: Correctly determine the type of the device.
devices.push_back(mdev);
}
#elif _WIN32
@ -213,7 +213,7 @@ struct MidiDeviceList
WideCharToMultiByte(CP_UTF8, 0, caps.szPname, (int)len, outbuf, size_needed, nullptr, nullptr);
outbuf[size_needed] = 0;
MidiOutDevice mdev = { outbuf, int(id), caps.wTechnology };
ZMusicMidiOutDevice mdev = { outbuf, int(id), caps.wTechnology };
devices.push_back(mdev);
}
}
@ -225,7 +225,7 @@ struct MidiDeviceList
static MidiDeviceList devlist;
DLL_EXPORT const MidiOutDevice* ZMusic_GetMidiDevices(int* pAmount)
DLL_EXPORT const ZMusicMidiOutDevice* ZMusic_GetMidiDevices(int* pAmount)
{
if (devlist.devices.size() == 0) devlist.Build();
if (pAmount) *pAmount = (int)devlist.devices.size();
@ -753,7 +753,7 @@ DLL_EXPORT bool ChangeMusicSettingFloat(EFloatConfigKey key, MusInfo* currSong,
if (pRealValue) *pRealValue = value;
return false;
case zmusic_min_sustain_time:
case zmusic_timidity_min_sustain_time:
if (value < 0) value = 0;
ChangeVarSync(TimidityPlus::min_sustain_time, value);
if (pRealValue) *pRealValue = value;
@ -839,3 +839,101 @@ DLL_EXPORT bool ChangeMusicSettingString(EStringConfigKey key, MusInfo* currSong
return false;
}
static ZMusicConfigurationSetting config[] = {
#ifdef HAVE_ADL
{"zmusic_adl_chips_count", zmusic_adl_chips_count, ZMUSIC_VAR_INT, 5},
{"zmusic_adl_emulator_id", zmusic_adl_emulator_id, ZMUSIC_VAR_INT, 0},
{"zmusic_adl_run_at_pcm_rate", zmusic_adl_run_at_pcm_rate, ZMUSIC_VAR_BOOL, 0},
{"zmusic_adl_fullpan", zmusic_adl_fullpan, ZMUSIC_VAR_BOOL, 1},
{"zmusic_adl_bank", zmusic_adl_bank, ZMUSIC_VAR_INT, 14},
{"zmusic_adl_use_custom_bank", zmusic_adl_use_custom_bank, ZMUSIC_VAR_BOOL, 0},
{"zmusic_adl_volume_model", zmusic_adl_volume_model, ZMUSIC_VAR_INT, 3},
{"zmusic_adl_custom_bank", zmusic_adl_custom_bank, ZMUSIC_VAR_STRING, 0},
#endif
{"zmusic_fluid_reverb", zmusic_fluid_reverb, ZMUSIC_VAR_BOOL, 0},
{"zmusic_fluid_chorus", zmusic_fluid_chorus, ZMUSIC_VAR_BOOL, 0},
{"zmusic_fluid_voices", zmusic_fluid_voices, ZMUSIC_VAR_INT, 128},
{"zmusic_fluid_interp", zmusic_fluid_interp, ZMUSIC_VAR_INT, 1},
{"zmusic_fluid_samplerate", zmusic_fluid_samplerate, ZMUSIC_VAR_INT, 0},
{"zmusic_fluid_threads", zmusic_fluid_threads, ZMUSIC_VAR_INT, 1},
{"zmusic_fluid_chorus_voices", zmusic_fluid_chorus_voices, ZMUSIC_VAR_INT, 3},
{"zmusic_fluid_chorus_type", zmusic_fluid_chorus_type, ZMUSIC_VAR_INT, 0},
{"zmusic_fluid_gain", zmusic_fluid_gain, ZMUSIC_VAR_FLOAT, 0},
{"zmusic_fluid_reverb_roomsize", zmusic_fluid_reverb_roomsize, ZMUSIC_VAR_FLOAT, 0.75f},
{"zmusic_fluid_reverb_damping", zmusic_fluid_reverb_damping, ZMUSIC_VAR_FLOAT, 0.23f},
{"zmusic_fluid_reverb_width", zmusic_fluid_reverb_width, ZMUSIC_VAR_FLOAT, 0.75f},
{"zmusic_fluid_reverb_level", zmusic_fluid_reverb_level, ZMUSIC_VAR_FLOAT, 0.57f},
{"zmusic_fluid_chorus_level", zmusic_fluid_chorus_level, ZMUSIC_VAR_FLOAT, 1.2f},
{"zmusic_fluid_chorus_speed", zmusic_fluid_chorus_speed, ZMUSIC_VAR_FLOAT, 0.3f},
{"zmusic_fluid_chorus_depth", zmusic_fluid_chorus_depth, ZMUSIC_VAR_FLOAT, 8},
{"zmusic_fluid_lib", zmusic_fluid_lib, ZMUSIC_VAR_STRING, 0},
#ifdef HAVE_OPL
{"zmusic_opl_numchips", zmusic_opl_numchips, ZMUSIC_VAR_INT, 2},
{"zmusic_opl_core", zmusic_opl_core, ZMUSIC_VAR_INT, 0},
{"zmusic_opl_fullpan", zmusic_opl_fullpan, ZMUSIC_VAR_BOOL, 1},
#endif
#ifdef HAVE_OPN
{"zmusic_opn_chips_count", zmusic_opn_chips_count, ZMUSIC_VAR_INT, 8},
{"zmusic_opn_emulator_id", zmusic_opn_emulator_id, ZMUSIC_VAR_INT, 0},
{"zmusic_opn_run_at_pcm_rate", zmusic_opn_run_at_pcm_rate, ZMUSIC_VAR_BOOL, 0},
{"zmusic_opn_fullpan", zmusic_opn_fullpan, ZMUSIC_VAR_BOOL, 2},
{"zmusic_opn_use_custom_bank", zmusic_opn_use_custom_bank, ZMUSIC_VAR_BOOL, 0},
{"zmusic_opn_custom_bank", zmusic_opn_custom_bank, ZMUSIC_VAR_STRING, 0},
#endif
#ifdef HAVE_GUS
{"zmusic_gus_dmxgus", zmusic_gus_dmxgus, ZMUSIC_VAR_BOOL, 0},
{"zmusic_gus_midi_voices", zmusic_gus_midi_voices, ZMUSIC_VAR_INT, 32},
{"zmusic_gus_memsize", zmusic_gus_memsize, ZMUSIC_VAR_INT, 0},
{"zmusic_gus_config", zmusic_gus_config, ZMUSIC_VAR_STRING, 0},
{"zmusic_gus_patchdir", zmusic_gus_patchdir, ZMUSIC_VAR_STRING, 0},
#endif
#ifdef HAVE_TIMIDITY
{"zmusic_timidity_modulation_wheel", zmusic_timidity_modulation_wheel, ZMUSIC_VAR_BOOL, 1},
{"zmusic_timidity_portamento", zmusic_timidity_portamento, ZMUSIC_VAR_BOOL, 0},
{"zmusic_timidity_reverb", zmusic_timidity_reverb, ZMUSIC_VAR_INT, 0},
{"zmusic_timidity_reverb_level", zmusic_timidity_reverb_level, ZMUSIC_VAR_INT, 0},
{"zmusic_timidity_chorus", zmusic_timidity_chorus, ZMUSIC_VAR_BOOL, 0},
{"zmusic_timidity_surround_chorus", zmusic_timidity_surround_chorus, ZMUSIC_VAR_BOOL, 0},
{"zmusic_timidity_channel_pressure", zmusic_timidity_channel_pressure, ZMUSIC_VAR_BOOL, 0},
{"zmusic_timidity_lpf_def", zmusic_timidity_lpf_def, ZMUSIC_VAR_BOOL, 1},
{"zmusic_timidity_temper_control", zmusic_timidity_temper_control, ZMUSIC_VAR_BOOL, 1},
{"zmusic_timidity_modulation_envelope", zmusic_timidity_modulation_envelope, ZMUSIC_VAR_BOOL, 1},
{"zmusic_timidity_overlap_voice_allow", zmusic_timidity_overlap_voice_allow, ZMUSIC_VAR_BOOL, 1},
{"zmusic_timidity_drum_effect", zmusic_timidity_drum_effect, ZMUSIC_VAR_BOOL, 0},
{"zmusic_timidity_pan_delay", zmusic_timidity_pan_delay, ZMUSIC_VAR_BOOL, 0},
{"zmusic_timidity_key_adjust", zmusic_timidity_key_adjust, ZMUSIC_VAR_INT, 0},
{"zmusic_timidity_drum_power", zmusic_timidity_drum_power, ZMUSIC_VAR_FLOAT, 1},
{"zmusic_timidity_tempo_adjust", zmusic_timidity_tempo_adjust, ZMUSIC_VAR_FLOAT, 1},
{"zmusic_timidity_min_sustain_time", zmusic_timidity_min_sustain_time, ZMUSIC_VAR_FLOAT, 5000},
{"zmusic_timidity_config", zmusic_timidity_config, ZMUSIC_VAR_STRING, 0},
#endif
#ifdef HAVE_WILDMIDI
{"zmusic_wildmidi_reverb", zmusic_wildmidi_reverb, ZMUSIC_VAR_BOOL, 0},
{"zmusic_wildmidi_enhanced_resampling", zmusic_wildmidi_enhanced_resampling, ZMUSIC_VAR_BOOL, 1},
{"zmusic_wildmidi_config", zmusic_wildmidi_config, ZMUSIC_VAR_STRING, 0},
#endif
{"zmusic_mod_samplerate", zmusic_mod_samplerate, ZMUSIC_VAR_INT, 0},
{"zmusic_mod_volramp", zmusic_mod_volramp, ZMUSIC_VAR_INT, 2},
{"zmusic_mod_interp", zmusic_mod_interp, ZMUSIC_VAR_BOOL, 2},
{"zmusic_mod_autochip", zmusic_mod_autochip, ZMUSIC_VAR_BOOL, 0},
{"zmusic_mod_autochip_size_force", zmusic_mod_autochip_size_force, ZMUSIC_VAR_INT, 100},
{"zmusic_mod_autochip_size_scan", zmusic_mod_autochip_size_scan, ZMUSIC_VAR_INT, 500},
{"zmusic_mod_autochip_scan_threshold", zmusic_mod_autochip_scan_threshold, ZMUSIC_VAR_INT, 12},
{"zmusic_mod_dumb_mastervolume", zmusic_mod_dumb_mastervolume, ZMUSIC_VAR_FLOAT, 1},
{"zmusic_gme_stereodepth", zmusic_gme_stereodepth, ZMUSIC_VAR_FLOAT, 0},
{"zmusic_snd_midiprecache", zmusic_snd_midiprecache, ZMUSIC_VAR_BOOL, 1},
{"zmusic_snd_streambuffersize", zmusic_snd_streambuffersize, ZMUSIC_VAR_INT, 64},
{"zmusic_snd_mididevice", zmusic_snd_mididevice, ZMUSIC_VAR_INT, 0},
{"zmusic_snd_outputrate", zmusic_snd_outputrate, ZMUSIC_VAR_INT, 44100},
{"zmusic_snd_musicvolume", zmusic_snd_musicvolume, ZMUSIC_VAR_FLOAT, 1},
{"zmusic_relative_volume", zmusic_relative_volume, ZMUSIC_VAR_FLOAT, 1},
{"zmusic_snd_mastervolume", zmusic_snd_mastervolume, ZMUSIC_VAR_FLOAT, 1},
{}
};
DLL_EXPORT const ZMusicConfigurationSetting* ZMusic_GetConfiguration()
{
return config;
}

View file

@ -123,17 +123,15 @@ struct WildMidiConfig
struct DumbConfig
{
int mod_samplerate;
int mod_volramp;
int mod_interp;
int mod_volramp = 2;
int mod_interp = 2;
int mod_autochip;
int mod_autochip_size_force;
int mod_autochip_size_scan;
int mod_autochip_scan_threshold;
float mod_dumb_mastervolume;
int mod_autochip_size_force = 100;
int mod_autochip_size_scan = 500;
int mod_autochip_scan_threshold = 12;
float mod_dumb_mastervolume = 1;
};
// The rest is not used yet.
struct MiscConfig
{
int snd_midiprecache;
@ -155,5 +153,5 @@ extern TimidityConfig timidityConfig;
extern WildMidiConfig wildMidiConfig;
extern DumbConfig dumbConfig;
extern MiscConfig miscConfig;
extern Callbacks musicCallbacks;
extern ZMusicCallbacks musicCallbacks;