@@ -150,6 +150,99 @@ fluidsynth_sysex(uint8_t *data, unsigned int len)
150150 fluid_synth_sysex (d -> synth , (const char * ) data , len , 0 , 0 , 0 , 0 );
151151}
152152
153+ void
154+ fluidsynth_reload_config (UNUSED (void * priv ))
155+ {
156+ fluidsynth_t * data = & fsdev ;
157+
158+ fluid_synth_sfunload (data -> synth , data -> sound_font , 1 );
159+
160+ fluid_settings_setnum (data -> settings , "synth.gain" , device_get_config_int ("output_gain" ) / 100.0f );
161+
162+ const char * sound_font = device_get_config_string ("sound_font" );
163+ #ifdef __unix__
164+ if (!sound_font || sound_font [0 ] == 0 )
165+ sound_font = (access ("/usr/share/sounds/sf2/FluidR3_GM.sf2" , F_OK ) == 0 ? "/usr/share/sounds/sf2/FluidR3_GM.sf2" :
166+ (access ("/usr/share/soundfonts/default.sf2" , F_OK ) == 0 ? "/usr/share/soundfonts/default.sf2" : "" ));
167+ #endif
168+ data -> sound_font = fluid_synth_sfload (data -> synth , sound_font , 1 );
169+
170+ if (device_get_config_int ("chorus" )) {
171+ #ifndef USE_OLD_FLUIDSYNTH_API
172+ fluid_synth_chorus_on (data -> synth , -1 , 1 );
173+ #else
174+ fluid_synth_set_chorus_on (data -> synth , 1 );
175+ #endif
176+
177+ int chorus_voices = device_get_config_int ("chorus_voices" );
178+ double chorus_level = device_get_config_int ("chorus_level" ) / 100.0 ;
179+ double chorus_speed = device_get_config_int ("chorus_speed" ) / 100.0 ;
180+ double chorus_depth = device_get_config_int ("chorus_depth" ) / 10.0 ;
181+
182+ int chorus_waveform = FLUID_CHORUS_MOD_SINE ;
183+ if (device_get_config_int ("chorus_waveform" ) == 0 )
184+ chorus_waveform = FLUID_CHORUS_MOD_SINE ;
185+ else
186+ chorus_waveform = FLUID_CHORUS_MOD_TRIANGLE ;
187+
188+ #ifndef USE_OLD_FLUIDSYNTH_API
189+ fluid_synth_set_chorus_group_nr (data -> synth , -1 , chorus_voices );
190+ fluid_synth_set_chorus_group_level (data -> synth , -1 , chorus_level );
191+ fluid_synth_set_chorus_group_speed (data -> synth , -1 , chorus_speed );
192+ fluid_synth_set_chorus_group_depth (data -> synth , -1 , chorus_depth );
193+ fluid_synth_set_chorus_group_type (data -> synth , -1 , chorus_waveform );
194+ #else
195+ fluid_synth_set_chorus (data -> synth , chorus_voices , chorus_level , chorus_speed , chorus_depth , chorus_waveform );
196+ #endif
197+ } else
198+ #ifndef USE_OLD_FLUIDSYNTH_API
199+ fluid_synth_chorus_on (data -> synth , -1 , 0 );
200+ #else
201+ fluid_synth_set_chorus_on (data -> synth , 0 );
202+ #endif
203+
204+ if (device_get_config_int ("reverb" )) {
205+ #ifndef USE_OLD_FLUIDSYNTH_API
206+ fluid_synth_reverb_on (data -> synth , -1 , 1 );
207+ #else
208+ fluid_synth_set_reverb_on (data -> synth , 1 );
209+ #endif
210+
211+ double reverb_room_size = device_get_config_int ("reverb_room_size" ) / 100.0 ;
212+ double reverb_damping = device_get_config_int ("reverb_damping" ) / 100.0 ;
213+ double reverb_width = device_get_config_int ("reverb_width" ) / 10.0 ;
214+ double reverb_level = device_get_config_int ("reverb_level" ) / 100.0 ;
215+
216+ #ifndef USE_OLD_FLUIDSYNTH_API
217+ fluid_synth_set_reverb_group_roomsize (data -> synth , -1 , reverb_room_size );
218+ fluid_synth_set_reverb_group_damp (data -> synth , -1 , reverb_damping );
219+ fluid_synth_set_reverb_group_width (data -> synth , -1 , reverb_width );
220+ fluid_synth_set_reverb_group_level (data -> synth , -1 , reverb_level );
221+ #else
222+ fluid_synth_set_reverb (data -> synth , reverb_room_size , reverb_damping , reverb_width , reverb_level );
223+ #endif
224+ } else
225+ #ifndef USE_OLD_FLUIDSYNTH_API
226+ fluid_synth_reverb_on (data -> synth , -1 , 0 );
227+ #else
228+ fluid_synth_set_reverb_on (data -> synth , 0 );
229+ #endif
230+
231+ int interpolation = device_get_config_int ("interpolation" );
232+ int fs_interpolation = FLUID_INTERP_4THORDER ;
233+
234+ if (interpolation == 0 )
235+ fs_interpolation = FLUID_INTERP_NONE ;
236+ else if (interpolation == 1 )
237+ fs_interpolation = FLUID_INTERP_LINEAR ;
238+ else if (interpolation == 2 )
239+ fs_interpolation = FLUID_INTERP_4THORDER ;
240+ else if (interpolation == 3 )
241+ fs_interpolation = FLUID_INTERP_7THORDER ;
242+
243+ fluid_synth_set_interp_method (data -> synth , -1 , fs_interpolation );
244+ }
245+
153246void *
154247fluidsynth_init (UNUSED (const device_t * info ))
155248{
@@ -323,14 +416,14 @@ static const device_config_t fluidsynth_config[] = {
323416 {
324417 .name = "sound_font" ,
325418 .description = "Sound Font" ,
326- .type = CONFIG_FNAME ,
419+ .type = CONFIG_FNAME | CONFIG_RUNTIME ,
327420 .default_string = "" ,
328421 .file_filter = "SF2 Sound Fonts (*.sf2)|*.sf2"
329422 },
330423 {
331424 .name = "output_gain" ,
332425 .description = "Output Gain" ,
333- .type = CONFIG_SPINNER ,
426+ .type = CONFIG_SPINNER | CONFIG_RUNTIME ,
334427 .spinner =
335428 {
336429 .min = 0 ,
@@ -341,13 +434,13 @@ static const device_config_t fluidsynth_config[] = {
341434 {
342435 .name = "chorus" ,
343436 .description = "Chorus" ,
344- .type = CONFIG_BINARY ,
437+ .type = CONFIG_BINARY | CONFIG_RUNTIME ,
345438 .default_int = 1
346439 },
347440 {
348441 .name = "chorus_voices" ,
349442 .description = "Chorus Voices" ,
350- .type = CONFIG_SPINNER ,
443+ .type = CONFIG_SPINNER | CONFIG_RUNTIME ,
351444 .spinner =
352445 {
353446 .min = 0 ,
@@ -358,7 +451,7 @@ static const device_config_t fluidsynth_config[] = {
358451 {
359452 .name = "chorus_level" ,
360453 .description = "Chorus Level" ,
361- .type = CONFIG_SPINNER ,
454+ .type = CONFIG_SPINNER | CONFIG_RUNTIME ,
362455 .spinner =
363456 {
364457 .min = 0 ,
@@ -369,7 +462,7 @@ static const device_config_t fluidsynth_config[] = {
369462 {
370463 .name = "chorus_speed" ,
371464 .description = "Chorus Speed" ,
372- .type = CONFIG_SPINNER ,
465+ .type = CONFIG_SPINNER | CONFIG_RUNTIME ,
373466 .spinner =
374467 {
375468 .min = 10 ,
@@ -380,7 +473,7 @@ static const device_config_t fluidsynth_config[] = {
380473 {
381474 .name = "chorus_depth" ,
382475 .description = "Chorus Depth" ,
383- .type = CONFIG_SPINNER ,
476+ .type = CONFIG_SPINNER | CONFIG_RUNTIME ,
384477 .spinner =
385478 {
386479 .min = 0 ,
@@ -391,7 +484,7 @@ static const device_config_t fluidsynth_config[] = {
391484 {
392485 .name = "chorus_waveform" ,
393486 .description = "Chorus Waveform" ,
394- .type = CONFIG_SELECTION ,
487+ .type = CONFIG_SELECTION | CONFIG_RUNTIME ,
395488 .selection =
396489 {
397490 {
@@ -408,13 +501,13 @@ static const device_config_t fluidsynth_config[] = {
408501 {
409502 .name = "reverb" ,
410503 .description = "Reverb" ,
411- .type = CONFIG_BINARY ,
504+ .type = CONFIG_BINARY | CONFIG_RUNTIME ,
412505 .default_int = 1
413506 },
414507 {
415508 .name = "reverb_room_size" ,
416509 .description = "Reverb Room Size" ,
417- .type = CONFIG_SPINNER ,
510+ .type = CONFIG_SPINNER | CONFIG_RUNTIME ,
418511 .spinner =
419512 {
420513 .min = 0 ,
@@ -425,7 +518,7 @@ static const device_config_t fluidsynth_config[] = {
425518 {
426519 .name = "reverb_damping" ,
427520 .description = "Reverb Damping" ,
428- .type = CONFIG_SPINNER ,
521+ .type = CONFIG_SPINNER | CONFIG_RUNTIME ,
429522 .spinner =
430523 {
431524 .min = 0 ,
@@ -436,7 +529,7 @@ static const device_config_t fluidsynth_config[] = {
436529 {
437530 .name = "reverb_width" ,
438531 .description = "Reverb Width" ,
439- .type = CONFIG_SPINNER ,
532+ .type = CONFIG_SPINNER | CONFIG_RUNTIME ,
440533 .spinner =
441534 {
442535 .min = 0 ,
@@ -447,7 +540,7 @@ static const device_config_t fluidsynth_config[] = {
447540 {
448541 .name = "reverb_level" ,
449542 .description = "Reverb Level" ,
450- .type = CONFIG_SPINNER ,
543+ .type = CONFIG_SPINNER | CONFIG_RUNTIME ,
451544 .spinner =
452545 {
453546 .min = 0 ,
@@ -458,7 +551,7 @@ static const device_config_t fluidsynth_config[] = {
458551 {
459552 .name = "interpolation" ,
460553 .description = "Interpolation Method" ,
461- .type = CONFIG_SELECTION ,
554+ .type = CONFIG_SELECTION | CONFIG_RUNTIME ,
462555 .selection =
463556 {
464557 {
@@ -487,14 +580,15 @@ static const device_config_t fluidsynth_config[] = {
487580const device_t fluidsynth_device = {
488581 .name = "FluidSynth" ,
489582 .internal_name = "fluidsynth" ,
490- .flags = 0 ,
583+ .flags = DEVICE_RTCONFIG ,
491584 .local = 0 ,
492585 .init = fluidsynth_init ,
493586 .close = fluidsynth_close ,
494587 .reset = NULL ,
495588 { .available = fluidsynth_available },
496589 .speed_changed = NULL ,
497590 .force_redraw = NULL ,
591+ .reload_config = fluidsynth_reload_config ,
498592 .config = fluidsynth_config
499593};
500594
0 commit comments