@@ -150,6 +150,99 @@ fluidsynth_sysex(uint8_t *data, unsigned int len)
150
150
fluid_synth_sysex (d -> synth , (const char * ) data , len , 0 , 0 , 0 , 0 );
151
151
}
152
152
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
+
153
246
void *
154
247
fluidsynth_init (UNUSED (const device_t * info ))
155
248
{
@@ -323,14 +416,14 @@ static const device_config_t fluidsynth_config[] = {
323
416
{
324
417
.name = "sound_font" ,
325
418
.description = "Sound Font" ,
326
- .type = CONFIG_FNAME ,
419
+ .type = CONFIG_FNAME | CONFIG_RUNTIME ,
327
420
.default_string = "" ,
328
421
.file_filter = "SF2 Sound Fonts (*.sf2)|*.sf2"
329
422
},
330
423
{
331
424
.name = "output_gain" ,
332
425
.description = "Output Gain" ,
333
- .type = CONFIG_SPINNER ,
426
+ .type = CONFIG_SPINNER | CONFIG_RUNTIME ,
334
427
.spinner =
335
428
{
336
429
.min = 0 ,
@@ -341,13 +434,13 @@ static const device_config_t fluidsynth_config[] = {
341
434
{
342
435
.name = "chorus" ,
343
436
.description = "Chorus" ,
344
- .type = CONFIG_BINARY ,
437
+ .type = CONFIG_BINARY | CONFIG_RUNTIME ,
345
438
.default_int = 1
346
439
},
347
440
{
348
441
.name = "chorus_voices" ,
349
442
.description = "Chorus Voices" ,
350
- .type = CONFIG_SPINNER ,
443
+ .type = CONFIG_SPINNER | CONFIG_RUNTIME ,
351
444
.spinner =
352
445
{
353
446
.min = 0 ,
@@ -358,7 +451,7 @@ static const device_config_t fluidsynth_config[] = {
358
451
{
359
452
.name = "chorus_level" ,
360
453
.description = "Chorus Level" ,
361
- .type = CONFIG_SPINNER ,
454
+ .type = CONFIG_SPINNER | CONFIG_RUNTIME ,
362
455
.spinner =
363
456
{
364
457
.min = 0 ,
@@ -369,7 +462,7 @@ static const device_config_t fluidsynth_config[] = {
369
462
{
370
463
.name = "chorus_speed" ,
371
464
.description = "Chorus Speed" ,
372
- .type = CONFIG_SPINNER ,
465
+ .type = CONFIG_SPINNER | CONFIG_RUNTIME ,
373
466
.spinner =
374
467
{
375
468
.min = 10 ,
@@ -380,7 +473,7 @@ static const device_config_t fluidsynth_config[] = {
380
473
{
381
474
.name = "chorus_depth" ,
382
475
.description = "Chorus Depth" ,
383
- .type = CONFIG_SPINNER ,
476
+ .type = CONFIG_SPINNER | CONFIG_RUNTIME ,
384
477
.spinner =
385
478
{
386
479
.min = 0 ,
@@ -391,7 +484,7 @@ static const device_config_t fluidsynth_config[] = {
391
484
{
392
485
.name = "chorus_waveform" ,
393
486
.description = "Chorus Waveform" ,
394
- .type = CONFIG_SELECTION ,
487
+ .type = CONFIG_SELECTION | CONFIG_RUNTIME ,
395
488
.selection =
396
489
{
397
490
{
@@ -408,13 +501,13 @@ static const device_config_t fluidsynth_config[] = {
408
501
{
409
502
.name = "reverb" ,
410
503
.description = "Reverb" ,
411
- .type = CONFIG_BINARY ,
504
+ .type = CONFIG_BINARY | CONFIG_RUNTIME ,
412
505
.default_int = 1
413
506
},
414
507
{
415
508
.name = "reverb_room_size" ,
416
509
.description = "Reverb Room Size" ,
417
- .type = CONFIG_SPINNER ,
510
+ .type = CONFIG_SPINNER | CONFIG_RUNTIME ,
418
511
.spinner =
419
512
{
420
513
.min = 0 ,
@@ -425,7 +518,7 @@ static const device_config_t fluidsynth_config[] = {
425
518
{
426
519
.name = "reverb_damping" ,
427
520
.description = "Reverb Damping" ,
428
- .type = CONFIG_SPINNER ,
521
+ .type = CONFIG_SPINNER | CONFIG_RUNTIME ,
429
522
.spinner =
430
523
{
431
524
.min = 0 ,
@@ -436,7 +529,7 @@ static const device_config_t fluidsynth_config[] = {
436
529
{
437
530
.name = "reverb_width" ,
438
531
.description = "Reverb Width" ,
439
- .type = CONFIG_SPINNER ,
532
+ .type = CONFIG_SPINNER | CONFIG_RUNTIME ,
440
533
.spinner =
441
534
{
442
535
.min = 0 ,
@@ -447,7 +540,7 @@ static const device_config_t fluidsynth_config[] = {
447
540
{
448
541
.name = "reverb_level" ,
449
542
.description = "Reverb Level" ,
450
- .type = CONFIG_SPINNER ,
543
+ .type = CONFIG_SPINNER | CONFIG_RUNTIME ,
451
544
.spinner =
452
545
{
453
546
.min = 0 ,
@@ -458,7 +551,7 @@ static const device_config_t fluidsynth_config[] = {
458
551
{
459
552
.name = "interpolation" ,
460
553
.description = "Interpolation Method" ,
461
- .type = CONFIG_SELECTION ,
554
+ .type = CONFIG_SELECTION | CONFIG_RUNTIME ,
462
555
.selection =
463
556
{
464
557
{
@@ -487,14 +580,15 @@ static const device_config_t fluidsynth_config[] = {
487
580
const device_t fluidsynth_device = {
488
581
.name = "FluidSynth" ,
489
582
.internal_name = "fluidsynth" ,
490
- .flags = 0 ,
583
+ .flags = DEVICE_RTCONFIG ,
491
584
.local = 0 ,
492
585
.init = fluidsynth_init ,
493
586
.close = fluidsynth_close ,
494
587
.reset = NULL ,
495
588
{ .available = fluidsynth_available },
496
589
.speed_changed = NULL ,
497
590
.force_redraw = NULL ,
591
+ .reload_config = fluidsynth_reload_config ,
498
592
.config = fluidsynth_config
499
593
};
500
594
0 commit comments