From 9f579d99f31cf3b9c9552d90e538d9d9943cb905 Mon Sep 17 00:00:00 2001 From: Marcus Weseloh Date: Thu, 30 Nov 2017 19:51:21 +0100 Subject: [PATCH] Remove callback and data parameters from settings_register_* functions Callback functions and user data can be set with the previously added functions. And callbacks are only used in a single place in new_fluid_synth, all other calls to setttings_register_* set those two params to NULL, so lets remove them everywhere. --- src/bindings/fluid_cmd.c | 4 +- src/bindings/fluid_filerenderer.c | 16 +++--- src/drivers/fluid_adriver.c | 38 ++++++------- src/drivers/fluid_alsa.c | 8 +-- src/drivers/fluid_coreaudio.c | 2 +- src/drivers/fluid_coremidi.c | 2 +- src/drivers/fluid_dart.c | 2 +- src/drivers/fluid_dsound.c | 2 +- src/drivers/fluid_jack.c | 12 ++-- src/drivers/fluid_mdriver.c | 18 +++--- src/drivers/fluid_oss.c | 4 +- src/drivers/fluid_portaudio.c | 2 +- src/drivers/fluid_pulse.c | 8 +-- src/drivers/fluid_winmidi.c | 2 +- src/midi/fluid_midi.c | 6 +- src/synth/fluid_synth.c | 95 ++++++++++++------------------- src/utils/fluid_settings.c | 59 +++++++------------ src/utils/fluid_settings.h | 9 +-- 18 files changed, 122 insertions(+), 167 deletions(-) diff --git a/src/bindings/fluid_cmd.c b/src/bindings/fluid_cmd.c index 2d525d63..4e79f66b 100644 --- a/src/bindings/fluid_cmd.c +++ b/src/bindings/fluid_cmd.c @@ -80,8 +80,8 @@ static int fluid_handle_voice_count (void* data, int ac, char **av, void fluid_shell_settings(fluid_settings_t* settings) { - fluid_settings_register_str(settings, "shell.prompt", "", 0, NULL, NULL); - fluid_settings_register_int(settings, "shell.port", 9800, 1, 65535, 0, NULL, NULL); + fluid_settings_register_str(settings, "shell.prompt", "", 0); + fluid_settings_register_int(settings, "shell.port", 9800, 1, 65535, 0); } diff --git a/src/bindings/fluid_filerenderer.c b/src/bindings/fluid_filerenderer.c index 3a26f36f..8ef4a051 100644 --- a/src/bindings/fluid_filerenderer.c +++ b/src/bindings/fluid_filerenderer.c @@ -113,10 +113,10 @@ fluid_file_renderer_settings (fluid_settings_t* settings) unsigned int n; fluid_settings_register_str(settings, "audio.file.name", "fluidsynth.wav", - FLUID_HINT_FILENAME, NULL, NULL); - fluid_settings_register_str(settings, "audio.file.type", "auto", 0, NULL, NULL); - fluid_settings_register_str(settings, "audio.file.format", "s16", 0, NULL, NULL); - fluid_settings_register_str(settings, "audio.file.endian", "auto", 0, NULL, NULL); + FLUID_HINT_FILENAME); + fluid_settings_register_str(settings, "audio.file.type", "auto", 0); + fluid_settings_register_str(settings, "audio.file.format", "s16", 0); + fluid_settings_register_str(settings, "audio.file.endian", "auto", 0); fluid_settings_add_option (settings, "audio.file.type", "auto"); @@ -149,12 +149,12 @@ fluid_file_renderer_settings (fluid_settings_t* settings) #else - fluid_settings_register_str(settings, "audio.file.name", "fluidsynth.raw", 0, NULL, NULL); - fluid_settings_register_str(settings, "audio.file.type", "raw", 0, NULL, NULL); + fluid_settings_register_str(settings, "audio.file.name", "fluidsynth.raw", 0); + fluid_settings_register_str(settings, "audio.file.type", "raw", 0); fluid_settings_add_option (settings, "audio.file.type", "raw"); - fluid_settings_register_str(settings, "audio.file.format", "s16", 0, NULL, NULL); + fluid_settings_register_str(settings, "audio.file.format", "s16", 0); fluid_settings_add_option (settings, "audio.file.format", "s16"); - fluid_settings_register_str(settings, "audio.file.endian", "cpu", 0, NULL, NULL); + fluid_settings_register_str(settings, "audio.file.endian", "cpu", 0); fluid_settings_add_option (settings, "audio.file.endian", "cpu"); #endif } diff --git a/src/drivers/fluid_adriver.c b/src/drivers/fluid_adriver.c index 0f689519..fd4ff014 100644 --- a/src/drivers/fluid_adriver.c +++ b/src/drivers/fluid_adriver.c @@ -268,47 +268,47 @@ void fluid_audio_driver_settings(fluid_settings_t* settings) { unsigned int i; - fluid_settings_register_str(settings, "audio.sample-format", "16bits", 0, NULL, NULL); + fluid_settings_register_str(settings, "audio.sample-format", "16bits", 0); fluid_settings_add_option(settings, "audio.sample-format", "16bits"); fluid_settings_add_option(settings, "audio.sample-format", "float"); #if defined(WIN32) - fluid_settings_register_int(settings, "audio.period-size", 512, 64, 8192, 0, NULL, NULL); - fluid_settings_register_int(settings, "audio.periods", 8, 2, 64, 0, NULL, NULL); + fluid_settings_register_int(settings, "audio.period-size", 512, 64, 8192, 0); + fluid_settings_register_int(settings, "audio.periods", 8, 2, 64, 0); #elif defined(MACOS9) - fluid_settings_register_int(settings, "audio.period-size", 64, 64, 8192, 0, NULL, NULL); - fluid_settings_register_int(settings, "audio.periods", 8, 2, 64, 0, NULL, NULL); + fluid_settings_register_int(settings, "audio.period-size", 64, 64, 8192, 0); + fluid_settings_register_int(settings, "audio.periods", 8, 2, 64, 0); #else - fluid_settings_register_int(settings, "audio.period-size", 64, 64, 8192, 0, NULL, NULL); - fluid_settings_register_int(settings, "audio.periods", 16, 2, 64, 0, NULL, NULL); + fluid_settings_register_int(settings, "audio.period-size", 64, 64, 8192, 0); + fluid_settings_register_int(settings, "audio.periods", 16, 2, 64, 0); #endif fluid_settings_register_int (settings, "audio.realtime-prio", - FLUID_DEFAULT_AUDIO_RT_PRIO, 0, 99, 0, NULL, NULL); + FLUID_DEFAULT_AUDIO_RT_PRIO, 0, 99, 0); /* Set the default driver */ #if JACK_SUPPORT - fluid_settings_register_str(settings, "audio.driver", "jack", 0, NULL, NULL); + fluid_settings_register_str(settings, "audio.driver", "jack", 0); #elif ALSA_SUPPORT - fluid_settings_register_str(settings, "audio.driver", "alsa", 0, NULL, NULL); + fluid_settings_register_str(settings, "audio.driver", "alsa", 0); #elif PULSE_SUPPORT - fluid_settings_register_str(settings, "audio.driver", "pulseaudio", 0, NULL, NULL); + fluid_settings_register_str(settings, "audio.driver", "pulseaudio", 0); #elif OSS_SUPPORT - fluid_settings_register_str(settings, "audio.driver", "oss", 0, NULL, NULL); + fluid_settings_register_str(settings, "audio.driver", "oss", 0); #elif COREAUDIO_SUPPORT - fluid_settings_register_str(settings, "audio.driver", "coreaudio", 0, NULL, NULL); + fluid_settings_register_str(settings, "audio.driver", "coreaudio", 0); #elif DSOUND_SUPPORT - fluid_settings_register_str(settings, "audio.driver", "dsound", 0, NULL, NULL); + fluid_settings_register_str(settings, "audio.driver", "dsound", 0); #elif SNDMAN_SUPPORT - fluid_settings_register_str(settings, "audio.driver", "sndman", 0, NULL, NULL); + fluid_settings_register_str(settings, "audio.driver", "sndman", 0); #elif PORTAUDIO_SUPPORT - fluid_settings_register_str(settings, "audio.driver", "portaudio", 0, NULL, NULL); + fluid_settings_register_str(settings, "audio.driver", "portaudio", 0); #elif DART_SUPPORT - fluid_settings_register_str(settings, "audio.driver", "dart", 0, NULL, NULL); + fluid_settings_register_str(settings, "audio.driver", "dart", 0); #elif AUFILE_SUPPORT - fluid_settings_register_str(settings, "audio.driver", "file", 0, NULL, NULL); + fluid_settings_register_str(settings, "audio.driver", "file", 0); #else - fluid_settings_register_str(settings, "audio.driver", "", 0, NULL, NULL); + fluid_settings_register_str(settings, "audio.driver", "", 0); #endif /* Add all drivers to the list of options */ diff --git a/src/drivers/fluid_alsa.c b/src/drivers/fluid_alsa.c index 22ec4a74..afb593fb 100644 --- a/src/drivers/fluid_alsa.c +++ b/src/drivers/fluid_alsa.c @@ -151,7 +151,7 @@ static fluid_thread_return_t fluid_alsa_seq_run(void* d); void fluid_alsa_audio_driver_settings(fluid_settings_t* settings) { - fluid_settings_register_str(settings, "audio.alsa.device", "default", 0, NULL, NULL); + fluid_settings_register_str(settings, "audio.alsa.device", "default", 0); } @@ -548,7 +548,7 @@ static fluid_thread_return_t fluid_alsa_audio_run_s16 (void *d) void fluid_alsa_rawmidi_driver_settings(fluid_settings_t* settings) { - fluid_settings_register_str(settings, "midi.alsa.device", "default", 0, NULL, NULL); + fluid_settings_register_str(settings, "midi.alsa.device", "default", 0); } /* @@ -715,8 +715,8 @@ fluid_alsa_midi_run(void* d) void fluid_alsa_seq_driver_settings(fluid_settings_t* settings) { - fluid_settings_register_str(settings, "midi.alsa_seq.device", "default", 0, NULL, NULL); - fluid_settings_register_str(settings, "midi.alsa_seq.id", "pid", 0, NULL, NULL); + fluid_settings_register_str(settings, "midi.alsa_seq.device", "default", 0); + fluid_settings_register_str(settings, "midi.alsa_seq.id", "pid", 0); } diff --git a/src/drivers/fluid_coreaudio.c b/src/drivers/fluid_coreaudio.c index 8c4b7fae..a3a146c3 100644 --- a/src/drivers/fluid_coreaudio.c +++ b/src/drivers/fluid_coreaudio.c @@ -111,7 +111,7 @@ fluid_core_audio_driver_settings(fluid_settings_t* settings) pa.mScope = kAudioObjectPropertyScopeWildcard; pa.mElement = kAudioObjectPropertyElementMaster; - fluid_settings_register_str (settings, "audio.coreaudio.device", "default", 0, NULL, NULL); + fluid_settings_register_str (settings, "audio.coreaudio.device", "default", 0); fluid_settings_add_option (settings, "audio.coreaudio.device", "default"); if (OK (AudioObjectGetPropertyDataSize (kAudioObjectSystemObject, &pa, 0, 0, &size))) { int num = size / (int) sizeof (AudioDeviceID); diff --git a/src/drivers/fluid_coremidi.c b/src/drivers/fluid_coremidi.c index 1bbe6c1e..deac4593 100644 --- a/src/drivers/fluid_coremidi.c +++ b/src/drivers/fluid_coremidi.c @@ -66,7 +66,7 @@ void fluid_coremidi_callback(const MIDIPacketList *list, void *p, void *src); void fluid_coremidi_driver_settings(fluid_settings_t* settings) { - fluid_settings_register_str(settings, "midi.coremidi.id", "pid", 0, NULL, NULL); + fluid_settings_register_str(settings, "midi.coremidi.id", "pid", 0); } /* diff --git a/src/drivers/fluid_dart.c b/src/drivers/fluid_dart.c index 0bd4f11a..1c5df476 100644 --- a/src/drivers/fluid_dart.c +++ b/src/drivers/fluid_dart.c @@ -75,7 +75,7 @@ static LONG APIENTRY fluid_dart_audio_run( ULONG ulStatus, PMCI_MIX_BUFFER pBuff void fluid_dart_audio_driver_settings(fluid_settings_t* settings) { - fluid_settings_register_str(settings, "audio.dart.device", "default", 0, NULL, NULL); + fluid_settings_register_str(settings, "audio.dart.device", "default", 0); } diff --git a/src/drivers/fluid_dsound.c b/src/drivers/fluid_dsound.c index 082eadd7..24635625 100644 --- a/src/drivers/fluid_dsound.c +++ b/src/drivers/fluid_dsound.c @@ -84,7 +84,7 @@ fluid_dsound_enum_callback2(LPGUID guid, LPCTSTR description, LPCTSTR module, LP void fluid_dsound_audio_driver_settings(fluid_settings_t* settings) { - fluid_settings_register_str(settings, "audio.dsound.device", "default", 0, NULL, NULL); + fluid_settings_register_str(settings, "audio.dsound.device", "default", 0); fluid_settings_add_option(settings, "audio.dsound.device", "default"); DirectSoundEnumerate((LPDSENUMCALLBACK) fluid_dsound_enum_callback, settings); } diff --git a/src/drivers/fluid_jack.c b/src/drivers/fluid_jack.c index 7bd79eaa..75fd1d37 100644 --- a/src/drivers/fluid_jack.c +++ b/src/drivers/fluid_jack.c @@ -106,10 +106,10 @@ static fluid_jack_client_t *last_client = NULL; /* Last unpaired client. F void fluid_jack_audio_driver_settings(fluid_settings_t* settings) { - fluid_settings_register_str(settings, "audio.jack.id", "fluidsynth", 0, NULL, NULL); - fluid_settings_register_int(settings, "audio.jack.multi", 0, 0, 1, FLUID_HINT_TOGGLED, NULL, NULL); - fluid_settings_register_int(settings, "audio.jack.autoconnect", 0, 0, 1, FLUID_HINT_TOGGLED, NULL, NULL); - fluid_settings_register_str(settings, "audio.jack.server", "", 0, NULL, NULL); + fluid_settings_register_str(settings, "audio.jack.id", "fluidsynth", 0); + fluid_settings_register_int(settings, "audio.jack.multi", 0, 0, 1, FLUID_HINT_TOGGLED); + fluid_settings_register_int(settings, "audio.jack.autoconnect", 0, 0, 1, FLUID_HINT_TOGGLED); + fluid_settings_register_str(settings, "audio.jack.server", "", 0); } /* @@ -614,8 +614,8 @@ fluid_jack_driver_shutdown(void *arg) void fluid_jack_midi_driver_settings (fluid_settings_t *settings) { - fluid_settings_register_str (settings, "midi.jack.id", "fluidsynth-midi", 0, NULL, NULL); - fluid_settings_register_str (settings, "midi.jack.server", "", 0, NULL, NULL); + fluid_settings_register_str (settings, "midi.jack.id", "fluidsynth-midi", 0); + fluid_settings_register_str (settings, "midi.jack.server", "", 0); } /* diff --git a/src/drivers/fluid_mdriver.c b/src/drivers/fluid_mdriver.c index 53b76346..26e073ce 100644 --- a/src/drivers/fluid_mdriver.c +++ b/src/drivers/fluid_mdriver.c @@ -144,26 +144,26 @@ void fluid_midi_driver_settings(fluid_settings_t* settings) { unsigned int i; - fluid_settings_register_int (settings, "midi.autoconnect", 0, 0, 1, FLUID_HINT_TOGGLED, NULL, NULL); + fluid_settings_register_int (settings, "midi.autoconnect", 0, 0, 1, FLUID_HINT_TOGGLED); fluid_settings_register_int (settings, "midi.realtime-prio", - FLUID_DEFAULT_MIDI_RT_PRIO, 0, 99, 0, NULL, NULL); + FLUID_DEFAULT_MIDI_RT_PRIO, 0, 99, 0); /* Set the default driver */ #if ALSA_SUPPORT - fluid_settings_register_str(settings, "midi.driver", "alsa_seq", 0, NULL, NULL); + fluid_settings_register_str(settings, "midi.driver", "alsa_seq", 0); #elif JACK_SUPPORT - fluid_settings_register_str(settings, "midi.driver", "jack", 0, NULL, NULL); + fluid_settings_register_str(settings, "midi.driver", "jack", 0); #elif OSS_SUPPORT - fluid_settings_register_str(settings, "midi.driver", "oss", 0, NULL, NULL); + fluid_settings_register_str(settings, "midi.driver", "oss", 0); #elif WINMIDI_SUPPORT - fluid_settings_register_str(settings, "midi.driver", "winmidi", 0, NULL, NULL); + fluid_settings_register_str(settings, "midi.driver", "winmidi", 0); #elif MIDISHARE_SUPPORT - fluid_settings_register_str(settings, "midi.driver", "midishare", 0, NULL, NULL); + fluid_settings_register_str(settings, "midi.driver", "midishare", 0); #elif COREMIDI_SUPPORT - fluid_settings_register_str(settings, "midi.driver", "coremidi", 0, NULL, NULL); + fluid_settings_register_str(settings, "midi.driver", "coremidi", 0); #else - fluid_settings_register_str(settings, "midi.driver", "", 0, NULL, NULL); + fluid_settings_register_str(settings, "midi.driver", "", 0); #endif /* Add all drivers to the list of options */ diff --git a/src/drivers/fluid_oss.c b/src/drivers/fluid_oss.c index 8e00f519..0fdad174 100644 --- a/src/drivers/fluid_oss.c +++ b/src/drivers/fluid_oss.c @@ -101,7 +101,7 @@ static fluid_thread_return_t fluid_oss_midi_run(void* d); void fluid_oss_audio_driver_settings(fluid_settings_t* settings) { - fluid_settings_register_str(settings, "audio.oss.device", "/dev/dsp", 0, NULL, NULL); + fluid_settings_register_str(settings, "audio.oss.device", "/dev/dsp", 0); } /* @@ -502,7 +502,7 @@ fluid_oss_audio_run2(void* d) void fluid_oss_midi_driver_settings(fluid_settings_t* settings) { - fluid_settings_register_str(settings, "midi.oss.device", "/dev/midi", 0, NULL, NULL); + fluid_settings_register_str(settings, "midi.oss.device", "/dev/midi", 0); } /* diff --git a/src/drivers/fluid_portaudio.c b/src/drivers/fluid_portaudio.c index 043a2335..62385627 100644 --- a/src/drivers/fluid_portaudio.c +++ b/src/drivers/fluid_portaudio.c @@ -122,7 +122,7 @@ fluid_portaudio_driver_settings (fluid_settings_t *settings) PaError err; int i; - fluid_settings_register_str (settings, "audio.portaudio.device", PORTAUDIO_DEFAULT_DEVICE, 0, NULL, NULL); + fluid_settings_register_str (settings, "audio.portaudio.device", PORTAUDIO_DEFAULT_DEVICE, 0); fluid_settings_add_option (settings, "audio.portaudio.device", PORTAUDIO_DEFAULT_DEVICE); err = Pa_Initialize(); diff --git a/src/drivers/fluid_pulse.c b/src/drivers/fluid_pulse.c index 08e75ffc..2cdd0219 100644 --- a/src/drivers/fluid_pulse.c +++ b/src/drivers/fluid_pulse.c @@ -63,11 +63,11 @@ static fluid_thread_return_t fluid_pulse_audio_run2(void* d); void fluid_pulse_audio_driver_settings(fluid_settings_t* settings) { - fluid_settings_register_str(settings, "audio.pulseaudio.server", "default", 0, NULL, NULL); - fluid_settings_register_str(settings, "audio.pulseaudio.device", "default", 0, NULL, NULL); - fluid_settings_register_str(settings, "audio.pulseaudio.media-role", "music", 0, NULL, NULL); + fluid_settings_register_str(settings, "audio.pulseaudio.server", "default", 0); + fluid_settings_register_str(settings, "audio.pulseaudio.device", "default", 0); + fluid_settings_register_str(settings, "audio.pulseaudio.media-role", "music", 0); fluid_settings_register_int(settings, "audio.pulseaudio.adjust-latency", 1, 0, 1, - FLUID_HINT_TOGGLED, NULL, NULL); + FLUID_HINT_TOGGLED); } diff --git a/src/drivers/fluid_winmidi.c b/src/drivers/fluid_winmidi.c index b6503eaf..fc2021a1 100644 --- a/src/drivers/fluid_winmidi.c +++ b/src/drivers/fluid_winmidi.c @@ -86,7 +86,7 @@ void fluid_winmidi_midi_driver_settings(fluid_settings_t* settings) MMRESULT res; MIDIINCAPS in_caps; UINT i, num; - fluid_settings_register_str(settings, "midi.winmidi.device", "default", 0, NULL, NULL); + fluid_settings_register_str(settings, "midi.winmidi.device", "default", 0); num = midiInGetNumDevs(); if (num > 0) { fluid_settings_add_option(settings, "midi.winmidi.device", "default"); diff --git a/src/midi/fluid_midi.c b/src/midi/fluid_midi.c index f73e44a2..eb84ded8 100644 --- a/src/midi/fluid_midi.c +++ b/src/midi/fluid_midi.c @@ -1293,14 +1293,12 @@ fluid_player_settings(fluid_settings_t *settings) { /* player.timing-source can be either "system" (use system timer) or "sample" (use timer based on number of written samples) */ - fluid_settings_register_str(settings, "player.timing-source", "sample", 0, - NULL, NULL); + fluid_settings_register_str(settings, "player.timing-source", "sample", 0); fluid_settings_add_option(settings, "player.timing-source", "sample"); fluid_settings_add_option(settings, "player.timing-source", "system"); /* Selects whether the player should reset the synth between songs, or not. */ - fluid_settings_register_int(settings, "player.reset-synth", 1, 0, 1, - FLUID_HINT_TOGGLED, NULL, NULL); + fluid_settings_register_int(settings, "player.reset-synth", 1, 0, 1, FLUID_HINT_TOGGLED); } diff --git a/src/synth/fluid_synth.c b/src/synth/fluid_synth.c index dbca05d6..dbe7e6bc 100644 --- a/src/synth/fluid_synth.c +++ b/src/synth/fluid_synth.c @@ -155,77 +155,47 @@ static const fluid_revmodel_presets_t revmodel_preset[] = { * INITIALIZATION & UTILITIES */ -static void fluid_synth_register_overflow(fluid_settings_t* settings, - fluid_num_update_t update_func, - void* update_data) -{ - fluid_settings_register_num(settings, "synth.overflow.percussion", - 4000, -10000, 10000, 0, update_func, update_data); - fluid_settings_register_num(settings, "synth.overflow.sustained", - -1000, -10000, 10000, 0, update_func, update_data); - fluid_settings_register_num(settings, "synth.overflow.released", - -2000, -10000, 10000, 0, update_func, update_data); - fluid_settings_register_num(settings, "synth.overflow.age", - 1000, -10000, 10000, 0, update_func, update_data); - fluid_settings_register_num(settings, "synth.overflow.volume", - 500, -10000, 10000, 0, update_func, update_data); -} - void fluid_synth_settings(fluid_settings_t* settings) { - fluid_settings_register_int(settings, "synth.verbose", 0, 0, 1, - FLUID_HINT_TOGGLED, NULL, NULL); - fluid_settings_register_int(settings, "synth.reverb.active", 1, 0, 1, - FLUID_HINT_TOGGLED, NULL, NULL); - fluid_settings_register_int(settings, "synth.chorus.active", 1, 0, 1, - FLUID_HINT_TOGGLED, NULL, NULL); - fluid_settings_register_int(settings, "synth.ladspa.active", 0, 0, 1, - FLUID_HINT_TOGGLED, NULL, NULL); - fluid_settings_register_int(settings, "synth.lock-memory", 1, 0, 1, - FLUID_HINT_TOGGLED, NULL, NULL); - fluid_settings_register_str(settings, "midi.portname", "", 0, NULL, NULL); + fluid_settings_register_int(settings, "synth.verbose", 0, 0, 1, FLUID_HINT_TOGGLED); + fluid_settings_register_int(settings, "synth.reverb.active", 1, 0, 1, FLUID_HINT_TOGGLED); + fluid_settings_register_int(settings, "synth.chorus.active", 1, 0, 1, FLUID_HINT_TOGGLED); + fluid_settings_register_int(settings, "synth.ladspa.active", 0, 0, 1, FLUID_HINT_TOGGLED); + fluid_settings_register_int(settings, "synth.lock-memory", 1, 0, 1, FLUID_HINT_TOGGLED); + fluid_settings_register_str(settings, "midi.portname", "", 0); #ifdef DEFAULT_SOUNDFONT - fluid_settings_register_str(settings, "synth.default-soundfont", - DEFAULT_SOUNDFONT, 0, NULL, NULL); + fluid_settings_register_str(settings, "synth.default-soundfont", DEFAULT_SOUNDFONT, 0); #endif - fluid_settings_register_int(settings, "synth.polyphony", - 256, 1, 65535, 0, NULL, NULL); - fluid_settings_register_int(settings, "synth.midi-channels", - 16, 16, 256, 0, NULL, NULL); - fluid_settings_register_num(settings, "synth.gain", - 0.2f, 0.0f, 10.0f, - 0, NULL, NULL); - fluid_settings_register_int(settings, "synth.audio-channels", - 1, 1, 128, 0, NULL, NULL); - fluid_settings_register_int(settings, "synth.audio-groups", - 1, 1, 128, 0, NULL, NULL); - fluid_settings_register_int(settings, "synth.effects-channels", - 2, 2, 2, 0, NULL, NULL); - fluid_settings_register_num(settings, "synth.sample-rate", - 44100.0f, 8000.0f, 96000.0f, - 0, NULL, NULL); - fluid_settings_register_int(settings, "synth.device-id", - 0, 0, 126, 0, NULL, NULL); - fluid_settings_register_int(settings, "synth.cpu-cores", 1, 1, 256, 0, NULL, NULL); + fluid_settings_register_int(settings, "synth.polyphony", 256, 1, 65535, 0); + fluid_settings_register_int(settings, "synth.midi-channels", 16, 16, 256, 0); + fluid_settings_register_num(settings, "synth.gain", 0.2f, 0.0f, 10.0f, 0); + fluid_settings_register_int(settings, "synth.audio-channels", 1, 1, 128, 0); + fluid_settings_register_int(settings, "synth.audio-groups", 1, 1, 128, 0); + fluid_settings_register_int(settings, "synth.effects-channels", 2, 2, 2, 0); + fluid_settings_register_num(settings, "synth.sample-rate", 44100.0f, 8000.0f, 96000.0f, 0); + fluid_settings_register_int(settings, "synth.device-id", 0, 0, 126, 0); + fluid_settings_register_int(settings, "synth.cpu-cores", 1, 1, 256, 0); - fluid_settings_register_int(settings, "synth.min-note-length", 10, 0, 65535, 0, NULL, NULL); + fluid_settings_register_int(settings, "synth.min-note-length", 10, 0, 65535, 0); - fluid_settings_register_int(settings, "synth.threadsafe-api", 1, 0, 1, - FLUID_HINT_TOGGLED, NULL, NULL); - fluid_settings_register_int(settings, "synth.parallel-render", 1, 0, 1, - FLUID_HINT_TOGGLED, NULL, NULL); + fluid_settings_register_int(settings, "synth.threadsafe-api", 1, 0, 1, FLUID_HINT_TOGGLED); + fluid_settings_register_int(settings, "synth.parallel-render", 1, 0, 1, FLUID_HINT_TOGGLED); - fluid_synth_register_overflow(settings, NULL, NULL); + fluid_settings_register_num(settings, "synth.overflow.percussion", 4000, -10000, 10000, 0); + fluid_settings_register_num(settings, "synth.overflow.sustained", -1000, -10000, 10000, 0); + fluid_settings_register_num(settings, "synth.overflow.released", -2000, -10000, 10000, 0); + fluid_settings_register_num(settings, "synth.overflow.age", 1000, -10000, 10000, 0); + fluid_settings_register_num(settings, "synth.overflow.volume", 500, -10000, 10000, 0); - fluid_settings_register_str(settings, "synth.midi-bank-select", "gs", 0, NULL, NULL); + fluid_settings_register_str(settings, "synth.midi-bank-select", "gs", 0); fluid_settings_add_option(settings, "synth.midi-bank-select", "gm"); fluid_settings_add_option(settings, "synth.midi-bank-select", "gs"); fluid_settings_add_option(settings, "synth.midi-bank-select", "xg"); fluid_settings_add_option(settings, "synth.midi-bank-select", "mma"); - fluid_settings_register_str(settings, "synth.volenv", "emu", 0, NULL, NULL); + fluid_settings_register_str(settings, "synth.volenv", "emu", 0); fluid_settings_add_option(settings, "synth.volenv", "emu"); fluid_settings_add_option(settings, "synth.volenv", "compliant"); } @@ -620,10 +590,17 @@ new_fluid_synth(fluid_settings_t *settings) (fluid_int_update_t) fluid_synth_update_polyphony, synth); fluid_settings_callback_int(settings, "synth.device-id", (fluid_int_update_t) fluid_synth_update_device_id, synth); + fluid_settings_callback_num(settings, "synth.overflow.percussion", + (fluid_num_update_t) fluid_synth_update_overflow, synth); + fluid_settings_callback_num(settings, "synth.overflow.sustained", + (fluid_num_update_t) fluid_synth_update_overflow, synth); + fluid_settings_callback_num(settings, "synth.overflow.released", + (fluid_num_update_t) fluid_synth_update_overflow, synth); + fluid_settings_callback_num(settings, "synth.overflow.age", + (fluid_num_update_t) fluid_synth_update_overflow, synth); + fluid_settings_callback_num(settings, "synth.overflow.volume", + (fluid_num_update_t) fluid_synth_update_overflow, synth); - fluid_synth_register_overflow(settings, - (fluid_num_update_t) fluid_synth_update_overflow, synth); - /* do some basic sanity checking on the settings */ if (synth->midi_channels % 16 != 0) { diff --git a/src/utils/fluid_settings.c b/src/utils/fluid_settings.c index d77a33af..df4866d1 100644 --- a/src/utils/fluid_settings.c +++ b/src/utils/fluid_settings.c @@ -87,7 +87,7 @@ typedef struct { } fluid_setting_node_t; static fluid_setting_node_t* -new_fluid_str_setting(const char* value, const char* def, int hints, fluid_str_update_t fun, void* data) +new_fluid_str_setting(const char* value, const char* def, int hints) { fluid_setting_node_t* node; fluid_str_setting_t* str; @@ -101,14 +101,14 @@ new_fluid_str_setting(const char* value, const char* def, int hints, fluid_str_u } node->type = FLUID_STR_TYPE; + str = &node->str; - str->value = value? FLUID_STRDUP(value) : NULL; str->def = def? FLUID_STRDUP(def) : NULL; str->hints = hints; str->options = NULL; - str->update = fun; - str->data = data; + str->update = NULL; + str->data = NULL; return node; } @@ -138,8 +138,7 @@ delete_fluid_str_setting(fluid_setting_node_t* node) static fluid_setting_node_t* -new_fluid_num_setting(double min, double max, double def, - int hints, fluid_num_update_t fun, void* data) +new_fluid_num_setting(double min, double max, double def, int hints) { fluid_setting_node_t* node; fluid_num_setting_t* num; @@ -153,15 +152,15 @@ new_fluid_num_setting(double min, double max, double def, } node->type = FLUID_NUM_TYPE; + num = &node->num; - num->value = def; num->def = def; num->min = min; num->max = max; num->hints = hints; - num->update = fun; - num->data = data; + num->update = NULL; + num->data = NULL; return node; } @@ -176,8 +175,7 @@ delete_fluid_num_setting(fluid_setting_node_t* node) } static fluid_setting_node_t* -new_fluid_int_setting(int min, int max, int def, - int hints, fluid_int_update_t fun, void* data) +new_fluid_int_setting(int min, int max, int def, int hints) { fluid_setting_node_t* node; fluid_int_setting_t* i; @@ -191,15 +189,15 @@ new_fluid_int_setting(int min, int max, int def, } node->type = FLUID_INT_TYPE; + i = &node->i; - i->value = def; i->def = def; i->min = min; i->max = max; i->hints = hints; - i->update = fun; - i->data = data; + i->update = NULL; + i->data = NULL; return node; } @@ -471,13 +469,10 @@ fluid_settings_set(fluid_settings_t* settings, const char *name, fluid_setting_n * @param name the setting's name * @param def the default value for the setting * @param hints the hints for the setting - * @param fun an update function for the setting - * @param data user supplied data * @return #FLUID_OK if the value has been register correctly, #FLUID_FAILED otherwise */ int -fluid_settings_register_str(fluid_settings_t* settings, const char* name, const char* def, int hints, - fluid_str_update_t fun, void* data) +fluid_settings_register_str(fluid_settings_t* settings, const char* name, const char* def, int hints) { fluid_setting_node_t *node; int retval = FLUID_FAILED; @@ -489,15 +484,13 @@ fluid_settings_register_str(fluid_settings_t* settings, const char* name, const fluid_rec_mutex_lock (settings->mutex); if (fluid_settings_get(settings, name, &node) != FLUID_OK) { - node = new_fluid_str_setting(def, def, hints, fun, data); + node = new_fluid_str_setting(def, def, hints); retval = fluid_settings_set(settings, name, node); if (retval != FLUID_OK) delete_fluid_str_setting (node); } else { /* if variable already exists, don't change its value. */ if (node->type == FLUID_STR_TYPE) { fluid_str_setting_t* setting = &node->str; - setting->update = fun; - setting->data = data; setting->def = def? FLUID_STRDUP(def) : NULL; setting->hints = hints; retval = FLUID_OK; @@ -520,14 +513,11 @@ fluid_settings_register_str(fluid_settings_t* settings, const char* name, const * @param min the smallest allowed value for the setting * @param max the largest allowed value for the setting * @param hints the hints for the setting - * @param fun an update function for the setting - * @param data user supplied data * @return #FLUID_OK if the value has been register correctly, #FLUID_FAILED otherwise */ int fluid_settings_register_num(fluid_settings_t* settings, const char* name, double def, - double min, double max, int hints, - fluid_num_update_t fun, void* data) + double min, double max, int hints) { fluid_setting_node_t *node; int retval = FLUID_FAILED; @@ -543,15 +533,13 @@ fluid_settings_register_num(fluid_settings_t* settings, const char* name, double if (fluid_settings_get(settings, name, &node) != FLUID_OK) { /* insert a new setting */ - node = new_fluid_num_setting(min, max, def, hints, fun, data); + node = new_fluid_num_setting(min, max, def, hints); retval = fluid_settings_set(settings, name, node); if (retval != FLUID_OK) delete_fluid_num_setting (node); } else { if (node->type == FLUID_NUM_TYPE) { /* update the existing setting but don't change its value */ fluid_num_setting_t* setting = &node->num; - setting->update = fun; - setting->data = data; setting->min = min; setting->max = max; setting->def = def; @@ -577,14 +565,11 @@ fluid_settings_register_num(fluid_settings_t* settings, const char* name, double * @param min the smallest allowed value for the setting * @param max the largest allowed value for the setting * @param hints the hints for the setting - * @param fun an update function for the setting - * @param data user supplied data * @return #FLUID_OK if the value has been register correctly, #FLUID_FAILED otherwise */ int fluid_settings_register_int(fluid_settings_t* settings, const char* name, int def, - int min, int max, int hints, - fluid_int_update_t fun, void* data) + int min, int max, int hints) { fluid_setting_node_t *node; int retval = FLUID_FAILED; @@ -600,15 +585,13 @@ fluid_settings_register_int(fluid_settings_t* settings, const char* name, int de if (fluid_settings_get(settings, name, &node) != FLUID_OK) { /* insert a new setting */ - node = new_fluid_int_setting(min, max, def, hints, fun, data); + node = new_fluid_int_setting(min, max, def, hints); retval = fluid_settings_set(settings, name, node); if (retval != FLUID_OK) delete_fluid_int_setting (node); } else { if (node->type == FLUID_INT_TYPE) { /* update the existing setting but don't change its value */ fluid_int_setting_t* setting = &node->i; - setting->update = fun; - setting->data = data; setting->min = min; setting->max = max; setting->def = def; @@ -890,7 +873,7 @@ fluid_settings_setstr(fluid_settings_t* settings, const char *name, const char * } } else { /* insert a new setting */ - node = new_fluid_str_setting(str, NULL, 0, NULL, NULL); + node = new_fluid_str_setting(str, NULL, 0); retval = fluid_settings_set(settings, name, node); if (retval != FLUID_OK) delete_fluid_str_setting (node); } @@ -1221,7 +1204,7 @@ fluid_settings_setnum(fluid_settings_t* settings, const char *name, double val) } } else { /* insert a new setting */ - node = new_fluid_num_setting(-1e10, 1e10, 0.0f, 0, NULL, NULL); + node = new_fluid_num_setting(-1e10, 1e10, 0.0f, 0); node->num.value = val; retval = fluid_settings_set(settings, name, node); if (retval != FLUID_OK) delete_fluid_num_setting (node); @@ -1373,7 +1356,7 @@ fluid_settings_setint(fluid_settings_t* settings, const char *name, int val) } } else { /* insert a new setting */ - node = new_fluid_int_setting(INT_MIN, INT_MAX, 0, 0, NULL, NULL); + node = new_fluid_int_setting(INT_MIN, INT_MAX, 0, 0); node->i.value = val; retval = fluid_settings_set(settings, name, node); if (retval != FLUID_OK) delete_fluid_int_setting (node); diff --git a/src/utils/fluid_settings.h b/src/utils/fluid_settings.h index 7a935bac..8264b89d 100644 --- a/src/utils/fluid_settings.h +++ b/src/utils/fluid_settings.h @@ -28,8 +28,7 @@ int fluid_settings_remove_option(fluid_settings_t* settings, const char* name, c typedef int (*fluid_str_update_t)(void* data, const char* name, const char* value); -int fluid_settings_register_str(fluid_settings_t* settings, const char* name, const char* def, int hints, - fluid_str_update_t fun, void* data); +int fluid_settings_register_str(fluid_settings_t* settings, const char* name, const char* def, int hints); int fluid_settings_callback_str(fluid_settings_t* settings, const char* name, fluid_str_update_t fun, void* data); @@ -37,16 +36,14 @@ int fluid_settings_callback_str(fluid_settings_t* settings, const char* name, typedef int (*fluid_num_update_t)(void* data, const char* name, double value); int fluid_settings_register_num(fluid_settings_t* settings, const char* name, double def, - double min, double max, int hints, - fluid_num_update_t fun, void* data); + double min, double max, int hints); int fluid_settings_callback_num(fluid_settings_t* settings, const char* name, fluid_num_update_t fun, void* data); typedef int (*fluid_int_update_t)(void* data, const char* name, int value); int fluid_settings_register_int(fluid_settings_t* settings, const char* name, int def, - int min, int max, int hints, - fluid_int_update_t fun, void* data); + int min, int max, int hints); int fluid_settings_callback_int(fluid_settings_t* settings, const char* name, fluid_int_update_t fun, void* data);