-
Notifications
You must be signed in to change notification settings - Fork 263
/
Copy pathfluid_synth.c
8464 lines (7275 loc) · 282 KB
/
fluid_synth.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* FluidSynth - A Software Synthesizer
*
* Copyright (C) 2003 Peter Hanappe and others.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
*/
#include "fluid_synth.h"
#include "fluid_sys.h"
#include "fluid_chan.h"
#include "fluid_tuning.h"
#include "fluid_settings.h"
#include "fluid_sfont.h"
#include "fluid_defsfont.h"
#include "fluid_instpatch.h"
#ifdef TRAP_ON_FPE
#define _GNU_SOURCE
#include <fenv.h>
/* seems to not be declared in fenv.h */
extern int feenableexcept(int excepts);
#endif
#define FLUID_API_RETURN(return_value) \
do { fluid_synth_api_exit(synth); \
return return_value; } while (0)
#define FLUID_API_RETURN_IF_CHAN_DISABLED(return_value) \
do { if (FLUID_LIKELY(synth->channel[chan]->mode & FLUID_CHANNEL_ENABLED)) \
{} \
else \
{ FLUID_API_RETURN(return_value); } \
} while (0)
#define FLUID_API_ENTRY_CHAN(fail_value) \
fluid_return_val_if_fail (synth != NULL, fail_value); \
fluid_return_val_if_fail (chan >= 0, fail_value); \
fluid_synth_api_enter(synth); \
if (chan >= synth->midi_channels) { \
FLUID_API_RETURN(fail_value); \
} \
static void fluid_synth_init(void);
static void fluid_synth_api_enter(fluid_synth_t *synth);
static void fluid_synth_api_exit(fluid_synth_t *synth);
static int fluid_synth_noteon_LOCAL(fluid_synth_t *synth, int chan, int key,
int vel);
static int fluid_synth_noteoff_LOCAL(fluid_synth_t *synth, int chan, int key);
static int fluid_synth_cc_LOCAL(fluid_synth_t *synth, int channum, int num);
static int fluid_synth_sysex_midi_tuning(fluid_synth_t *synth, const char *data,
int len, char *response,
int *response_len, int avail_response,
int *handled, int dryrun);
static int fluid_synth_sysex_gs_dt1(fluid_synth_t *synth, const char *data,
int len, char *response,
int *response_len, int avail_response,
int *handled, int dryrun);
static int fluid_synth_sysex_xg(fluid_synth_t *synth, const char *data,
int len, char *response,
int *response_len, int avail_response,
int *handled, int dryrun);
int fluid_synth_all_notes_off_LOCAL(fluid_synth_t *synth, int chan);
static int fluid_synth_all_sounds_off_LOCAL(fluid_synth_t *synth, int chan);
static int fluid_synth_system_reset_LOCAL(fluid_synth_t *synth);
static int fluid_synth_modulate_voices_LOCAL(fluid_synth_t *synth, int chan,
int is_cc, int ctrl);
static int fluid_synth_modulate_voices_all_LOCAL(fluid_synth_t *synth, int chan);
static int fluid_synth_update_channel_pressure_LOCAL(fluid_synth_t *synth, int channum);
static int fluid_synth_update_key_pressure_LOCAL(fluid_synth_t *synth, int chan, int key);
static int fluid_synth_update_pitch_bend_LOCAL(fluid_synth_t *synth, int chan);
static int fluid_synth_update_pitch_wheel_sens_LOCAL(fluid_synth_t *synth, int chan);
static int fluid_synth_set_preset(fluid_synth_t *synth, int chan,
fluid_preset_t *preset);
static int fluid_synth_reverb_get_param(fluid_synth_t *synth, int fx_group,
int param, double *value);
static int fluid_synth_chorus_get_param(fluid_synth_t *synth, int fx_group,
int param, double *value);
static fluid_preset_t *
fluid_synth_get_preset(fluid_synth_t *synth, int sfontnum,
int banknum, int prognum);
static fluid_preset_t *
fluid_synth_get_preset_by_sfont_name(fluid_synth_t *synth, const char *sfontname,
int banknum, int prognum);
static void fluid_synth_update_presets(fluid_synth_t *synth);
static void fluid_synth_update_gain_LOCAL(fluid_synth_t *synth);
static int fluid_synth_update_polyphony_LOCAL(fluid_synth_t *synth, int new_polyphony);
static void init_dither(void);
static FLUID_INLINE int16_t round_clip_to_i16(float x);
static int fluid_synth_render_blocks(fluid_synth_t *synth, int blockcount);
static fluid_voice_t *fluid_synth_free_voice_by_kill_LOCAL(fluid_synth_t *synth);
static void fluid_synth_kill_by_exclusive_class_LOCAL(fluid_synth_t *synth,
fluid_voice_t *new_voice);
static int fluid_synth_sfunload_callback(void *data, unsigned int msec);
static fluid_tuning_t *fluid_synth_get_tuning(fluid_synth_t *synth,
int bank, int prog);
static int fluid_synth_replace_tuning_LOCK(fluid_synth_t *synth,
fluid_tuning_t *tuning,
int bank, int prog, int apply);
static void fluid_synth_replace_tuning_LOCAL(fluid_synth_t *synth,
fluid_tuning_t *old_tuning,
fluid_tuning_t *new_tuning,
int apply, int unref_new);
static void fluid_synth_update_voice_tuning_LOCAL(fluid_synth_t *synth,
fluid_channel_t *channel);
static int fluid_synth_set_tuning_LOCAL(fluid_synth_t *synth, int chan,
fluid_tuning_t *tuning, int apply);
static void fluid_synth_set_gen_LOCAL(fluid_synth_t *synth, int chan,
int param, float value);
static void fluid_synth_stop_LOCAL(fluid_synth_t *synth, unsigned int id);
static int fluid_synth_set_important_channels(fluid_synth_t *synth, const char *channels);
/* Callback handlers for real-time settings */
static void fluid_synth_handle_gain(void *data, const char *name, double value);
static void fluid_synth_handle_polyphony(void *data, const char *name, int value);
static void fluid_synth_handle_device_id(void *data, const char *name, int value);
static void fluid_synth_handle_overflow(void *data, const char *name, double value);
static void fluid_synth_handle_important_channels(void *data, const char *name,
const char *value);
static void fluid_synth_handle_reverb_chorus_num(void *data, const char *name, double value);
static void fluid_synth_handle_reverb_chorus_int(void *data, const char *name, int value);
static void fluid_synth_reset_basic_channel_LOCAL(fluid_synth_t *synth, int chan, int nbr_chan);
static int fluid_synth_check_next_basic_channel(fluid_synth_t *synth, int basicchan, int mode, int val);
static void fluid_synth_set_basic_channel_LOCAL(fluid_synth_t *synth, int basicchan, int mode, int val);
/***************************************************************
*
* GLOBAL
*/
/* has the synth module been initialized? */
/* fluid_atomic_int_t may be anything, so init with {0} to catch most cases */
static fluid_atomic_int_t fluid_synth_initialized = {0};
/* default modulators
* SF2.01 page 52 ff:
*
* There is a set of predefined default modulators. They have to be
* explicitly overridden by the sound font in order to turn them off.
*/
static fluid_mod_t default_vel2att_mod; /* SF2.01 section 8.4.1 */
/*not static */ fluid_mod_t default_vel2filter_mod; /* SF2.01 section 8.4.2 */
static fluid_mod_t default_at2viblfo_mod; /* SF2.01 section 8.4.3 */
static fluid_mod_t default_mod2viblfo_mod; /* SF2.01 section 8.4.4 */
static fluid_mod_t default_att_mod; /* SF2.01 section 8.4.5 */
static fluid_mod_t default_pan_mod; /* SF2.01 section 8.4.6 */
static fluid_mod_t default_expr_mod; /* SF2.01 section 8.4.7 */
static fluid_mod_t default_reverb_mod; /* SF2.01 section 8.4.8 */
static fluid_mod_t default_chorus_mod; /* SF2.01 section 8.4.9 */
static fluid_mod_t default_pitch_bend_mod; /* SF2.01 section 8.4.10 */
static fluid_mod_t custom_balance_mod; /* Non-standard modulator */
/* custom_breath2att_modulator is not a default modulator specified in SF
it is intended to replace default_vel2att_mod on demand using
API fluid_set_breath_mode() or command shell setbreathmode.
*/
static fluid_mod_t custom_breath2att_mod;
/* reverb presets */
static const fluid_revmodel_presets_t revmodel_preset[] =
{
/* name */ /* roomsize */ /* damp */ /* width */ /* level */
{ "Test 1", 0.2f, 0.0f, 0.5f, 0.9f },
{ "Test 2", 0.4f, 0.2f, 0.5f, 0.8f },
{ "Test 3", 0.6f, 0.4f, 0.5f, 0.7f },
{ "Test 4", 0.8f, 0.7f, 0.5f, 0.6f },
{ "Test 5", 0.8f, 1.0f, 0.5f, 0.5f },
};
/***************************************************************
*
* INITIALIZATION & UTILITIES
*/
void fluid_synth_settings(fluid_settings_t *settings)
{
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_num(settings, "synth.reverb.room-size", FLUID_REVERB_DEFAULT_ROOMSIZE, 0.0, 1.0, 0);
fluid_settings_register_num(settings, "synth.reverb.damp", FLUID_REVERB_DEFAULT_DAMP, 0.0, 1.0, 0);
fluid_settings_register_num(settings, "synth.reverb.width", FLUID_REVERB_DEFAULT_WIDTH, 0.0, 100.0, 0);
fluid_settings_register_num(settings, "synth.reverb.level", FLUID_REVERB_DEFAULT_LEVEL, 0.0, 1.0, 0);
fluid_settings_register_int(settings, "synth.chorus.active", 1, 0, 1, FLUID_HINT_TOGGLED);
fluid_settings_register_int(settings, "synth.chorus.nr", FLUID_CHORUS_DEFAULT_N, 0, 99, 0);
fluid_settings_register_num(settings, "synth.chorus.level", FLUID_CHORUS_DEFAULT_LEVEL, 0.0, 10.0, 0);
fluid_settings_register_num(settings, "synth.chorus.speed", FLUID_CHORUS_DEFAULT_SPEED, 0.1, 5.0, 0);
fluid_settings_register_num(settings, "synth.chorus.depth", FLUID_CHORUS_DEFAULT_DEPTH, 0.0, 256.0, 0);
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);
#endif
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.6, 0.0, 10.0, 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_int(settings, "synth.effects-groups", 1, 1, 128, 0);
fluid_settings_register_num(settings, "synth.sample-rate", 44100.0, 8000.0, 96000.0, 0);
fluid_settings_register_int(settings, "synth.device-id", 0, 0, 127, 0);
#ifdef ENABLE_MIXER_THREADS
fluid_settings_register_int(settings, "synth.cpu-cores", 1, 1, 256, 0);
#else
fluid_settings_register_int(settings, "synth.cpu-cores", 1, 1, 1, 0);
#endif
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);
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_num(settings, "synth.overflow.important", 5000, -50000, 50000, 0);
fluid_settings_register_str(settings, "synth.overflow.important-channels", "", 0);
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_int(settings, "synth.dynamic-sample-loading", 0, 0, 1, FLUID_HINT_TOGGLED);
}
/**
* Get FluidSynth runtime version.
* @param major Location to store major number
* @param minor Location to store minor number
* @param micro Location to store micro number
*/
void fluid_version(int *major, int *minor, int *micro)
{
*major = FLUIDSYNTH_VERSION_MAJOR;
*minor = FLUIDSYNTH_VERSION_MINOR;
*micro = FLUIDSYNTH_VERSION_MICRO;
}
/**
* Get FluidSynth runtime version as a string.
* @return FluidSynth version string, which is internal and should not be
* modified or freed.
*/
char *
fluid_version_str(void)
{
return FLUIDSYNTH_VERSION;
}
/*
* void fluid_synth_init
*
* Does all the initialization for this module.
*/
static void
fluid_synth_init(void)
{
#ifdef TRAP_ON_FPE
#if !defined(__GLIBC__) && defined(__linux__)
#warning "Trap on FPE is only supported when using glibc!"
#else
/* Turn on floating point exception traps */
feenableexcept(FE_DIVBYZERO | FE_OVERFLOW | FE_INVALID);
#endif
#endif
init_dither();
/* custom_breath2att_mod is not a default modulator specified in SF2.01.
it is intended to replace default_vel2att_mod on demand using
API fluid_set_breath_mode() or command shell setbreathmode.
*/
fluid_mod_set_source1(&custom_breath2att_mod, /* The modulator we are programming here */
BREATH_MSB, /* Source. breath MSB corresponds to 2. */
FLUID_MOD_CC /* MIDI continuous controller */
| FLUID_MOD_CONCAVE /* Curve shape. Corresponds to 'type=1' */
| FLUID_MOD_UNIPOLAR /* Polarity. Corresponds to 'P=0' */
| FLUID_MOD_NEGATIVE /* Direction. Corresponds to 'D=1' */
);
fluid_mod_set_source2(&custom_breath2att_mod, 0, 0); /* No 2nd source */
fluid_mod_set_dest(&custom_breath2att_mod, GEN_ATTENUATION); /* Target: Initial attenuation */
fluid_mod_set_amount(&custom_breath2att_mod, FLUID_PEAK_ATTENUATION); /* Modulation amount: 960 */
/* SF2.01 page 53 section 8.4.1: MIDI Note-On Velocity to Initial Attenuation */
fluid_mod_set_source1(&default_vel2att_mod, /* The modulator we are programming here */
FLUID_MOD_VELOCITY, /* Source. VELOCITY corresponds to 'index=2'. */
FLUID_MOD_GC /* Not a MIDI continuous controller */
| FLUID_MOD_CONCAVE /* Curve shape. Corresponds to 'type=1' */
| FLUID_MOD_UNIPOLAR /* Polarity. Corresponds to 'P=0' */
| FLUID_MOD_NEGATIVE /* Direction. Corresponds to 'D=1' */
);
fluid_mod_set_source2(&default_vel2att_mod, 0, 0); /* No 2nd source */
fluid_mod_set_dest(&default_vel2att_mod, GEN_ATTENUATION); /* Target: Initial attenuation */
fluid_mod_set_amount(&default_vel2att_mod, FLUID_PEAK_ATTENUATION); /* Modulation amount: 960 */
/* SF2.01 page 53 section 8.4.2: MIDI Note-On Velocity to Filter Cutoff
* Have to make a design decision here. The specs don't make any sense this way or another.
* One sound font, 'Kingston Piano', which has been praised for its quality, tries to
* override this modulator with an amount of 0 and positive polarity (instead of what
* the specs say, D=1) for the secondary source.
* So if we change the polarity to 'positive', one of the best free sound fonts works...
*/
fluid_mod_set_source1(&default_vel2filter_mod, FLUID_MOD_VELOCITY, /* Index=2 */
FLUID_MOD_GC /* CC=0 */
| FLUID_MOD_LINEAR /* type=0 */
| FLUID_MOD_UNIPOLAR /* P=0 */
| FLUID_MOD_NEGATIVE /* D=1 */
);
fluid_mod_set_source2(&default_vel2filter_mod, FLUID_MOD_VELOCITY, /* Index=2 */
FLUID_MOD_GC /* CC=0 */
| FLUID_MOD_SWITCH /* type=3 */
| FLUID_MOD_UNIPOLAR /* P=0 */
// do not remove | FLUID_MOD_NEGATIVE /* D=1 */
| FLUID_MOD_POSITIVE /* D=0 */
);
fluid_mod_set_dest(&default_vel2filter_mod, GEN_FILTERFC); /* Target: Initial filter cutoff */
fluid_mod_set_amount(&default_vel2filter_mod, -2400);
/* SF2.01 page 53 section 8.4.3: MIDI Channel pressure to Vibrato LFO pitch depth */
fluid_mod_set_source1(&default_at2viblfo_mod, FLUID_MOD_CHANNELPRESSURE, /* Index=13 */
FLUID_MOD_GC /* CC=0 */
| FLUID_MOD_LINEAR /* type=0 */
| FLUID_MOD_UNIPOLAR /* P=0 */
| FLUID_MOD_POSITIVE /* D=0 */
);
fluid_mod_set_source2(&default_at2viblfo_mod, 0, 0); /* no second source */
fluid_mod_set_dest(&default_at2viblfo_mod, GEN_VIBLFOTOPITCH); /* Target: Vib. LFO => pitch */
fluid_mod_set_amount(&default_at2viblfo_mod, 50);
/* SF2.01 page 53 section 8.4.4: Mod wheel (Controller 1) to Vibrato LFO pitch depth */
fluid_mod_set_source1(&default_mod2viblfo_mod, MODULATION_MSB, /* Index=1 */
FLUID_MOD_CC /* CC=1 */
| FLUID_MOD_LINEAR /* type=0 */
| FLUID_MOD_UNIPOLAR /* P=0 */
| FLUID_MOD_POSITIVE /* D=0 */
);
fluid_mod_set_source2(&default_mod2viblfo_mod, 0, 0); /* no second source */
fluid_mod_set_dest(&default_mod2viblfo_mod, GEN_VIBLFOTOPITCH); /* Target: Vib. LFO => pitch */
fluid_mod_set_amount(&default_mod2viblfo_mod, 50);
/* SF2.01 page 55 section 8.4.5: MIDI continuous controller 7 to initial attenuation*/
fluid_mod_set_source1(&default_att_mod, VOLUME_MSB, /* index=7 */
FLUID_MOD_CC /* CC=1 */
| FLUID_MOD_CONCAVE /* type=1 */
| FLUID_MOD_UNIPOLAR /* P=0 */
| FLUID_MOD_NEGATIVE /* D=1 */
);
fluid_mod_set_source2(&default_att_mod, 0, 0); /* No second source */
fluid_mod_set_dest(&default_att_mod, GEN_ATTENUATION); /* Target: Initial attenuation */
fluid_mod_set_amount(&default_att_mod, FLUID_PEAK_ATTENUATION); /* Amount: 960 */
/* SF2.01 page 55 section 8.4.6 MIDI continuous controller 10 to Pan Position */
fluid_mod_set_source1(&default_pan_mod, PAN_MSB, /* index=10 */
FLUID_MOD_CC /* CC=1 */
| FLUID_MOD_LINEAR /* type=0 */
| FLUID_MOD_BIPOLAR /* P=1 */
| FLUID_MOD_POSITIVE /* D=0 */
);
fluid_mod_set_source2(&default_pan_mod, 0, 0); /* No second source */
fluid_mod_set_dest(&default_pan_mod, GEN_PAN); /* Target: pan */
/* Amount: 500. The SF specs $8.4.6, p. 55 says: "Amount = 1000
tenths of a percent". The center value (64) corresponds to 50%,
so it follows that amount = 50% x 1000/% = 500. */
fluid_mod_set_amount(&default_pan_mod, 500.0);
/* SF2.01 page 55 section 8.4.7: MIDI continuous controller 11 to initial attenuation*/
fluid_mod_set_source1(&default_expr_mod, EXPRESSION_MSB, /* index=11 */
FLUID_MOD_CC /* CC=1 */
| FLUID_MOD_CONCAVE /* type=1 */
| FLUID_MOD_UNIPOLAR /* P=0 */
| FLUID_MOD_NEGATIVE /* D=1 */
);
fluid_mod_set_source2(&default_expr_mod, 0, 0); /* No second source */
fluid_mod_set_dest(&default_expr_mod, GEN_ATTENUATION); /* Target: Initial attenuation */
fluid_mod_set_amount(&default_expr_mod, FLUID_PEAK_ATTENUATION); /* Amount: 960 */
/* SF2.01 page 55 section 8.4.8: MIDI continuous controller 91 to Reverb send */
fluid_mod_set_source1(&default_reverb_mod, EFFECTS_DEPTH1, /* index=91 */
FLUID_MOD_CC /* CC=1 */
| FLUID_MOD_LINEAR /* type=0 */
| FLUID_MOD_UNIPOLAR /* P=0 */
| FLUID_MOD_POSITIVE /* D=0 */
);
fluid_mod_set_source2(&default_reverb_mod, 0, 0); /* No second source */
fluid_mod_set_dest(&default_reverb_mod, GEN_REVERBSEND); /* Target: Reverb send */
fluid_mod_set_amount(&default_reverb_mod, 200); /* Amount: 200 ('tenths of a percent') */
/* SF2.01 page 55 section 8.4.9: MIDI continuous controller 93 to Chorus send */
fluid_mod_set_source1(&default_chorus_mod, EFFECTS_DEPTH3, /* index=93 */
FLUID_MOD_CC /* CC=1 */
| FLUID_MOD_LINEAR /* type=0 */
| FLUID_MOD_UNIPOLAR /* P=0 */
| FLUID_MOD_POSITIVE /* D=0 */
);
fluid_mod_set_source2(&default_chorus_mod, 0, 0); /* No second source */
fluid_mod_set_dest(&default_chorus_mod, GEN_CHORUSSEND); /* Target: Chorus */
fluid_mod_set_amount(&default_chorus_mod, 200); /* Amount: 200 ('tenths of a percent') */
/* SF2.01 page 57 section 8.4.10 MIDI Pitch Wheel to Initial Pitch ... */
/* Initial Pitch is not a "standard" generator, because it isn't mentioned in the
list of generators in the SF2 specifications. That's why destination Initial Pitch
is replaced here by fine tune generator.
*/
fluid_mod_set_source1(&default_pitch_bend_mod, FLUID_MOD_PITCHWHEEL, /* Index=14 */
FLUID_MOD_GC /* CC =0 */
| FLUID_MOD_LINEAR /* type=0 */
| FLUID_MOD_BIPOLAR /* P=1 */
| FLUID_MOD_POSITIVE /* D=0 */
);
fluid_mod_set_source2(&default_pitch_bend_mod, FLUID_MOD_PITCHWHEELSENS, /* Index = 16 */
FLUID_MOD_GC /* CC=0 */
| FLUID_MOD_LINEAR /* type=0 */
| FLUID_MOD_UNIPOLAR /* P=0 */
| FLUID_MOD_POSITIVE /* D=0 */
);
/* Also see the comment in gen.h about GEN_PITCH */
fluid_mod_set_dest(&default_pitch_bend_mod, GEN_FINETUNE); /* Destination: Fine Tune */
fluid_mod_set_amount(&default_pitch_bend_mod, 12700.0); /* Amount: 12700 cents */
/* Non-standard MIDI continuous controller 8 to channel stereo balance */
fluid_mod_set_source1(&custom_balance_mod, BALANCE_MSB, /* Index=8 */
FLUID_MOD_CC /* CC=1 */
| FLUID_MOD_CONCAVE /* type=1 */
| FLUID_MOD_BIPOLAR /* P=1 */
| FLUID_MOD_POSITIVE /* D=0 */
);
fluid_mod_set_source2(&custom_balance_mod, 0, 0);
fluid_mod_set_dest(&custom_balance_mod, GEN_CUSTOM_BALANCE); /* Destination: stereo balance */
/* Amount: 96 dB of attenuation (on the opposite channel) */
fluid_mod_set_amount(&custom_balance_mod, FLUID_PEAK_ATTENUATION); /* Amount: 960 */
#if defined(LIBINSTPATCH_SUPPORT)
/* defer libinstpatch init to fluid_instpatch.c to avoid #include "libinstpatch.h" */
if(!fluid_instpatch_supports_multi_init())
{
fluid_instpatch_init();
}
#endif
}
static FLUID_INLINE unsigned int fluid_synth_get_ticks(fluid_synth_t *synth)
{
return fluid_atomic_int_get(&synth->ticks_since_start);
}
static FLUID_INLINE void fluid_synth_add_ticks(fluid_synth_t *synth, int val)
{
fluid_atomic_int_add(&synth->ticks_since_start, val);
}
/***************************************************************
* FLUID SAMPLE TIMERS
* Timers that use written audio data as timing reference
*/
struct _fluid_sample_timer_t
{
fluid_sample_timer_t *next; /* Single linked list of timers */
unsigned long starttick;
fluid_timer_callback_t callback;
void *data;
int isfinished;
};
/*
* fluid_sample_timer_process - called when synth->ticks is updated
*/
static void fluid_sample_timer_process(fluid_synth_t *synth)
{
fluid_sample_timer_t *st;
long msec;
int cont;
unsigned int ticks = fluid_synth_get_ticks(synth);
for(st = synth->sample_timers; st; st = st->next)
{
if(st->isfinished)
{
continue;
}
msec = (long)(1000.0 * ((double)(ticks - st->starttick)) / synth->sample_rate);
cont = (*st->callback)(st->data, msec);
if(cont == 0)
{
st->isfinished = 1;
}
}
}
fluid_sample_timer_t *new_fluid_sample_timer(fluid_synth_t *synth, fluid_timer_callback_t callback, void *data)
{
fluid_sample_timer_t *result = FLUID_NEW(fluid_sample_timer_t);
if(result == NULL)
{
FLUID_LOG(FLUID_ERR, "Out of memory");
return NULL;
}
fluid_sample_timer_reset(synth, result);
result->data = data;
result->callback = callback;
result->next = synth->sample_timers;
synth->sample_timers = result;
return result;
}
void delete_fluid_sample_timer(fluid_synth_t *synth, fluid_sample_timer_t *timer)
{
fluid_sample_timer_t **ptr;
fluid_return_if_fail(synth != NULL);
fluid_return_if_fail(timer != NULL);
ptr = &synth->sample_timers;
while(*ptr)
{
if(*ptr == timer)
{
*ptr = timer->next;
FLUID_FREE(timer);
return;
}
ptr = &((*ptr)->next);
}
}
void fluid_sample_timer_reset(fluid_synth_t *synth, fluid_sample_timer_t *timer)
{
timer->starttick = fluid_synth_get_ticks(synth);
timer->isfinished = 0;
}
/***************************************************************
*
* FLUID SYNTH
*/
static FLUID_INLINE void
fluid_synth_update_mixer(fluid_synth_t *synth, fluid_rvoice_function_t method, int intparam,
fluid_real_t realparam)
{
fluid_return_if_fail(synth != NULL && synth->eventhandler != NULL);
fluid_return_if_fail(synth->eventhandler->mixer != NULL);
fluid_rvoice_eventhandler_push_int_real(synth->eventhandler, method,
synth->eventhandler->mixer,
intparam, realparam);
}
static FLUID_INLINE unsigned int fluid_synth_get_min_note_length_LOCAL(fluid_synth_t *synth)
{
int i;
fluid_settings_getint(synth->settings, "synth.min-note-length", &i);
return (unsigned int)(i * synth->sample_rate / 1000.0f);
}
/**
* Create new FluidSynth instance.
* @param settings Configuration parameters to use (used directly).
* @return New FluidSynth instance or NULL on error
*
* @note The @p settings parameter is used directly, but the synth does not take ownership of it.
* Hence, the caller is responsible for freeing it, when no longer needed.
* Further note that you may modify FluidSettings of the
* @p settings instance. However, only those FluidSettings marked as 'realtime' will
* affect the synth immediately. See the \ref fluidsettings for more details.
*
* @warning The @p settings object should only be used by a single synth at a time. I.e. creating
* multiple synth instances with a single @p settings object causes undefined behavior. Once the
* "single synth" has been deleted, you may use the @p settings object again for another synth.
*/
fluid_synth_t *
new_fluid_synth(fluid_settings_t *settings)
{
fluid_synth_t *synth;
fluid_sfloader_t *loader;
char *important_channels;
int i, prio_level = 0;
int with_ladspa = 0;
double sample_rate_min, sample_rate_max;
/* initialize all the conversion tables and other stuff */
if(fluid_atomic_int_compare_and_exchange(&fluid_synth_initialized, 0, 1))
{
fluid_synth_init();
}
/* allocate a new synthesizer object */
synth = FLUID_NEW(fluid_synth_t);
if(synth == NULL)
{
FLUID_LOG(FLUID_ERR, "Out of memory");
return NULL;
}
FLUID_MEMSET(synth, 0, sizeof(fluid_synth_t));
#if defined(LIBINSTPATCH_SUPPORT)
if(fluid_instpatch_supports_multi_init())
{
fluid_instpatch_init();
}
#endif
fluid_rec_mutex_init(synth->mutex);
fluid_settings_getint(settings, "synth.threadsafe-api", &synth->use_mutex);
synth->public_api_count = 0;
synth->settings = settings;
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.polyphony", &synth->polyphony);
fluid_settings_getnum(settings, "synth.sample-rate", &synth->sample_rate);
fluid_settings_getnum_range(settings, "synth.sample-rate", &sample_rate_min, &sample_rate_max);
fluid_settings_getint(settings, "synth.midi-channels", &synth->midi_channels);
fluid_settings_getint(settings, "synth.audio-channels", &synth->audio_channels);
fluid_settings_getint(settings, "synth.audio-groups", &synth->audio_groups);
fluid_settings_getint(settings, "synth.effects-channels", &synth->effects_channels);
fluid_settings_getint(settings, "synth.effects-groups", &synth->effects_groups);
fluid_settings_getnum_float(settings, "synth.gain", &synth->gain);
fluid_settings_getint(settings, "synth.device-id", &synth->device_id);
fluid_settings_getint(settings, "synth.cpu-cores", &synth->cores);
fluid_settings_getnum_float(settings, "synth.overflow.percussion", &synth->overflow.percussion);
fluid_settings_getnum_float(settings, "synth.overflow.released", &synth->overflow.released);
fluid_settings_getnum_float(settings, "synth.overflow.sustained", &synth->overflow.sustained);
fluid_settings_getnum_float(settings, "synth.overflow.volume", &synth->overflow.volume);
fluid_settings_getnum_float(settings, "synth.overflow.age", &synth->overflow.age);
fluid_settings_getnum_float(settings, "synth.overflow.important", &synth->overflow.important);
/* register the callbacks */
fluid_settings_callback_num(settings, "synth.gain",
fluid_synth_handle_gain, synth);
fluid_settings_callback_int(settings, "synth.polyphony",
fluid_synth_handle_polyphony, synth);
fluid_settings_callback_int(settings, "synth.device-id",
fluid_synth_handle_device_id, synth);
fluid_settings_callback_num(settings, "synth.overflow.percussion",
fluid_synth_handle_overflow, synth);
fluid_settings_callback_num(settings, "synth.overflow.sustained",
fluid_synth_handle_overflow, synth);
fluid_settings_callback_num(settings, "synth.overflow.released",
fluid_synth_handle_overflow, synth);
fluid_settings_callback_num(settings, "synth.overflow.age",
fluid_synth_handle_overflow, synth);
fluid_settings_callback_num(settings, "synth.overflow.volume",
fluid_synth_handle_overflow, synth);
fluid_settings_callback_num(settings, "synth.overflow.important",
fluid_synth_handle_overflow, synth);
fluid_settings_callback_str(settings, "synth.overflow.important-channels",
fluid_synth_handle_important_channels, synth);
fluid_settings_callback_num(settings, "synth.reverb.room-size",
fluid_synth_handle_reverb_chorus_num, synth);
fluid_settings_callback_num(settings, "synth.reverb.damp",
fluid_synth_handle_reverb_chorus_num, synth);
fluid_settings_callback_num(settings, "synth.reverb.width",
fluid_synth_handle_reverb_chorus_num, synth);
fluid_settings_callback_num(settings, "synth.reverb.level",
fluid_synth_handle_reverb_chorus_num, synth);
fluid_settings_callback_int(settings, "synth.reverb.active",
fluid_synth_handle_reverb_chorus_int, synth);
fluid_settings_callback_int(settings, "synth.chorus.active",
fluid_synth_handle_reverb_chorus_int, synth);
fluid_settings_callback_int(settings, "synth.chorus.nr",
fluid_synth_handle_reverb_chorus_int, synth);
fluid_settings_callback_num(settings, "synth.chorus.level",
fluid_synth_handle_reverb_chorus_num, synth);
fluid_settings_callback_num(settings, "synth.chorus.depth",
fluid_synth_handle_reverb_chorus_num, synth);
fluid_settings_callback_num(settings, "synth.chorus.speed",
fluid_synth_handle_reverb_chorus_num, synth);
/* do some basic sanity checking on the settings */
if(synth->midi_channels % 16 != 0)
{
int n = synth->midi_channels / 16;
synth->midi_channels = (n + 1) * 16;
fluid_settings_setint(settings, "synth.midi-channels", synth->midi_channels);
FLUID_LOG(FLUID_WARN, "Requested number of MIDI channels is not a multiple of 16. "
"I'll increase the number of channels to the next multiple.");
}
if(synth->audio_channels < 1)
{
FLUID_LOG(FLUID_WARN, "Requested number of audio channels is smaller than 1. "
"Changing this setting to 1.");
synth->audio_channels = 1;
}
else if(synth->audio_channels > 128)
{
FLUID_LOG(FLUID_WARN, "Requested number of audio channels is too big (%d). "
"Limiting this setting to 128.", synth->audio_channels);
synth->audio_channels = 128;
}
if(synth->audio_groups < 1)
{
FLUID_LOG(FLUID_WARN, "Requested number of audio groups is smaller than 1. "
"Changing this setting to 1.");
synth->audio_groups = 1;
}
else if(synth->audio_groups > 128)
{
FLUID_LOG(FLUID_WARN, "Requested number of audio groups is too big (%d). "
"Limiting this setting to 128.", synth->audio_groups);
synth->audio_groups = 128;
}
if(synth->effects_channels < 2)
{
FLUID_LOG(FLUID_WARN, "Invalid number of effects channels (%d)."
"Setting effects channels to 2.", synth->effects_channels);
synth->effects_channels = 2;
}
/*
number of buffers rendered by the mixer is determined by synth->audio_groups.
audio from MIDI channel is rendered, mapped and mixed in these buffers.
Typically synth->audio_channels is only used by audio driver and should be set
to the same value that synth->audio_groups. In some situation using LADSPA,
it is best to diminish audio-channels so that the driver will be able to pass
the audio to audio devices in the case these devices have a limited number of
audio channels.
audio-channels must not be greater then audio-groups, otherwise these
audio output above audio-groups will not be rendered by the mixeur.
*/
if(synth->audio_channels > synth->audio_groups)
{
synth->audio_channels = synth->audio_groups;
fluid_settings_setint(settings, "synth.audio-channels", synth->audio_channels);
FLUID_LOG(FLUID_WARN, "Requested audio-channels to high. "
"Limiting this setting to audio-groups.");
}
if(fluid_settings_dupstr(settings, "synth.overflow.important-channels",
&important_channels) == FLUID_OK)
{
if(fluid_synth_set_important_channels(synth, important_channels) != FLUID_OK)
{
FLUID_LOG(FLUID_WARN, "Failed to set overflow important channels");
}
FLUID_FREE(important_channels);
}
/* as soon as the synth is created it starts playing. */
synth->state = FLUID_SYNTH_PLAYING;
synth->fromkey_portamento = INVALID_NOTE; /* disable portamento */
fluid_atomic_int_set(&synth->ticks_since_start, 0);
synth->tuning = NULL;
fluid_private_init(synth->tuning_iter);
/* Initialize multi-core variables if multiple cores enabled */
if(synth->cores > 1)
{
fluid_settings_getint(synth->settings, "audio.realtime-prio", &prio_level);
}
/* Allocate event queue for rvoice mixer */
/* In an overflow situation, a new voice takes about 50 spaces in the queue! */
synth->eventhandler = new_fluid_rvoice_eventhandler(synth->polyphony * 64,
synth->polyphony, synth->audio_groups,
synth->effects_channels, synth->effects_groups,
(fluid_real_t)sample_rate_max, synth->sample_rate,
synth->cores - 1, prio_level);
if(synth->eventhandler == NULL)
{
goto error_recovery;
}
/* Setup the list of default modulators.
* Needs to happen after eventhandler has been set up, as fluid_synth_enter_api is called in the process */
synth->default_mod = NULL;
fluid_synth_add_default_mod(synth, &default_vel2att_mod, FLUID_SYNTH_ADD);
fluid_synth_add_default_mod(synth, &default_vel2filter_mod, FLUID_SYNTH_ADD);
fluid_synth_add_default_mod(synth, &default_at2viblfo_mod, FLUID_SYNTH_ADD);
fluid_synth_add_default_mod(synth, &default_mod2viblfo_mod, FLUID_SYNTH_ADD);
fluid_synth_add_default_mod(synth, &default_att_mod, FLUID_SYNTH_ADD);
fluid_synth_add_default_mod(synth, &default_pan_mod, FLUID_SYNTH_ADD);
fluid_synth_add_default_mod(synth, &default_expr_mod, FLUID_SYNTH_ADD);
fluid_synth_add_default_mod(synth, &default_reverb_mod, FLUID_SYNTH_ADD);
fluid_synth_add_default_mod(synth, &default_chorus_mod, FLUID_SYNTH_ADD);
fluid_synth_add_default_mod(synth, &default_pitch_bend_mod, FLUID_SYNTH_ADD);
fluid_synth_add_default_mod(synth, &custom_balance_mod, FLUID_SYNTH_ADD);
/* Create and initialize the Fx unit.*/
fluid_settings_getint(settings, "synth.ladspa.active", &with_ladspa);
if(with_ladspa)
{
#ifdef LADSPA
synth->ladspa_fx = new_fluid_ladspa_fx(synth->sample_rate,
FLUID_MIXER_MAX_BUFFERS_DEFAULT * FLUID_BUFSIZE);
if(synth->ladspa_fx == NULL)
{
FLUID_LOG(FLUID_ERR, "Out of memory");
goto error_recovery;
}
fluid_rvoice_mixer_set_ladspa(synth->eventhandler->mixer, synth->ladspa_fx,
synth->audio_groups);
#else /* LADSPA */
FLUID_LOG(FLUID_WARN, "FluidSynth has not been compiled with LADSPA support");
#endif /* LADSPA */
}
/* allocate and add the dls sfont loader */
#ifdef LIBINSTPATCH_SUPPORT
loader = new_fluid_instpatch_loader(settings);
if(loader == NULL)
{
FLUID_LOG(FLUID_WARN, "Failed to create the instpatch SoundFont loader");
}
else
{
fluid_synth_add_sfloader(synth, loader);
}
#endif
/* allocate and add the default sfont loader */
loader = new_fluid_defsfloader(settings);
if(loader == NULL)
{
FLUID_LOG(FLUID_WARN, "Failed to create the default SoundFont loader");
}
else
{
fluid_synth_add_sfloader(synth, loader);
}
/* allocate all channel objects */
synth->channel = FLUID_ARRAY(fluid_channel_t *, synth->midi_channels);
if(synth->channel == NULL)
{
FLUID_LOG(FLUID_ERR, "Out of memory");
goto error_recovery;
}
FLUID_MEMSET(synth->channel, 0, synth->midi_channels * sizeof(*synth->channel));
for(i = 0; i < synth->midi_channels; i++)
{
synth->channel[i] = new_fluid_channel(synth, i);
if(synth->channel[i] == NULL)
{
goto error_recovery;
}
}
/* allocate all synthesis processes */
synth->nvoice = synth->polyphony;
synth->voice = FLUID_ARRAY(fluid_voice_t *, synth->nvoice);
if(synth->voice == NULL)
{
goto error_recovery;
}
FLUID_MEMSET(synth->voice, 0, synth->nvoice * sizeof(*synth->voice));
for(i = 0; i < synth->nvoice; i++)
{
synth->voice[i] = new_fluid_voice(synth->eventhandler, synth->sample_rate);
if(synth->voice[i] == NULL)
{
goto error_recovery;
}
}
/* sets a default basic channel */
/* Sets one basic channel: basic channel 0, mode 0 (Omni On - Poly) */
/* (i.e all channels are polyphonic) */
/* Must be called after channel objects allocation */
fluid_synth_set_basic_channel_LOCAL(synth, 0, FLUID_CHANNEL_MODE_OMNION_POLY,
synth->midi_channels);
synth->min_note_length_ticks = fluid_synth_get_min_note_length_LOCAL(synth);
fluid_synth_update_mixer(synth, fluid_rvoice_mixer_set_polyphony,
synth->polyphony, 0.0f);
fluid_synth_reverb_on(synth, -1, synth->with_reverb);
fluid_synth_chorus_on(synth, -1, synth->with_chorus);
synth->cur = FLUID_BUFSIZE;
synth->curmax = 0;
synth->dither_index = 0;
{
double values[FLUID_REVERB_PARAM_LAST];
fluid_settings_getnum(settings, "synth.reverb.room-size", &values[FLUID_REVERB_ROOMSIZE]);
fluid_settings_getnum(settings, "synth.reverb.damp", &values[FLUID_REVERB_DAMP]);
fluid_settings_getnum(settings, "synth.reverb.width", &values[FLUID_REVERB_WIDTH]);
fluid_settings_getnum(settings, "synth.reverb.level", &values[FLUID_REVERB_LEVEL]);
fluid_synth_set_reverb_full(synth, -1, FLUID_REVMODEL_SET_ALL, values);
}
{
double values[FLUID_CHORUS_PARAM_LAST];
fluid_settings_getint(settings, "synth.chorus.nr", &i);
values[FLUID_CHORUS_NR] = (double)i;
fluid_settings_getnum(settings, "synth.chorus.level", &values[FLUID_CHORUS_LEVEL]);
fluid_settings_getnum(settings, "synth.chorus.speed", &values[FLUID_CHORUS_SPEED]);
fluid_settings_getnum(settings, "synth.chorus.depth", &values[FLUID_CHORUS_DEPTH]);
values[FLUID_CHORUS_TYPE] = (double)FLUID_CHORUS_DEFAULT_TYPE;
fluid_synth_set_chorus_full(synth, -1, FLUID_CHORUS_SET_ALL, values);
}
synth->bank_select = FLUID_BANK_STYLE_GS;
if(fluid_settings_str_equal(settings, "synth.midi-bank-select", "gm"))
{
synth->bank_select = FLUID_BANK_STYLE_GM;
}
else if(fluid_settings_str_equal(settings, "synth.midi-bank-select", "gs"))
{
synth->bank_select = FLUID_BANK_STYLE_GS;
}
else if(fluid_settings_str_equal(settings, "synth.midi-bank-select", "xg"))
{
synth->bank_select = FLUID_BANK_STYLE_XG;
}
else if(fluid_settings_str_equal(settings, "synth.midi-bank-select", "mma"))
{
synth->bank_select = FLUID_BANK_STYLE_MMA;
}