mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2025-02-26 13:50:50 +00:00
Converted all yes/no string boolean parameters to FLUID_HINT_TOGGLED integers.
Added FLUID_HINT_FILENAME to audio.file.name setting. Added backwards compatibility for yes/no string booleans to fluid_settings_setstr, fluid_settings_copystr, fluid_settings_dupstr, fluid_settings_getstr, fluid_settings_str_equal and fluid_settings_getstr_default. Added support for integer type to fluid_settings_get_hints and fluid_settings_is_realtime. fluid_settings_add_option now automatically enables FLUID_HINT_OPTIONLIST. Replaced fluid_settings_foreach_option() with fluid_settings_foreach_option_alpha(). Replaced fluid_settings_foreach() with fluid_settings_foreach_alpha(). Added backwards compatibility to fluidsynth -o switch for yes/no booleans and improved error handling. Added support for boolean strings to 'set' shell command and improved type handling and errors. Added boolean support to 'settings' and 'info' commands. Added boolean type output to -o help. Welcome message is now always displayed in fluidsynth. Changed 'help' command to list topics (help help), instead of general help. Marked FLUID_HINT_INTEGER as deprecated (since there is a FLUID_INT_TYPE).
This commit is contained in:
parent
f3b62ad39a
commit
93ddc1fc5f
14 changed files with 324 additions and 289 deletions
|
@ -98,15 +98,15 @@ extern "C" {
|
|||
/**
|
||||
* Hint FLUID_HINT_INTEGER indicates that a user interface would
|
||||
* probably wish to provide a stepped control taking only integer
|
||||
* values. Any bounds set should be slightly wider than the actual
|
||||
* integer range required to avoid floating point rounding errors. For
|
||||
* instance, the integer set {0,1,2,3} might be described as [-0.1,
|
||||
* 3.1].
|
||||
* values.
|
||||
* @deprecated
|
||||
*
|
||||
* As there is an integer setting type, this hint is not used.
|
||||
*/
|
||||
#define FLUID_HINT_INTEGER 0x20
|
||||
|
||||
|
||||
#define FLUID_HINT_FILENAME 0x01 /**< Setting is a file name */
|
||||
#define FLUID_HINT_FILENAME 0x01 /**< String setting is a file name */
|
||||
#define FLUID_HINT_OPTIONLIST 0x02 /**< Setting is a list of string options */
|
||||
|
||||
|
||||
|
@ -195,10 +195,6 @@ void fluid_settings_foreach_option(fluid_settings_t* settings,
|
|||
char* name, void* data,
|
||||
fluid_settings_foreach_option_t func);
|
||||
FLUIDSYNTH_API
|
||||
void fluid_settings_foreach_option_alpha (fluid_settings_t* settings,
|
||||
char* name, void* data,
|
||||
fluid_settings_foreach_option_t func);
|
||||
FLUIDSYNTH_API
|
||||
int fluid_settings_option_count (fluid_settings_t* settings, char* name);
|
||||
|
||||
/**
|
||||
|
@ -212,9 +208,6 @@ typedef void (*fluid_settings_foreach_t)(void* data, char* name, int type);
|
|||
FLUIDSYNTH_API
|
||||
void fluid_settings_foreach(fluid_settings_t* settings, void* data,
|
||||
fluid_settings_foreach_t func);
|
||||
FLUIDSYNTH_API
|
||||
void fluid_settings_foreach_alpha(fluid_settings_t* settings, void* data,
|
||||
fluid_settings_foreach_t func);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -221,9 +221,7 @@ void fluid_audio_driver_settings(fluid_settings_t* settings)
|
|||
fluid_settings_register_int(settings, "audio.periods", 16, 2, 64, 0, NULL, NULL);
|
||||
#endif
|
||||
|
||||
fluid_settings_register_str (settings, "audio.realtime", "yes", 0, NULL, NULL);
|
||||
fluid_settings_add_option (settings, "audio.realtime", "yes");
|
||||
fluid_settings_add_option (settings, "audio.realtime", "no");
|
||||
fluid_settings_register_int (settings, "audio.realtime", 1, 0, 1, FLUID_HINT_TOGGLED, NULL, NULL);
|
||||
fluid_settings_register_int (settings, "audio.realtime-prio",
|
||||
FLUID_DEFAULT_AUDIO_RT_PRIO, 1, 99, 0, NULL, NULL);
|
||||
|
||||
|
|
|
@ -191,7 +191,8 @@ new_fluid_alsa_audio_driver2(fluid_settings_t* settings,
|
|||
fluid_settings_dupstr(settings, "audio.alsa.device", &device); /* ++ dup device name */
|
||||
fluid_settings_getint (settings, "audio.realtime-prio", &realtime_prio);
|
||||
|
||||
if (fluid_settings_str_equal (settings, "audio.realtime", "yes"))
|
||||
fluid_settings_getint (settings, "audio.realtime", &sched);
|
||||
if (sched)
|
||||
sched = SCHED_FIFO;
|
||||
else sched = SCHED_OTHER;
|
||||
|
||||
|
@ -289,8 +290,6 @@ new_fluid_alsa_audio_driver2(fluid_settings_t* settings,
|
|||
goto error_recovery;
|
||||
}
|
||||
|
||||
FLUID_LOG(FLUID_INFO, "ALSA driver: Using format %s", fluid_alsa_formats[i].name);
|
||||
|
||||
/* Set the software params */
|
||||
snd_pcm_sw_params_current(dev->pcm, swparams);
|
||||
|
||||
|
@ -653,7 +652,8 @@ new_fluid_alsa_rawmidi_driver(fluid_settings_t* settings,
|
|||
|
||||
fluid_settings_getint (settings, "midi.realtime-prio", &realtime_prio);
|
||||
|
||||
if (fluid_settings_str_equal (settings, "midi.realtime", "yes"))
|
||||
fluid_settings_getint (settings, "midi.realtime", &sched);
|
||||
if (sched)
|
||||
sched = SCHED_FIFO;
|
||||
else sched = SCHED_OTHER;
|
||||
|
||||
|
@ -923,7 +923,8 @@ new_fluid_alsa_seq_driver(fluid_settings_t* settings,
|
|||
|
||||
fluid_settings_getint (settings, "midi.realtime-prio", &realtime_prio);
|
||||
|
||||
if (fluid_settings_str_equal (settings, "midi.realtime", "yes"))
|
||||
fluid_settings_getint (settings, "midi.realtime", &sched);
|
||||
if (sched)
|
||||
sched = SCHED_FIFO;
|
||||
else sched = SCHED_OTHER;
|
||||
|
||||
|
|
|
@ -1229,19 +1229,43 @@ fluid_handle_dumptuning(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t
|
|||
int
|
||||
fluid_handle_set(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out)
|
||||
{
|
||||
int hints;
|
||||
int ival;
|
||||
|
||||
if (ac < 2) {
|
||||
fluid_ostream_printf(out, "set: too few arguments.\n");
|
||||
fluid_ostream_printf(out, "set: Too few arguments.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (fluid_is_number(av[1])) {
|
||||
if (FLUID_STRCHR(av[1], '.') != NULL) {
|
||||
fluid_synth_setnum(synth, av[0], atof(av[1]));
|
||||
} else {
|
||||
fluid_synth_setint(synth, av[0], atoi(av[1]));
|
||||
}
|
||||
} else {
|
||||
fluid_synth_setstr(synth, av[0], av[1]);
|
||||
switch (fluid_settings_get_type (synth->settings, av[0]))
|
||||
{
|
||||
case FLUID_NO_TYPE:
|
||||
fluid_ostream_printf (out, "set: Parameter '%s' not found.\n", av[0]);
|
||||
break;
|
||||
case FLUID_INT_TYPE:
|
||||
hints = fluid_settings_get_hints (synth->settings, av[0]);
|
||||
|
||||
if (hints & FLUID_HINT_TOGGLED)
|
||||
{
|
||||
if (FLUID_STRCMP (av[1], "yes") == 0 || FLUID_STRCMP (av[1], "True") == 0
|
||||
|| FLUID_STRCMP (av[1], "TRUE") == 0 || FLUID_STRCMP (av[1], "true") == 0
|
||||
|| FLUID_STRCMP (av[1], "T") == 0)
|
||||
ival = 1;
|
||||
else ival = atoi (av[1]);
|
||||
}
|
||||
else ival = atoi (av[1]);
|
||||
|
||||
fluid_synth_setint (synth, av[0], ival);
|
||||
break;
|
||||
case FLUID_NUM_TYPE:
|
||||
fluid_synth_setnum (synth, av[0], atof (av[1]));
|
||||
break;
|
||||
case FLUID_STR_TYPE:
|
||||
fluid_synth_setstr(synth, av[0], av[1]);
|
||||
break;
|
||||
case FLUID_SET_TYPE:
|
||||
fluid_ostream_printf (out, "set: Parameter '%s' is a node.\n", av[0]);
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -1326,9 +1350,13 @@ static void fluid_handle_settings_iter2(void* data, char* name, int type)
|
|||
}
|
||||
|
||||
case FLUID_INT_TYPE: {
|
||||
int value;
|
||||
int value, hints;
|
||||
fluid_synth_getint(d->synth, name, &value);
|
||||
fluid_ostream_printf(d->out, "%d\n", value);
|
||||
hints = fluid_settings_get_hints (d->synth->settings, name);
|
||||
|
||||
if (!(hints & FLUID_HINT_TOGGLED))
|
||||
fluid_ostream_printf(d->out, "%d\n", value);
|
||||
else fluid_ostream_printf(d->out, "%s\n", value ? "True" : "False");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1352,7 +1380,7 @@ fluid_handle_settings(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t o
|
|||
data.out = out;
|
||||
|
||||
fluid_settings_foreach(fluid_synth_get_settings(synth), &data, fluid_handle_settings_iter1);
|
||||
fluid_settings_foreach_alpha(fluid_synth_get_settings(synth), &data, fluid_handle_settings_iter2);
|
||||
fluid_settings_foreach(fluid_synth_get_settings(synth), &data, fluid_handle_settings_iter2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1407,16 +1435,30 @@ fluid_handle_info(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out)
|
|||
}
|
||||
|
||||
case FLUID_INT_TYPE: {
|
||||
int value, min, max;
|
||||
int value, min, max, def, hints;
|
||||
|
||||
fluid_settings_getint_range(settings, av[0], &min, &max);
|
||||
fluid_settings_getint(settings, av[0], &value);
|
||||
hints = fluid_settings_get_hints(settings, av[0]);
|
||||
def = fluid_settings_getint_default (settings, av[0]);
|
||||
|
||||
fluid_ostream_printf(out, "%s:\n", av[0]);
|
||||
fluid_ostream_printf(out, "Type: integer\n");
|
||||
fluid_ostream_printf(out, "Value: %d\n", value);
|
||||
fluid_ostream_printf(out, "Minimum value: %d\n", min);
|
||||
fluid_ostream_printf(out, "Maximum value: %d\n", max);
|
||||
fluid_ostream_printf(out, "Default value: %d\n",
|
||||
fluid_settings_getint_default(settings, av[0]));
|
||||
|
||||
if (!(hints & FLUID_HINT_TOGGLED))
|
||||
{
|
||||
fluid_ostream_printf(out, "Type: integer\n");
|
||||
fluid_ostream_printf(out, "Value: %d\n", value);
|
||||
fluid_ostream_printf(out, "Minimum value: %d\n", min);
|
||||
fluid_ostream_printf(out, "Maximum value: %d\n", max);
|
||||
fluid_ostream_printf(out, "Default value: %d\n", def);
|
||||
}
|
||||
else
|
||||
{
|
||||
fluid_ostream_printf(out, "Type: boolean\n");
|
||||
fluid_ostream_printf(out, "Value: %s\n", value ? "True" : "False");
|
||||
fluid_ostream_printf(out, "Default value: %s\n", def ? "True" : "False");
|
||||
}
|
||||
|
||||
fluid_ostream_printf(out, "Real-time: %s\n",
|
||||
fluid_settings_is_realtime(settings, av[0])? "yes" : "no");
|
||||
break;
|
||||
|
@ -1436,7 +1478,7 @@ fluid_handle_info(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out)
|
|||
data.out = out;
|
||||
data.first = 1;
|
||||
fluid_ostream_printf(out, "Options: ");
|
||||
fluid_settings_foreach_option_alpha (settings, av[0], &data, fluid_handle_print_option);
|
||||
fluid_settings_foreach_option (settings, av[0], &data, fluid_handle_print_option);
|
||||
fluid_ostream_printf(out, "\n");
|
||||
|
||||
fluid_ostream_printf(out, "Real-time: %s\n",
|
||||
|
@ -1445,7 +1487,8 @@ fluid_handle_info(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out)
|
|||
}
|
||||
|
||||
case FLUID_SET_TYPE:
|
||||
fluid_ostream_printf(out, "%s is a node", av[0]);
|
||||
fluid_ostream_printf(out, "%s:\n", av[0]);
|
||||
fluid_ostream_printf(out, "Type: node\n");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1478,7 +1521,7 @@ fluid_handle_help(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out)
|
|||
* - help help
|
||||
*/
|
||||
|
||||
char* topic = "general"; /* default, if no topic is given */
|
||||
char* topic = "help"; /* default, if no topic is given */
|
||||
int count = 0;
|
||||
int i;
|
||||
|
||||
|
|
|
@ -136,7 +136,8 @@ fluid_file_renderer_settings (fluid_settings_t* settings)
|
|||
int i, i2;
|
||||
const char **np;
|
||||
|
||||
fluid_settings_register_str(settings, "audio.file.name", "fluidsynth.wav", 0, NULL, NULL);
|
||||
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);
|
||||
|
|
|
@ -89,9 +89,7 @@ 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_str(settings, "audio.jack.multi", "no", 0, NULL, NULL);
|
||||
fluid_settings_add_option(settings, "audio.jack.multi", "no");
|
||||
fluid_settings_add_option(settings, "audio.jack.multi", "yes");
|
||||
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);
|
||||
}
|
||||
|
@ -177,7 +175,9 @@ new_fluid_jack_audio_driver2(fluid_settings_t* settings, fluid_audio_func_t func
|
|||
" (synth.sample-rate=%lu, jackd=%lu)", (int)sample_rate, jack_srate);
|
||||
}
|
||||
|
||||
if (!fluid_settings_str_equal(settings, "audio.jack.multi", "yes")) {
|
||||
fluid_settings_getint (settings, "audio.jack.multi", &i);
|
||||
|
||||
if (i) {
|
||||
|
||||
/* create the two audio output ports */
|
||||
dev->num_output_ports = 1;
|
||||
|
|
|
@ -145,9 +145,8 @@ void fluid_midi_driver_settings(fluid_settings_t* settings)
|
|||
{
|
||||
int i;
|
||||
|
||||
fluid_settings_register_str (settings, "midi.realtime", "yes", 0, NULL, NULL);
|
||||
fluid_settings_add_option (settings, "midi.realtime", "yes");
|
||||
fluid_settings_add_option (settings, "midi.realtime", "no");
|
||||
fluid_settings_register_int (settings, "midi.realtime", 1, 0, 1,
|
||||
FLUID_HINT_TOGGLED, NULL, NULL);
|
||||
fluid_settings_register_int (settings, "midi.realtime-prio",
|
||||
FLUID_DEFAULT_MIDI_RT_PRIO, 1, 99, 0, NULL, NULL);
|
||||
|
||||
|
|
|
@ -1123,8 +1123,9 @@ fluid_player_t* new_fluid_player(fluid_synth_t* synth)
|
|||
|
||||
player->use_system_timer =
|
||||
fluid_settings_str_equal(synth->settings, "player.timing-source", "system");
|
||||
player->reset_synth_between_songs =
|
||||
fluid_settings_str_equal(synth->settings, "player.reset-synth", "yes");
|
||||
|
||||
fluid_settings_getint (synth->settings, "player.reset-synth", &i);
|
||||
player->reset_synth_between_songs = i;
|
||||
|
||||
return player;
|
||||
}
|
||||
|
@ -1163,11 +1164,12 @@ void 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);
|
||||
/* Selects whether the player should reset the synth between
|
||||
songs, or not. */
|
||||
fluid_settings_register_str(settings, "player.reset-synth", "yes", 0, NULL, NULL);
|
||||
fluid_settings_add_option(settings, "player.reset-synth", "no");
|
||||
fluid_settings_add_option(settings, "player.reset-synth", "yes");
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -133,7 +133,8 @@ new_fluid_oss_audio_driver(fluid_settings_t* settings, fluid_synth_t* synth)
|
|||
fluid_settings_getnum(settings, "synth.sample-rate", &sample_rate);
|
||||
fluid_settings_getint (settings, "audio.realtime-prio", &realtime_prio);
|
||||
|
||||
if (fluid_settings_str_equal (settings, "audio.realtime", "yes"))
|
||||
fluid_settings_getint (settings, "audio.realtime", &sched);
|
||||
if (sched)
|
||||
sched = SCHED_FIFO;
|
||||
else sched = SCHED_OTHER;
|
||||
|
||||
|
@ -310,7 +311,8 @@ new_fluid_oss_audio_driver2(fluid_settings_t* settings, fluid_audio_func_t func,
|
|||
fluid_settings_getnum(settings, "synth.sample-rate", &sample_rate);
|
||||
fluid_settings_getint (settings, "audio.realtime-prio", &realtime_prio);
|
||||
|
||||
if (fluid_settings_str_equal (settings, "audio.realtime", "yes"))
|
||||
fluid_settings_getint (settings, "audio.realtime", &sched);
|
||||
if (sched)
|
||||
sched = SCHED_FIFO;
|
||||
else sched = SCHED_OTHER;
|
||||
|
||||
|
@ -653,7 +655,8 @@ new_fluid_oss_midi_driver(fluid_settings_t* settings,
|
|||
|
||||
fluid_settings_getint (settings, "midi.realtime-prio", &realtime_prio);
|
||||
|
||||
if (fluid_settings_str_equal (settings, "midi.realtime", "yes"))
|
||||
fluid_settings_getint (settings, "midi.realtime", &sched);
|
||||
if (sched)
|
||||
sched = SCHED_FIFO;
|
||||
else sched = SCHED_OTHER;
|
||||
|
||||
|
|
|
@ -106,7 +106,8 @@ new_fluid_pulse_audio_driver2(fluid_settings_t* settings,
|
|||
fluid_settings_dupstr(settings, "audio.pulseaudio.device", &device); /* ++ alloc device string */
|
||||
fluid_settings_getint (settings, "audio.realtime-prio", &realtime_prio);
|
||||
|
||||
if (fluid_settings_str_equal (settings, "audio.realtime", "yes"))
|
||||
fluid_settings_getint (settings, "audio.realtime", &sched);
|
||||
if (sched)
|
||||
sched = SCHED_FIFO;
|
||||
else sched = SCHED_OTHER;
|
||||
|
||||
|
|
|
@ -569,7 +569,7 @@ fluid_settings_register_int(fluid_settings_t* settings, char* name, int def,
|
|||
*
|
||||
* @param settings a settings object
|
||||
* @param name a setting's name
|
||||
* @return the type for the named setting, or FLUID_NO_TYPE when it does not exists
|
||||
* @return the type for the named setting, or #FLUID_NO_TYPE when it does not exist
|
||||
*/
|
||||
int
|
||||
fluid_settings_get_type(fluid_settings_t* settings, char* name)
|
||||
|
@ -612,6 +612,9 @@ fluid_settings_get_hints(fluid_settings_t* settings, char* name)
|
|||
} else if (node->type == FLUID_STR_TYPE) {
|
||||
fluid_str_setting_t* setting = (fluid_str_setting_t*) node;
|
||||
hints = setting->hints;
|
||||
} else if (node->type == FLUID_INT_TYPE) {
|
||||
fluid_int_setting_t* setting = (fluid_int_setting_t*) node;
|
||||
hints = setting->hints;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -645,6 +648,9 @@ fluid_settings_is_realtime(fluid_settings_t* settings, char* name)
|
|||
} else if (node->type == FLUID_STR_TYPE) {
|
||||
fluid_str_setting_t* setting = (fluid_str_setting_t*) node;
|
||||
isrealtime = setting->update != NULL;
|
||||
} else if (node->type == FLUID_INT_TYPE) {
|
||||
fluid_int_setting_t* setting = (fluid_int_setting_t*) node;
|
||||
isrealtime = setting->update != NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -665,7 +671,6 @@ int
|
|||
fluid_settings_setstr(fluid_settings_t* settings, char* name, char* str)
|
||||
{
|
||||
fluid_setting_node_t *node;
|
||||
fluid_str_setting_t* setting;
|
||||
int retval = 0;
|
||||
|
||||
fluid_return_val_if_fail (settings != NULL, 0);
|
||||
|
@ -675,7 +680,7 @@ fluid_settings_setstr(fluid_settings_t* settings, char* name, char* str)
|
|||
|
||||
if (fluid_settings_get (settings, name, &node)) {
|
||||
if (node->type == FLUID_STR_TYPE) {
|
||||
setting = (fluid_str_setting_t *)node;
|
||||
fluid_str_setting_t *setting = (fluid_str_setting_t *)node;
|
||||
|
||||
if (setting->value) FLUID_FREE (setting->value);
|
||||
setting->value = str ? FLUID_STRDUP (str) : NULL;
|
||||
|
@ -684,6 +689,24 @@ fluid_settings_setstr(fluid_settings_t* settings, char* name, char* str)
|
|||
if (setting->update) (*setting->update)(setting->data, name, str);
|
||||
retval = 1;
|
||||
}
|
||||
else if (node->type == FLUID_INT_TYPE) /* Handle yes/no for boolean values for backwards compatibility */
|
||||
{
|
||||
fluid_int_setting_t *setting = (fluid_int_setting_t *)node;
|
||||
|
||||
if (setting->hints & FLUID_HINT_TOGGLED)
|
||||
{
|
||||
if (FLUID_STRCMP (str, "yes") == 0)
|
||||
{
|
||||
setting->value = TRUE;
|
||||
if (setting->update) (*setting->update)(setting->data, name, TRUE);
|
||||
}
|
||||
else if (FLUID_STRCMP (str, "no") == 0)
|
||||
{
|
||||
setting->value = FALSE;
|
||||
if (setting->update) (*setting->update)(setting->data, name, FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* insert a new setting */
|
||||
fluid_str_setting_t* setting;
|
||||
|
@ -725,17 +748,32 @@ fluid_settings_copystr(fluid_settings_t* settings, char* name, char* str, int le
|
|||
|
||||
fluid_rec_mutex_lock (settings->mutex);
|
||||
|
||||
if (fluid_settings_get(settings, name, &node)
|
||||
&& (node->type == FLUID_STR_TYPE)) {
|
||||
fluid_str_setting_t* setting = (fluid_str_setting_t*) node;
|
||||
|
||||
if (setting->value)
|
||||
if (fluid_settings_get (settings, name, &node))
|
||||
{
|
||||
if (node->type == FLUID_STR_TYPE)
|
||||
{
|
||||
FLUID_STRNCPY (str, setting->value, len);
|
||||
str[len - 1] = 0; /* Force terminate, in case of truncation */
|
||||
}
|
||||
fluid_str_setting_t *setting = (fluid_str_setting_t *)node;
|
||||
|
||||
retval = 1;
|
||||
if (setting->value)
|
||||
{
|
||||
FLUID_STRNCPY (str, setting->value, len);
|
||||
str[len - 1] = 0; /* Force terminate, in case of truncation */
|
||||
}
|
||||
|
||||
retval = 1;
|
||||
}
|
||||
else if (node->type == FLUID_INT_TYPE) /* Handle boolean integers for backwards compatibility */
|
||||
{
|
||||
fluid_int_setting_t *setting = (fluid_int_setting_t *)node;
|
||||
|
||||
if (setting->hints & FLUID_HINT_TOGGLED)
|
||||
{
|
||||
FLUID_STRNCPY (str, setting->value ? "yes" : "no", len);
|
||||
str[len - 1] = 0; /* Force terminate, in case of truncation */
|
||||
|
||||
retval = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fluid_rec_mutex_unlock (settings->mutex);
|
||||
|
@ -766,17 +804,32 @@ fluid_settings_dupstr(fluid_settings_t* settings, char* name, char** str)
|
|||
|
||||
fluid_rec_mutex_lock (settings->mutex);
|
||||
|
||||
if (fluid_settings_get(settings, name, &node)
|
||||
&& (node->type == FLUID_STR_TYPE)) {
|
||||
fluid_str_setting_t* setting = (fluid_str_setting_t*) node;
|
||||
|
||||
if (setting->value)
|
||||
if (fluid_settings_get(settings, name, &node))
|
||||
{
|
||||
if (node->type == FLUID_STR_TYPE)
|
||||
{
|
||||
*str = FLUID_STRDUP (setting->value);
|
||||
if (!*str) FLUID_LOG (FLUID_ERR, "Out of memory");
|
||||
}
|
||||
fluid_str_setting_t *setting = (fluid_str_setting_t *)node;
|
||||
|
||||
if (!setting->value || *str) retval = 1; /* Don't set to 1 if out of memory */
|
||||
if (setting->value)
|
||||
{
|
||||
*str = FLUID_STRDUP (setting->value);
|
||||
if (!*str) FLUID_LOG (FLUID_ERR, "Out of memory");
|
||||
}
|
||||
|
||||
if (!setting->value || *str) retval = 1; /* Don't set to 1 if out of memory */
|
||||
}
|
||||
else if (node->type == FLUID_INT_TYPE) /* Handle boolean integers for backwards compatibility */
|
||||
{
|
||||
fluid_int_setting_t *setting = (fluid_int_setting_t *)node;
|
||||
|
||||
if (setting->hints & FLUID_HINT_TOGGLED)
|
||||
{
|
||||
*str = FLUID_STRDUP (setting->value ? "yes" : "no");
|
||||
if (!*str) FLUID_LOG (FLUID_ERR, "Out of memory");
|
||||
|
||||
if (!setting->value || *str) retval = 1; /* Don't set to 1 if out of memory */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fluid_rec_mutex_unlock (settings->mutex);
|
||||
|
@ -790,6 +843,7 @@ fluid_settings_dupstr(fluid_settings_t* settings, char* name, char** str)
|
|||
* @param name a setting's name
|
||||
* @param str Location to store pointer to the settings string value
|
||||
* @return 1 if the value exists, 0 otherwise
|
||||
* @deprecated
|
||||
*
|
||||
* If the value does not exists, 'str' is set to NULL. Otherwise, 'str' will
|
||||
* point to the value. The application does not own the returned value and it
|
||||
|
@ -812,11 +866,24 @@ fluid_settings_getstr(fluid_settings_t* settings, char* name, char** str)
|
|||
|
||||
fluid_rec_mutex_lock (settings->mutex);
|
||||
|
||||
if (fluid_settings_get(settings, name, &node)
|
||||
&& (node->type == FLUID_STR_TYPE)) {
|
||||
fluid_str_setting_t* setting = (fluid_str_setting_t*) node;
|
||||
*str = setting->value;
|
||||
retval = 1;
|
||||
if (fluid_settings_get(settings, name, &node))
|
||||
{
|
||||
if (node->type == FLUID_STR_TYPE)
|
||||
{
|
||||
fluid_str_setting_t *setting = (fluid_str_setting_t *)node;
|
||||
*str = setting->value;
|
||||
retval = 1;
|
||||
}
|
||||
else if (node->type == FLUID_INT_TYPE) /* Handle boolean integers for backwards compatibility */
|
||||
{
|
||||
fluid_int_setting_t *setting = (fluid_int_setting_t *)node;
|
||||
|
||||
if (setting->hints & FLUID_HINT_TOGGLED)
|
||||
{
|
||||
*str = setting->value ? "yes" : "no";
|
||||
retval = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else *str = NULL;
|
||||
|
||||
|
@ -834,7 +901,7 @@ fluid_settings_getstr(fluid_settings_t* settings, char* name, char** str)
|
|||
* @return 1 if the value exists and is equal to 's', 0 otherwise
|
||||
*/
|
||||
int
|
||||
fluid_settings_str_equal(fluid_settings_t* settings, char* name, char* s)
|
||||
fluid_settings_str_equal (fluid_settings_t* settings, char* name, char* s)
|
||||
{
|
||||
fluid_setting_node_t *node;
|
||||
int retval = 0;
|
||||
|
@ -845,10 +912,20 @@ fluid_settings_str_equal(fluid_settings_t* settings, char* name, char* s)
|
|||
|
||||
fluid_rec_mutex_lock (settings->mutex);
|
||||
|
||||
if (fluid_settings_get(settings, name, &node)
|
||||
&& (node->type == FLUID_STR_TYPE)) {
|
||||
fluid_str_setting_t* setting = (fluid_str_setting_t*) node;
|
||||
if (setting->value) retval = FLUID_STRCMP (setting->value, s) == 0;
|
||||
if (fluid_settings_get (settings, name, &node))
|
||||
{
|
||||
if (node->type == FLUID_STR_TYPE)
|
||||
{
|
||||
fluid_str_setting_t *setting = (fluid_str_setting_t *)node;
|
||||
if (setting->value) retval = FLUID_STRCMP (setting->value, s) == 0;
|
||||
}
|
||||
else if (node->type == FLUID_INT_TYPE) /* Handle boolean integers for backwards compatibility */
|
||||
{
|
||||
fluid_int_setting_t *setting = (fluid_int_setting_t *)node;
|
||||
|
||||
if (setting->hints & FLUID_HINT_TOGGLED)
|
||||
retval = FLUID_STRCMP (setting->value ? "yes" : "no", s) == 0;
|
||||
}
|
||||
}
|
||||
|
||||
fluid_rec_mutex_unlock (settings->mutex);
|
||||
|
@ -875,10 +952,20 @@ fluid_settings_getstr_default(fluid_settings_t* settings, char* name)
|
|||
|
||||
fluid_rec_mutex_lock (settings->mutex);
|
||||
|
||||
if (fluid_settings_get(settings, name, &node)
|
||||
&& (node->type == FLUID_STR_TYPE)) {
|
||||
fluid_str_setting_t* setting = (fluid_str_setting_t*) node;
|
||||
retval = setting->def;
|
||||
if (fluid_settings_get (settings, name, &node))
|
||||
{
|
||||
if (node->type == FLUID_STR_TYPE)
|
||||
{
|
||||
fluid_str_setting_t* setting = (fluid_str_setting_t*) node;
|
||||
retval = setting->def;
|
||||
}
|
||||
else if (node->type == FLUID_INT_TYPE) /* Handle boolean integers for backwards compatibility */
|
||||
{
|
||||
fluid_int_setting_t *setting = (fluid_int_setting_t *)node;
|
||||
|
||||
if (setting->hints & FLUID_HINT_TOGGLED)
|
||||
retval = setting->def ? "yes" : "no";
|
||||
}
|
||||
}
|
||||
|
||||
fluid_rec_mutex_unlock (settings->mutex);
|
||||
|
@ -892,6 +979,8 @@ fluid_settings_getstr_default(fluid_settings_t* settings, char* name)
|
|||
* @param name a setting's name
|
||||
* @param s option string to add
|
||||
* @return 1 if the setting exists and option was added, 0 otherwise
|
||||
*
|
||||
* Causes the setting's #FLUID_HINT_OPTIONLIST hint to be set.
|
||||
*/
|
||||
int
|
||||
fluid_settings_add_option(fluid_settings_t* settings, char* name, const char* s)
|
||||
|
@ -910,6 +999,7 @@ fluid_settings_add_option(fluid_settings_t* settings, char* name, const char* s)
|
|||
fluid_str_setting_t* setting = (fluid_str_setting_t*) node;
|
||||
char* copy = FLUID_STRDUP(s);
|
||||
setting->options = fluid_list_append(setting->options, copy);
|
||||
setting->hints |= FLUID_HINT_OPTIONLIST;
|
||||
retval = 1;
|
||||
}
|
||||
|
||||
|
@ -1243,51 +1333,15 @@ fluid_settings_getint_default(fluid_settings_t* settings, char* name)
|
|||
* @param name a setting's name
|
||||
* @param data any user provided pointer
|
||||
* @param func callback function to be called on each iteration
|
||||
*
|
||||
* NOTE: Starting with FluidSynth 1.1.0 the \a func callback is called for each
|
||||
* option in alphabetical order. Sort order was undefined in previous versions.
|
||||
*/
|
||||
void
|
||||
fluid_settings_foreach_option (fluid_settings_t* settings, char* name, void* data,
|
||||
fluid_settings_foreach_option_t func)
|
||||
{
|
||||
fluid_setting_node_t *node;
|
||||
|
||||
fluid_return_if_fail (settings != NULL);
|
||||
fluid_return_if_fail (name != NULL);
|
||||
fluid_return_if_fail (func != NULL);
|
||||
|
||||
fluid_rec_mutex_lock (settings->mutex);
|
||||
|
||||
if (fluid_settings_get(settings, name, &node)
|
||||
&& (node->type == FLUID_STR_TYPE)) {
|
||||
|
||||
fluid_str_setting_t* setting = (fluid_str_setting_t*) node;
|
||||
fluid_list_t* list = setting->options;
|
||||
|
||||
while (list) {
|
||||
char* option = (char*) fluid_list_get(list);
|
||||
(*func)(data, name, option);
|
||||
list = fluid_list_next(list);
|
||||
}
|
||||
}
|
||||
|
||||
fluid_rec_mutex_unlock (settings->mutex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterate the available options for a named string setting, calling the provided
|
||||
* callback function for each existing option. Like fluid_settings_foreach_option()
|
||||
* but calls the callback for each option in alphabetical order.
|
||||
*
|
||||
* @param settings a settings object
|
||||
* @param name a setting's name
|
||||
* @param data any user provided pointer
|
||||
* @param func callback function to be called on each iteration
|
||||
* @since 1.1.0
|
||||
*/
|
||||
void
|
||||
fluid_settings_foreach_option_alpha (fluid_settings_t* settings, char* name, void* data,
|
||||
fluid_settings_foreach_option_t func)
|
||||
{
|
||||
fluid_setting_node_t *node;
|
||||
fluid_str_setting_t *setting;
|
||||
fluid_list_t *p, *newlist = NULL;
|
||||
|
||||
|
@ -1348,9 +1402,8 @@ fluid_settings_option_count (fluid_settings_t *settings, char *name)
|
|||
/* Structure passed to fluid_settings_foreach_iter recursive function */
|
||||
typedef struct
|
||||
{
|
||||
fluid_settings_foreach_t func;
|
||||
void *data;
|
||||
char path[MAX_SETTINGS_LABEL+1]; /* Maximum settings label length */
|
||||
fluid_list_t *names; /* For fluid_settings_foreach() */
|
||||
} fluid_settings_foreach_bag_t;
|
||||
|
||||
static int
|
||||
|
@ -1360,73 +1413,6 @@ fluid_settings_foreach_iter (void* key, void* value, void* data)
|
|||
char *keystr = key;
|
||||
fluid_setting_node_t *node = value;
|
||||
int pathlen;
|
||||
|
||||
pathlen = strlen (bag->path);
|
||||
|
||||
if (pathlen > 0)
|
||||
{
|
||||
bag->path[pathlen] = '.';
|
||||
bag->path[pathlen + 1] = 0;
|
||||
}
|
||||
|
||||
strcat (bag->path, keystr);
|
||||
|
||||
switch (node->type) {
|
||||
case FLUID_NUM_TYPE:
|
||||
case FLUID_INT_TYPE:
|
||||
case FLUID_STR_TYPE:
|
||||
(*bag->func)(bag->data, bag->path, node->type);
|
||||
break;
|
||||
case FLUID_SET_TYPE:
|
||||
fluid_hashtable_foreach(((fluid_set_setting_t *)value)->hashtable,
|
||||
fluid_settings_foreach_iter, bag);
|
||||
break;
|
||||
}
|
||||
|
||||
bag->path[pathlen] = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterate the existing settings defined in a settings object, calling the
|
||||
* provided callback function for each setting.
|
||||
*
|
||||
* @param settings a settings object
|
||||
* @param data any user provided pointer
|
||||
* @param func callback function to be called on each iteration
|
||||
*/
|
||||
void
|
||||
fluid_settings_foreach(fluid_settings_t* settings, void* data, fluid_settings_foreach_t func)
|
||||
{
|
||||
fluid_settings_foreach_bag_t bag;
|
||||
|
||||
fluid_return_if_fail (settings != NULL);
|
||||
fluid_return_if_fail (func != NULL);
|
||||
|
||||
bag.func = func;
|
||||
bag.data = data;
|
||||
bag.path[0] = 0;
|
||||
|
||||
fluid_rec_mutex_lock (settings->mutex);
|
||||
fluid_hashtable_foreach(settings, fluid_settings_foreach_iter, &bag);
|
||||
fluid_rec_mutex_unlock (settings->mutex);
|
||||
}
|
||||
|
||||
/* Structure passed to fluid_settings_foreach_iter recursive function */
|
||||
typedef struct
|
||||
{
|
||||
char path[MAX_SETTINGS_LABEL+1]; /* Maximum settings label length */
|
||||
fluid_list_t *names; /* For fluid_settings_foreach_alpha() */
|
||||
} fluid_settings_foreach_alpha_bag_t;
|
||||
|
||||
static int
|
||||
fluid_settings_foreach_alpha_iter (void* key, void* value, void* data)
|
||||
{
|
||||
fluid_settings_foreach_alpha_bag_t *bag = data;
|
||||
char *keystr = key;
|
||||
fluid_setting_node_t *node = value;
|
||||
int pathlen;
|
||||
char *s;
|
||||
|
||||
pathlen = strlen (bag->path);
|
||||
|
@ -1448,7 +1434,7 @@ fluid_settings_foreach_alpha_iter (void* key, void* value, void* data)
|
|||
break;
|
||||
case FLUID_SET_TYPE:
|
||||
fluid_hashtable_foreach(((fluid_set_setting_t *)value)->hashtable,
|
||||
fluid_settings_foreach_alpha_iter, bag);
|
||||
fluid_settings_foreach_iter, bag);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1459,18 +1445,20 @@ fluid_settings_foreach_alpha_iter (void* key, void* value, void* data)
|
|||
|
||||
/**
|
||||
* Iterate the existing settings defined in a settings object, calling the
|
||||
* provided callback function for each setting. Like fluid_settings_foreach()
|
||||
* but calls the callback with each setting in alphabetical order.
|
||||
* provided callback function for each setting.
|
||||
*
|
||||
* @param settings a settings object
|
||||
* @param data any user provided pointer
|
||||
* @param func callback function to be called on each iteration
|
||||
* @since 1.1.0
|
||||
*
|
||||
* NOTE: Starting with FluidSynth 1.1.0 the \a func callback is called for each
|
||||
* setting in alphabetical order. Sort order was undefined in previous versions.
|
||||
*/
|
||||
void
|
||||
fluid_settings_foreach_alpha(fluid_settings_t* settings, void* data, fluid_settings_foreach_t func)
|
||||
fluid_settings_foreach (fluid_settings_t* settings, void* data,
|
||||
fluid_settings_foreach_t func)
|
||||
{
|
||||
fluid_settings_foreach_alpha_bag_t bag;
|
||||
fluid_settings_foreach_bag_t bag;
|
||||
fluid_setting_node_t *node;
|
||||
fluid_list_t *p;
|
||||
|
||||
|
@ -1483,7 +1471,7 @@ fluid_settings_foreach_alpha(fluid_settings_t* settings, void* data, fluid_setti
|
|||
fluid_rec_mutex_lock (settings->mutex);
|
||||
|
||||
/* Add all node names to the bag.names list */
|
||||
fluid_hashtable_foreach (settings, fluid_settings_foreach_alpha_iter, &bag);
|
||||
fluid_hashtable_foreach (settings, fluid_settings_foreach_iter, &bag);
|
||||
|
||||
/* Sort names */
|
||||
bag.names = fluid_list_sort (bag.names, fluid_list_str_compare_func);
|
||||
|
|
|
@ -202,21 +202,16 @@ static fluid_revmodel_presets_t revmodel_preset[] = {
|
|||
|
||||
void fluid_synth_settings(fluid_settings_t* settings)
|
||||
{
|
||||
fluid_settings_register_str(settings, "synth.verbose", "no", 0, NULL, NULL);
|
||||
fluid_settings_add_option(settings, "synth.verbose", "no");
|
||||
fluid_settings_add_option(settings, "synth.verbose", "yes");
|
||||
fluid_settings_register_str(settings, "synth.dump", "no", 0, NULL, NULL);
|
||||
fluid_settings_add_option(settings, "synth.dump", "no");
|
||||
fluid_settings_add_option(settings, "synth.dump", "yes");
|
||||
fluid_settings_register_str(settings, "synth.reverb.active", "yes", 0, NULL, NULL);
|
||||
fluid_settings_add_option(settings, "synth.reverb.active", "no");
|
||||
fluid_settings_add_option(settings, "synth.reverb.active", "yes");
|
||||
fluid_settings_register_str(settings, "synth.chorus.active", "yes", 0, NULL, NULL);
|
||||
fluid_settings_add_option(settings, "synth.chorus.active", "no");
|
||||
fluid_settings_add_option(settings, "synth.chorus.active", "yes");
|
||||
fluid_settings_register_str(settings, "synth.ladspa.active", "no", 0, NULL, NULL);
|
||||
fluid_settings_add_option(settings, "synth.ladspa.active", "no");
|
||||
fluid_settings_add_option(settings, "synth.ladspa.active", "yes");
|
||||
fluid_settings_register_int(settings, "synth.verbose", 0, 0, 1,
|
||||
FLUID_HINT_TOGGLED, NULL, NULL);
|
||||
fluid_settings_register_int(settings, "synth.dump", 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_str(settings, "midi.portname", "", 0, NULL, NULL);
|
||||
|
||||
fluid_settings_register_int(settings, "synth.polyphony",
|
||||
|
@ -547,10 +542,10 @@ new_fluid_synth(fluid_settings_t *settings)
|
|||
|
||||
synth->settings = settings;
|
||||
|
||||
synth->with_reverb = fluid_settings_str_equal(settings, "synth.reverb.active", "yes");
|
||||
synth->with_chorus = fluid_settings_str_equal(settings, "synth.chorus.active", "yes");
|
||||
synth->verbose = fluid_settings_str_equal(settings, "synth.verbose", "yes");
|
||||
synth->dump = fluid_settings_str_equal(settings, "synth.dump", "yes");
|
||||
fluid_settings_getint(settings, "synth.reverb.active", &synth->with_reverb);
|
||||
fluid_settings_getint(settings, "synth.chorus.active", &synth->with_chorus);
|
||||
fluid_settings_getint(settings, "synth.verbose", &synth->verbose);
|
||||
fluid_settings_getint(settings, "synth.dump", &synth->dump);
|
||||
|
||||
fluid_settings_getint(settings, "synth.polyphony", &synth->polyphony);
|
||||
fluid_settings_getnum(settings, "synth.sample-rate", &synth->sample_rate);
|
||||
|
@ -780,7 +775,7 @@ new_fluid_synth(fluid_settings_t *settings)
|
|||
for (i = 0; i < synth->polyphony; i++)
|
||||
synth->core_voice_processed[i] = NULL;
|
||||
|
||||
prio = fluid_settings_str_equal (synth->settings, "audio.realtime", "yes");
|
||||
fluid_settings_getint (synth->settings, "audio.realtime", &prio);
|
||||
|
||||
if (prio)
|
||||
{
|
||||
|
|
|
@ -165,8 +165,8 @@ struct _fluid_synth_t
|
|||
int polyphony; /**< maximum polyphony */
|
||||
int with_reverb; /**< Should the synth use the built-in reverb unit? */
|
||||
int with_chorus; /**< Should the synth use the built-in chorus unit? */
|
||||
char verbose; /**< Turn verbose mode on? */
|
||||
char dump; /**< Dump events to stdout to hook up a user interface? */
|
||||
int verbose; /**< Turn verbose mode on? */
|
||||
int dump; /**< Dump events to stdout to hook up a user interface? */
|
||||
double sample_rate; /**< The sample rate */
|
||||
int midi_channels; /**< the number of MIDI channels (>= 16) */
|
||||
int audio_channels; /**< the number of audio channels (1 channel=left+right) */
|
||||
|
|
|
@ -76,14 +76,13 @@ extern int optind, opterr, optopt;
|
|||
#endif
|
||||
|
||||
|
||||
/* process_o_cmd_line_option
|
||||
*
|
||||
* Purpose:
|
||||
* Process a command line option -o setting=value,
|
||||
* for example: -o synth.polyhony=16
|
||||
*/
|
||||
void process_o_cmd_line_option(fluid_settings_t* settings, char* optarg){
|
||||
/* Process a command line option -o setting=value, for example: -o synth.polyhony=16 */
|
||||
void process_o_cmd_line_option(fluid_settings_t* settings, char* optarg)
|
||||
{
|
||||
char* val;
|
||||
int hints;
|
||||
int ival;
|
||||
|
||||
for (val = optarg; *val != '\0'; val++) {
|
||||
if (*val == '=') {
|
||||
*val++ = 0;
|
||||
|
@ -98,26 +97,43 @@ void process_o_cmd_line_option(fluid_settings_t* settings, char* optarg){
|
|||
return;
|
||||
}
|
||||
|
||||
/* At this point:
|
||||
* optarg => "synth.polyphony"
|
||||
* val => "16"
|
||||
*/
|
||||
switch(fluid_settings_get_type(settings, optarg)){
|
||||
case FLUID_NUM_TYPE:
|
||||
if (fluid_settings_setnum(settings, optarg, atof(val))){
|
||||
break;
|
||||
};
|
||||
if (!fluid_settings_setnum (settings, optarg, atof (val)))
|
||||
{
|
||||
fprintf (stderr, "Failed to set floating point parameter '%s'\n", optarg);
|
||||
exit (1);
|
||||
}
|
||||
break;
|
||||
case FLUID_INT_TYPE:
|
||||
if (fluid_settings_setint(settings, optarg, atoi(val))){
|
||||
break;
|
||||
};
|
||||
hints = fluid_settings_get_hints (settings, optarg);
|
||||
|
||||
if (hints & FLUID_HINT_TOGGLED)
|
||||
{
|
||||
if (FLUID_STRCMP (val, "yes") == 0 || FLUID_STRCMP (val, "True") == 0
|
||||
|| FLUID_STRCMP (val, "TRUE") == 0 || FLUID_STRCMP (val, "true") == 0
|
||||
|| FLUID_STRCMP (val, "T") == 0)
|
||||
ival = 1;
|
||||
else ival = atoi (val);
|
||||
}
|
||||
else ival = atoi (val);
|
||||
|
||||
if (!fluid_settings_setint (settings, optarg, ival))
|
||||
{
|
||||
fprintf (stderr, "Failed to set integer parameter '%s'\n", optarg);
|
||||
exit (1);
|
||||
}
|
||||
break;
|
||||
case FLUID_STR_TYPE:
|
||||
if (fluid_settings_setstr(settings, optarg, val)){
|
||||
break;
|
||||
};
|
||||
if (fluid_settings_setstr (settings, optarg, val))
|
||||
{
|
||||
fprintf (stderr, "Failed to set string parameter '%s'\n", optarg);
|
||||
exit (1);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
fprintf (stderr, "Settings argument on command line: Failed to set \"%s\" to \"%s\".\n"
|
||||
"Most likely the parameter \"%s\" does not exist.\n", optarg, val, optarg);
|
||||
fprintf (stderr, "Setting parameter '%s' not found\n", optarg);
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -154,7 +170,7 @@ settings_foreach_func (void *data, char *name, int type)
|
|||
{
|
||||
fluid_settings_t *settings = (fluid_settings_t *)data;
|
||||
double dmin, dmax, ddef;
|
||||
int imin, imax, idef;
|
||||
int imin, imax, idef, hints;
|
||||
char *defstr;
|
||||
int count;
|
||||
OptionBag bag;
|
||||
|
@ -170,13 +186,19 @@ settings_foreach_func (void *data, char *name, int type)
|
|||
case FLUID_INT_TYPE:
|
||||
fluid_settings_getint_range (settings, name, &imin, &imax);
|
||||
idef = fluid_settings_getint_default (settings, name);
|
||||
printf ("%-24s INT [min=", name);
|
||||
print_pretty_int (imin);
|
||||
printf (", max=");
|
||||
print_pretty_int (imax);
|
||||
printf (", def=");
|
||||
print_pretty_int (idef);
|
||||
printf ("]\n");
|
||||
hints = fluid_settings_get_hints (settings, name);
|
||||
|
||||
if (!(hints & FLUID_HINT_TOGGLED))
|
||||
{
|
||||
printf ("%-24s INT [min=", name);
|
||||
print_pretty_int (imin);
|
||||
printf (", max=");
|
||||
print_pretty_int (imax);
|
||||
printf (", def=");
|
||||
print_pretty_int (idef);
|
||||
printf ("]\n");
|
||||
}
|
||||
else printf ("%-24s BOOL [def=%s]\n", name, idef ? "True" : "False");
|
||||
break;
|
||||
case FLUID_STR_TYPE:
|
||||
printf ("%-24s STR", name);
|
||||
|
@ -194,8 +216,8 @@ settings_foreach_func (void *data, char *name, int type)
|
|||
{
|
||||
bag.count = count;
|
||||
bag.curindex = 0;
|
||||
fluid_settings_foreach_option_alpha (settings, name, &bag,
|
||||
settings_option_foreach_func);
|
||||
fluid_settings_foreach_option (settings, name, &bag,
|
||||
settings_option_foreach_func);
|
||||
}
|
||||
|
||||
printf ("]\n");
|
||||
|
@ -216,8 +238,8 @@ show_settings_str_options (fluid_settings_t *settings, char *name)
|
|||
|
||||
bag.count = fluid_settings_option_count (settings, name);
|
||||
bag.curindex = 0;
|
||||
fluid_settings_foreach_option_alpha (settings, name, &bag,
|
||||
settings_option_foreach_func);
|
||||
fluid_settings_foreach_option (settings, name, &bag,
|
||||
settings_option_foreach_func);
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
|
@ -280,6 +302,8 @@ int main(int argc, char** argv)
|
|||
lash_args = fluid_lash_extract_args (&argc, &argv);
|
||||
#endif
|
||||
|
||||
print_welcome ();
|
||||
|
||||
settings = new_fluid_settings();
|
||||
|
||||
#ifdef GETOPT_SUPPORT /* pre section of GETOPT supported argument handling */
|
||||
|
@ -368,7 +392,6 @@ int main(int argc, char** argv)
|
|||
case 'a':
|
||||
if (FLUID_STRCMP (optarg, "help") == 0)
|
||||
{
|
||||
print_welcome ();
|
||||
printf ("-a options (audio driver):\n ");
|
||||
show_settings_str_options (settings, "audio.driver");
|
||||
exit (0);
|
||||
|
@ -377,22 +400,21 @@ int main(int argc, char** argv)
|
|||
break;
|
||||
case 'C':
|
||||
if ((optarg != NULL) && ((strcmp(optarg, "0") == 0) || (strcmp(optarg, "no") == 0))) {
|
||||
fluid_settings_setstr(settings, "synth.chorus.active", "no");
|
||||
fluid_settings_setint(settings, "synth.chorus.active", FALSE);
|
||||
} else {
|
||||
fluid_settings_setstr(settings, "synth.chorus.active", "yes");
|
||||
fluid_settings_setint(settings, "synth.chorus.active", TRUE);
|
||||
}
|
||||
break;
|
||||
case 'c':
|
||||
fluid_settings_setint(settings, "audio.periods", atoi(optarg));
|
||||
break;
|
||||
case 'd':
|
||||
fluid_settings_setstr(settings, "synth.dump", "yes");
|
||||
fluid_settings_setint(settings, "synth.dump", TRUE);
|
||||
dump = 1;
|
||||
break;
|
||||
case 'E':
|
||||
if (FLUID_STRCMP (optarg, "help") == 0)
|
||||
{
|
||||
print_welcome ();
|
||||
printf ("-E options (audio file byte order):\n ");
|
||||
show_settings_str_options (settings, "audio.file.endian");
|
||||
|
||||
|
@ -442,7 +464,6 @@ int main(int argc, char** argv)
|
|||
case 'm':
|
||||
if (FLUID_STRCMP (optarg, "help") == 0)
|
||||
{
|
||||
print_welcome ();
|
||||
printf ("-m options (MIDI driver):\n ");
|
||||
show_settings_str_options (settings, "midi.driver");
|
||||
exit (0);
|
||||
|
@ -455,7 +476,6 @@ int main(int argc, char** argv)
|
|||
case 'O':
|
||||
if (FLUID_STRCMP (optarg, "help") == 0)
|
||||
{
|
||||
print_welcome ();
|
||||
printf ("-O options (audio file format):\n ");
|
||||
show_settings_str_options (settings, "audio.file.format");
|
||||
|
||||
|
@ -478,9 +498,9 @@ int main(int argc, char** argv)
|
|||
break;
|
||||
case 'R':
|
||||
if ((optarg != NULL) && ((strcmp(optarg, "0") == 0) || (strcmp(optarg, "no") == 0))) {
|
||||
fluid_settings_setstr(settings, "synth.reverb.active", "no");
|
||||
fluid_settings_setint(settings, "synth.reverb.active", FALSE);
|
||||
} else {
|
||||
fluid_settings_setstr(settings, "synth.reverb.active", "yes");
|
||||
fluid_settings_setint(settings, "synth.reverb.active", TRUE);
|
||||
}
|
||||
break;
|
||||
case 'r':
|
||||
|
@ -492,7 +512,6 @@ int main(int argc, char** argv)
|
|||
case 'T':
|
||||
if (FLUID_STRCMP (optarg, "help") == 0)
|
||||
{
|
||||
print_welcome ();
|
||||
printf ("-T options (audio file type):\n ");
|
||||
show_settings_str_options (settings, "audio.file.type");
|
||||
|
||||
|
@ -510,7 +529,7 @@ int main(int argc, char** argv)
|
|||
exit (0);
|
||||
break;
|
||||
case 'v':
|
||||
fluid_settings_setstr(settings, "synth.verbose", "yes");
|
||||
fluid_settings_setint(settings, "synth.verbose", TRUE);
|
||||
break;
|
||||
case 'z':
|
||||
fluid_settings_setint(settings, "audio.period-size", atoi(optarg));
|
||||
|
@ -543,9 +562,8 @@ int main(int argc, char** argv)
|
|||
/* option help requested? "-o help" */
|
||||
if (option_help)
|
||||
{
|
||||
print_welcome ();
|
||||
printf ("FluidSynth settings:\n");
|
||||
fluid_settings_foreach_alpha (settings, settings, settings_foreach_func);
|
||||
fluid_settings_foreach (settings, settings, settings_foreach_func);
|
||||
exit (0);
|
||||
}
|
||||
|
||||
|
@ -703,9 +721,7 @@ int main(int argc, char** argv)
|
|||
|
||||
/* run the shell */
|
||||
if (interactive) {
|
||||
print_welcome();
|
||||
|
||||
printf ("Type 'help' for information on commands and 'help help' for help topics.\n\n");
|
||||
printf ("Type 'help' for help topics.\n\n");
|
||||
|
||||
/* In dump mode we set the prompt to "". The UI cannot easily
|
||||
* handle lines, which don't end with CR. Changing the prompt
|
||||
|
@ -720,7 +736,6 @@ int main(int argc, char** argv)
|
|||
if (fast_render) {
|
||||
char *filename;
|
||||
|
||||
print_welcome ();
|
||||
fluid_settings_dupstr (settings, "audio.file.name", &filename);
|
||||
printf ("Rendering audio to file '%s'..\n", filename);
|
||||
if (filename) FLUID_FREE (filename);
|
||||
|
@ -797,15 +812,11 @@ static fluid_cmd_handler_t* newclient(void* data, char* addr)
|
|||
void
|
||||
print_usage()
|
||||
{
|
||||
print_welcome ();
|
||||
fprintf(stderr, "Usage: fluidsynth [options] [soundfonts]\n");
|
||||
fprintf(stderr, "Try -h for help.\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* print_welcome
|
||||
*/
|
||||
void
|
||||
print_welcome()
|
||||
{
|
||||
|
@ -823,7 +834,7 @@ void
|
|||
print_help()
|
||||
{
|
||||
char allnames[256];
|
||||
print_welcome ();
|
||||
|
||||
printf("Usage: \n");
|
||||
printf(" fluidsynth [options] [soundfonts] [midifiles]\n");
|
||||
printf("Possible options:\n");
|
||||
|
|
Loading…
Reference in a new issue