mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2025-04-07 16:21:18 +00:00
Merge pull request #385 from FluidSynth/issue49
Add reverb and chorus settings
This commit is contained in:
commit
fcc69471d6
11 changed files with 321 additions and 41 deletions
|
@ -821,8 +821,8 @@ fluidmax_chorus(t_object *o, Symbol *s, short ac, Atom *at)
|
|||
}
|
||||
else if(ftmax_is_number(at))
|
||||
{
|
||||
double speed = fluid_synth_get_chorus_speed_Hz(self->synth);
|
||||
double depth = fluid_synth_get_chorus_depth_ms(self->synth);
|
||||
double speed = fluid_synth_get_chorus_speed(self->synth);
|
||||
double depth = fluid_synth_get_chorus_depth(self->synth);
|
||||
int type = fluid_synth_get_chorus_type(self->synth);
|
||||
int nr = fluid_synth_get_chorus_nr(self->synth);
|
||||
|
||||
|
@ -1267,8 +1267,8 @@ fluidmax_print(t_object *o, Symbol *s, short ac, Atom *at)
|
|||
if(self->chorus != 0)
|
||||
{
|
||||
double level = fluid_synth_get_chorus_level(self->synth);
|
||||
double speed = fluid_synth_get_chorus_speed_Hz(self->synth);
|
||||
double depth = fluid_synth_get_chorus_depth_ms(self->synth);
|
||||
double speed = fluid_synth_get_chorus_speed(self->synth);
|
||||
double depth = fluid_synth_get_chorus_depth(self->synth);
|
||||
int type = fluid_synth_get_chorus_type(self->synth);
|
||||
int nr = fluid_synth_get_chorus_nr(self->synth);
|
||||
|
||||
|
@ -1477,8 +1477,8 @@ fluidmax_info(t_object *o, Symbol *s, short ac, Atom *at)
|
|||
if(self->chorus != 0)
|
||||
{
|
||||
double level = fluid_synth_get_chorus_level(self->synth);
|
||||
double speed = fluid_synth_get_chorus_speed_Hz(self->synth);
|
||||
double depth = fluid_synth_get_chorus_depth_ms(self->synth);
|
||||
double speed = fluid_synth_get_chorus_speed(self->synth);
|
||||
double depth = fluid_synth_get_chorus_depth(self->synth);
|
||||
int type = fluid_synth_get_chorus_type(self->synth);
|
||||
int nr = fluid_synth_get_chorus_nr(self->synth);
|
||||
ftmax_atom_t a[5];
|
||||
|
|
|
@ -42,6 +42,42 @@ Developers: Settings can be deprecated by adding: <deprecated>SOME TEXT</depreca
|
|||
<desc>
|
||||
When set to 1 (TRUE) the chorus effects module is activated. Otherwise, no chorus will be added to the output signal. Note that the amount of signal sent to the chorus module depends on the "chorus send" generator defined in the SoundFont.</desc>
|
||||
</setting>
|
||||
<setting>
|
||||
<name>chorus.depth</name>
|
||||
<type>num</type>
|
||||
<def>8</def>
|
||||
<min>0</min>
|
||||
<max>21</max>
|
||||
<desc>
|
||||
Specifies the modulation depth of the chorus.</desc>
|
||||
</setting>
|
||||
<setting>
|
||||
<name>chorus.level</name>
|
||||
<type>num</type>
|
||||
<def>2</def>
|
||||
<min>0</min>
|
||||
<max>10</max>
|
||||
<desc>
|
||||
Specifies the output amplitude of the chorus signal.</desc>
|
||||
</setting>
|
||||
<setting>
|
||||
<name>chorus.nr</name>
|
||||
<type>int</type>
|
||||
<def>3</def>
|
||||
<min>0</min>
|
||||
<max>99</max>
|
||||
<desc>
|
||||
Sets the voice count of the chorus.</desc>
|
||||
</setting>
|
||||
<setting>
|
||||
<name>chorus.speed</name>
|
||||
<type>num</type>
|
||||
<def>0.3</def>
|
||||
<min>0.29</min>
|
||||
<max>5</max>
|
||||
<desc>
|
||||
Sets the modulation speed in Hz.</desc>
|
||||
</setting>
|
||||
<setting>
|
||||
<name>cpu-cores</name>
|
||||
<type>int</type>
|
||||
|
@ -247,6 +283,42 @@ Developers: Settings can be deprecated by adding: <deprecated>SOME TEXT</depreca
|
|||
When set to 1 (TRUE) the reverb effects module is activated. Otherwise, no reverb will be added to the output signal. Note that the amount of signal sent to the reverb module depends on the "reverb send" generator defined in the SoundFont.
|
||||
</desc>
|
||||
</setting>
|
||||
<setting>
|
||||
<name>reverb.damp</name>
|
||||
<type>num</type>
|
||||
<def>0</def>
|
||||
<min>0</min>
|
||||
<max>1</max>
|
||||
<desc>
|
||||
Sets the amount of reverb damping.</desc>
|
||||
</setting>
|
||||
<setting>
|
||||
<name>reverb.level</name>
|
||||
<type>num</type>
|
||||
<def>0.9</def>
|
||||
<min>0</min>
|
||||
<max>1</max>
|
||||
<desc>
|
||||
Sets the reverb output amplitude.</desc>
|
||||
</setting>
|
||||
<setting>
|
||||
<name>reverb.room-size</name>
|
||||
<type>num</type>
|
||||
<def>0.2</def>
|
||||
<min>0</min>
|
||||
<max>1</max>
|
||||
<desc>
|
||||
Sets the room size (i.e. amount of wet) reverb.</desc>
|
||||
</setting>
|
||||
<setting>
|
||||
<name>reverb.width</name>
|
||||
<type>num</type>
|
||||
<def>0.5</def>
|
||||
<min>0</min>
|
||||
<max>100</max>
|
||||
<desc>
|
||||
Sets the stereo spread of the reverb signal.</desc>
|
||||
</setting>
|
||||
<setting>
|
||||
<name>sample-rate</name>
|
||||
<type>num</type>
|
||||
|
|
|
@ -108,6 +108,7 @@ Changes in FluidSynth 2.0.0 concerning developers:
|
|||
- reverb: roomsize is now limited to an upper threshold of 1.0 to avoid exponential volume increase
|
||||
- use unique device names for the "audio.portaudio.device" setting
|
||||
- rename fluid_mod_new() and fluid_mod_delete() to match naming conventions: new_fluid_mod() and delete_fluid_mod()
|
||||
- rename chorus getters to match naming conventions: fluid_synth_get_chorus_speed() and fluid_synth_get_chorus_depth()
|
||||
- fluid_synth_remove_sfont() returns FLUID_OK or FLUID_FAILED
|
||||
<br /><br />
|
||||
- add <a href="fluidsettings.xml#midi.autoconnect">"midi.autoconnect"</a> a setting for automatically connecting fluidsynth to available MIDI input ports
|
||||
|
@ -117,6 +118,7 @@ Changes in FluidSynth 2.0.0 concerning developers:
|
|||
- add fluid_synth_add_default_mod() and fluid_synth_remove_default_mod() for manipulating default modulators
|
||||
- add individual reverb setters: fluid_synth_set_reverb_roomsize(), fluid_synth_set_reverb_damp(), fluid_synth_set_reverb_width(), fluid_synth_set_reverb_level()
|
||||
- add individual chorus setters: fluid_synth_set_chorus_nr(), fluid_synth_set_chorus_level(), fluid_synth_set_chorus_speed(), fluid_synth_set_chorus_depth(), fluid_synth_set_chorus_type()
|
||||
- add realtime settings for <a href="fluidsettings.xml#synth.reverb.damp">reverb</a> and <a href="fluidsettings.xml#synth.chorus.depth">chorus</a> parameters
|
||||
- introduce a separate data type for sequencer client IDs: #fluid_seq_id_t
|
||||
- add seek support to midi-player, see fluid_player_seek()
|
||||
- expose functions to manipulate the ladspa effects unit (see ladspa.h)
|
||||
|
|
|
@ -137,11 +137,6 @@ FLUIDSYNTH_API double fluid_synth_get_reverb_damp(fluid_synth_t* synth);
|
|||
FLUIDSYNTH_API double fluid_synth_get_reverb_level(fluid_synth_t* synth);
|
||||
FLUIDSYNTH_API double fluid_synth_get_reverb_width(fluid_synth_t* synth);
|
||||
|
||||
#define FLUID_REVERB_DEFAULT_ROOMSIZE 0.2f /**< Default reverb room size */
|
||||
#define FLUID_REVERB_DEFAULT_DAMP 0.0f /**< Default reverb damping */
|
||||
#define FLUID_REVERB_DEFAULT_WIDTH 0.5f /**< Default reverb width */
|
||||
#define FLUID_REVERB_DEFAULT_LEVEL 0.9f /**< Default reverb level */
|
||||
|
||||
|
||||
/* Chorus */
|
||||
|
||||
|
@ -164,16 +159,10 @@ FLUIDSYNTH_API int fluid_synth_set_chorus_type(fluid_synth_t* synth, int type);
|
|||
FLUIDSYNTH_API void fluid_synth_set_chorus_on(fluid_synth_t* synth, int on);
|
||||
FLUIDSYNTH_API int fluid_synth_get_chorus_nr(fluid_synth_t* synth);
|
||||
FLUIDSYNTH_API double fluid_synth_get_chorus_level(fluid_synth_t* synth);
|
||||
FLUIDSYNTH_API double fluid_synth_get_chorus_speed_Hz(fluid_synth_t* synth);
|
||||
FLUIDSYNTH_API double fluid_synth_get_chorus_depth_ms(fluid_synth_t* synth);
|
||||
FLUIDSYNTH_API double fluid_synth_get_chorus_speed(fluid_synth_t* synth);
|
||||
FLUIDSYNTH_API double fluid_synth_get_chorus_depth(fluid_synth_t* synth);
|
||||
FLUIDSYNTH_API int fluid_synth_get_chorus_type(fluid_synth_t* synth); /* see fluid_chorus_mod */
|
||||
|
||||
#define FLUID_CHORUS_DEFAULT_N 3 /**< Default chorus voice count */
|
||||
#define FLUID_CHORUS_DEFAULT_LEVEL 2.0f /**< Default chorus level */
|
||||
#define FLUID_CHORUS_DEFAULT_SPEED 0.3f /**< Default chorus speed */
|
||||
#define FLUID_CHORUS_DEFAULT_DEPTH 8.0f /**< Default chorus depth */
|
||||
#define FLUID_CHORUS_DEFAULT_TYPE FLUID_CHORUS_MOD_SINE /**< Default chorus waveform type */
|
||||
|
||||
|
||||
/* Audio and MIDI channels */
|
||||
|
||||
|
|
|
@ -803,6 +803,9 @@ fluid_handle_reverbpreset(void* data, int ac, char** av, fluid_ostream_t out)
|
|||
{
|
||||
FLUID_ENTRY_COMMAND(data);
|
||||
int reverb_preset_number;
|
||||
|
||||
fluid_ostream_printf(out, "rev_preset is deprecated and will be removed in a future release!\n");
|
||||
|
||||
if (ac < 1) {
|
||||
fluid_ostream_printf(out, "rev_preset: too few arguments\n");
|
||||
return FLUID_FAILED;
|
||||
|
@ -823,10 +826,14 @@ fluid_handle_reverbsetroomsize(void* data, int ac, char** av, fluid_ostream_t ou
|
|||
{
|
||||
FLUID_ENTRY_COMMAND(data);
|
||||
fluid_real_t room_size;
|
||||
|
||||
if (ac < 1) {
|
||||
fluid_ostream_printf(out, "rev_setroomsize: too few arguments.\n");
|
||||
return FLUID_FAILED;
|
||||
}
|
||||
|
||||
fluid_ostream_printf(out, "rev_setroomsize is deprecated! Use 'set synth.reverb.room-size %s' instead.\n", av[0]);
|
||||
|
||||
room_size = atof(av[0]);
|
||||
if (room_size < 0){
|
||||
fluid_ostream_printf(out, "rev_setroomsize: Room size must be positive!\n");
|
||||
|
@ -852,6 +859,9 @@ fluid_handle_reverbsetdamp(void* data, int ac, char** av, fluid_ostream_t out)
|
|||
fluid_ostream_printf(out, "rev_setdamp: too few arguments.\n");
|
||||
return FLUID_FAILED;
|
||||
}
|
||||
|
||||
fluid_ostream_printf(out, "rev_setdamp is deprecated! Use 'set synth.reverb.damp %s' instead.\n", av[0]);
|
||||
|
||||
damp = atof(av[0]);
|
||||
if ((damp < 0.0f) || (damp > 1)){
|
||||
fluid_ostream_printf(out, "rev_setdamp: damp must be between 0 and 1!\n");
|
||||
|
@ -873,6 +883,9 @@ fluid_handle_reverbsetwidth(void* data, int ac, char** av, fluid_ostream_t out)
|
|||
fluid_ostream_printf(out, "rev_setwidth: too few arguments.\n");
|
||||
return FLUID_FAILED;
|
||||
}
|
||||
|
||||
fluid_ostream_printf(out, "rev_setroomsize is deprecated! Use 'set synth.reverb.width %s' instead.\n", av[0]);
|
||||
|
||||
width = atof(av[0]);
|
||||
if ((width < 0) || (width > 100)){
|
||||
fluid_ostream_printf(out, "rev_setroomsize: Too wide! (0..100)\n");
|
||||
|
@ -894,6 +907,9 @@ fluid_handle_reverbsetlevel(void* data, int ac, char** av, fluid_ostream_t out)
|
|||
fluid_ostream_printf(out, "rev_setlevel: too few arguments.\n");
|
||||
return FLUID_FAILED;
|
||||
}
|
||||
|
||||
fluid_ostream_printf(out, "rev_setlevel is deprecated! Use 'set synth.reverb.level %s' instead.\n", av[0]);
|
||||
|
||||
level = atof(av[0]);
|
||||
if (fabs(level) > 30){
|
||||
fluid_ostream_printf(out, "rev_setlevel: Value too high! (Value of 10 =+20 dB)\n");
|
||||
|
@ -914,7 +930,9 @@ fluid_handle_reverb(void* data, int ac, char** av, fluid_ostream_t out)
|
|||
fluid_ostream_printf(out, "reverb: too few arguments.\n");
|
||||
return FLUID_FAILED;
|
||||
}
|
||||
|
||||
|
||||
fluid_ostream_printf(out, "reverb is deprecated! Use 'set synth.reverb.active %s' instead.\n", av[0]);
|
||||
|
||||
if ((FLUID_STRCMP(av[0], "0") == 0) || (FLUID_STRCMP(av[0], "off") == 0)) {
|
||||
fluid_synth_set_reverb_on(handler->synth,0);
|
||||
} else if ((FLUID_STRCMP(av[0], "1") == 0) || (FLUID_STRCMP(av[0], "on") == 0)) {
|
||||
|
@ -939,6 +957,9 @@ fluid_handle_chorusnr(void* data, int ac, char** av, fluid_ostream_t out)
|
|||
fluid_ostream_printf(out, "cho_set_nr: too few arguments.\n");
|
||||
return FLUID_FAILED;
|
||||
}
|
||||
|
||||
fluid_ostream_printf(out, "cho_set_nr is deprecated! Use 'set synth.chorus.nr %s' instead.\n", av[0]);
|
||||
|
||||
nr = atoi(av[0]);
|
||||
fluid_synth_set_chorus_nr(handler->synth, nr);
|
||||
return FLUID_OK;
|
||||
|
@ -955,6 +976,9 @@ fluid_handle_choruslevel(void* data, int ac, char** av, fluid_ostream_t out)
|
|||
fluid_ostream_printf(out, "cho_set_level: too few arguments.\n");
|
||||
return FLUID_FAILED;
|
||||
}
|
||||
|
||||
fluid_ostream_printf(out, "cho_set_level is deprecated! Use 'set synth.chorus.level %s' instead.\n", av[0]);
|
||||
|
||||
level = atof(av[0]);
|
||||
fluid_synth_set_chorus_level(handler->synth, level);
|
||||
return FLUID_OK;
|
||||
|
@ -972,6 +996,9 @@ fluid_handle_chorusspeed(void* data, int ac, char** av, fluid_ostream_t out)
|
|||
fluid_ostream_printf(out, "cho_set_speed: too few arguments.\n");
|
||||
return FLUID_FAILED;
|
||||
}
|
||||
|
||||
fluid_ostream_printf(out, "cho_set_speed is deprecated! Use 'set synth.chorus.speed %s' instead.\n", av[0]);
|
||||
|
||||
speed = atof(av[0]);
|
||||
fluid_synth_set_chorus_speed(handler->synth, speed);
|
||||
return FLUID_OK;
|
||||
|
@ -988,6 +1015,9 @@ fluid_handle_chorusdepth(void* data, int ac, char** av, fluid_ostream_t out)
|
|||
fluid_ostream_printf(out, "cho_set_depth: too few arguments.\n");
|
||||
return FLUID_FAILED;
|
||||
}
|
||||
|
||||
fluid_ostream_printf(out, "cho_set_depth is deprecated! Use 'set synth.chorus.depth %s' instead.\n", av[0]);
|
||||
|
||||
depth = atof(av[0]);
|
||||
fluid_synth_set_chorus_depth(handler->synth, depth);
|
||||
return FLUID_OK;
|
||||
|
@ -1001,7 +1031,9 @@ fluid_handle_chorus(void* data, int ac, char** av, fluid_ostream_t out)
|
|||
fluid_ostream_printf(out, "chorus: too few arguments\n");
|
||||
return FLUID_FAILED;
|
||||
}
|
||||
|
||||
|
||||
fluid_ostream_printf(out, "chorus is deprecated! Use 'set synth.chorus.active %s' instead.\n", av[0]);
|
||||
|
||||
if ((FLUID_STRCMP(av[0], "0") == 0) || (FLUID_STRCMP(av[0], "off") == 0)) {
|
||||
fluid_synth_set_chorus_on(handler->synth,0);
|
||||
} else if ((FLUID_STRCMP(av[0], "1") == 0) || (FLUID_STRCMP(av[0], "on") == 0)) {
|
||||
|
|
|
@ -220,11 +220,7 @@ fluid_chorus_init(fluid_chorus_t* chorus)
|
|||
for (i = 0; i < MAX_SAMPLES; i++) {
|
||||
chorus->chorusbuf[i] = 0.0;
|
||||
}
|
||||
|
||||
/* initialize the chorus with the default settings */
|
||||
fluid_chorus_set (chorus, FLUID_CHORUS_SET_ALL, FLUID_CHORUS_DEFAULT_N,
|
||||
FLUID_CHORUS_DEFAULT_LEVEL, FLUID_CHORUS_DEFAULT_SPEED,
|
||||
FLUID_CHORUS_DEFAULT_DEPTH, FLUID_CHORUS_DEFAULT_TYPE);
|
||||
|
||||
return FLUID_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -195,11 +195,6 @@ fluid_comb_getfeedback(fluid_comb* comb)
|
|||
#define scaledamp 1.0f
|
||||
#define scaleroom 0.28f
|
||||
#define offsetroom 0.7f
|
||||
#define initialroom 0.5f
|
||||
#define initialdamp 0.2f
|
||||
#define initialwet 1
|
||||
#define initialdry 0
|
||||
#define initialwidth 1
|
||||
#define stereospread 23
|
||||
|
||||
/*
|
||||
|
@ -278,7 +273,6 @@ new_fluid_revmodel(fluid_real_t sample_rate)
|
|||
fluid_allpass_setfeedback(&rev->allpassR[3], 0.5f);
|
||||
|
||||
rev->gain = fixedgain;
|
||||
fluid_revmodel_set(rev,FLUID_REVMODEL_SET_ALL,initialroom,initialdamp,initialwidth,initialwet);
|
||||
|
||||
return rev;
|
||||
}
|
||||
|
|
|
@ -126,6 +126,8 @@ 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);
|
||||
|
@ -134,6 +136,8 @@ static void fluid_synth_set_basic_channel_LOCAL(fluid_synth_t* synth, int basicc
|
|||
static int fluid_synth_set_reverb_full_LOCAL(fluid_synth_t* synth, int set, double roomsize,
|
||||
double damping, double width, double level);
|
||||
|
||||
static int fluid_synth_set_chorus_full_LOCAL(fluid_synth_t* synth, int set, int nr, double level,
|
||||
double speed, double depth_ms, int type);
|
||||
|
||||
/***************************************************************
|
||||
*
|
||||
|
@ -191,8 +195,19 @@ static const fluid_revmodel_presets_t revmodel_preset[] = {
|
|||
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.0f, 1.0f, 0);
|
||||
fluid_settings_register_num(settings, "synth.reverb.damp", FLUID_REVERB_DEFAULT_DAMP, 0.0f, 1.0f, 0);
|
||||
fluid_settings_register_num(settings, "synth.reverb.width", FLUID_REVERB_DEFAULT_WIDTH, 0.0f, 100.0f, 0);
|
||||
fluid_settings_register_num(settings, "synth.reverb.level", FLUID_REVERB_DEFAULT_LEVEL, 0.0f, 1.0f, 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.0f, 10.0f, 0);
|
||||
fluid_settings_register_num(settings, "synth.chorus.speed", FLUID_CHORUS_DEFAULT_SPEED, 0.29f, 5.0f, 0);
|
||||
fluid_settings_register_num(settings, "synth.chorus.depth", FLUID_CHORUS_DEFAULT_DEPTH, 0.0f, 21.0f, 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);
|
||||
|
@ -641,6 +656,26 @@ new_fluid_synth(fluid_settings_t *settings)
|
|||
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 */
|
||||
|
||||
|
@ -799,12 +834,38 @@ new_fluid_synth(fluid_settings_t *settings)
|
|||
synth->curmax = 0;
|
||||
synth->dither_index = 0;
|
||||
|
||||
fluid_synth_set_reverb_full_LOCAL(synth,
|
||||
{
|
||||
double room, damp, width, level;
|
||||
|
||||
fluid_settings_getnum(settings, "synth.reverb.room-size", &room);
|
||||
fluid_settings_getnum(settings, "synth.reverb.damp", &damp);
|
||||
fluid_settings_getnum(settings, "synth.reverb.width", &width);
|
||||
fluid_settings_getnum(settings, "synth.reverb.level", &level);
|
||||
|
||||
fluid_synth_set_reverb_full_LOCAL(synth,
|
||||
FLUID_REVMODEL_SET_ALL,
|
||||
FLUID_REVERB_DEFAULT_ROOMSIZE,
|
||||
FLUID_REVERB_DEFAULT_DAMP,
|
||||
FLUID_REVERB_DEFAULT_WIDTH,
|
||||
FLUID_REVERB_DEFAULT_LEVEL);
|
||||
room,
|
||||
damp,
|
||||
width,
|
||||
level);
|
||||
}
|
||||
|
||||
{
|
||||
double level, speed, depth;
|
||||
|
||||
fluid_settings_getint(settings, "synth.chorus.nr", &i);
|
||||
fluid_settings_getnum(settings, "synth.chorus.level", &level);
|
||||
fluid_settings_getnum(settings, "synth.chorus.speed", &speed);
|
||||
fluid_settings_getnum(settings, "synth.chorus.depth", &depth);
|
||||
|
||||
fluid_synth_set_chorus_full_LOCAL(synth,
|
||||
FLUID_CHORUS_SET_ALL,
|
||||
i,
|
||||
level,
|
||||
speed,
|
||||
depth,
|
||||
FLUID_CHORUS_DEFAULT_TYPE);
|
||||
}
|
||||
|
||||
/* Initialize multi-core variables if multiple cores enabled */
|
||||
if (synth->cores > 1)
|
||||
|
@ -3408,6 +3469,55 @@ fluid_synth_render_blocks(fluid_synth_t* synth, int blockcount)
|
|||
return blockcount;
|
||||
}
|
||||
|
||||
/*
|
||||
* Handler for synth.reverb.* and synth.chorus.* double settings.
|
||||
*/
|
||||
static void fluid_synth_handle_reverb_chorus_num (void *data, const char *name, double value)
|
||||
{
|
||||
fluid_synth_t *synth = (fluid_synth_t *)data;
|
||||
fluid_return_if_fail(synth != NULL);
|
||||
|
||||
if (FLUID_STRCMP(name, "synth.reverb.room-size") == 0) {
|
||||
fluid_synth_set_reverb_roomsize(synth, value);
|
||||
}
|
||||
else if (FLUID_STRCMP(name, "synth.reverb.damp") == 0) {
|
||||
fluid_synth_set_reverb_damp(synth, value);
|
||||
}
|
||||
else if (FLUID_STRCMP(name, "synth.reverb.width") == 0) {
|
||||
fluid_synth_set_reverb_width(synth, value);
|
||||
}
|
||||
else if (FLUID_STRCMP(name, "synth.reverb.level") == 0) {
|
||||
fluid_synth_set_reverb_level(synth, value);
|
||||
}
|
||||
else if (FLUID_STRCMP(name, "synth.chorus.depth") == 0) {
|
||||
fluid_synth_set_chorus_depth(synth, value);
|
||||
}
|
||||
else if (FLUID_STRCMP(name, "synth.chorus.speed") == 0) {
|
||||
fluid_synth_set_chorus_speed(synth, value);
|
||||
}
|
||||
else if (FLUID_STRCMP(name, "synth.chorus.level") == 0) {
|
||||
fluid_synth_set_chorus_level(synth, value);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Handler for synth.reverb.* and synth.chorus.* integer settings.
|
||||
*/
|
||||
static void fluid_synth_handle_reverb_chorus_int (void *data, const char *name, int value)
|
||||
{
|
||||
fluid_synth_t *synth = (fluid_synth_t *)data;
|
||||
fluid_return_if_fail(synth != NULL);
|
||||
|
||||
if (FLUID_STRCMP(name, "synth.reverb.active") == 0) {
|
||||
fluid_synth_set_reverb_on(synth, value);
|
||||
}
|
||||
else if (FLUID_STRCMP(name, "synth.chorus.active") == 0) {
|
||||
fluid_synth_set_chorus_on(synth, value);
|
||||
}
|
||||
else if (FLUID_STRCMP(name, "synth.chorus.nr") == 0) {
|
||||
fluid_synth_set_chorus_nr(synth, value);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Handler for synth.overflow.* settings.
|
||||
|
@ -4408,7 +4518,6 @@ fluid_synth_set_chorus_full(fluid_synth_t* synth, int set, int nr, double level,
|
|||
double speed, double depth_ms, int type)
|
||||
{
|
||||
int ret;
|
||||
fluid_rvoice_param_t param[MAX_EVENT_PARAMS];
|
||||
|
||||
fluid_return_val_if_fail (synth != NULL, FLUID_FAILED);
|
||||
/* if non of the flags is set, fail */
|
||||
|
@ -4417,6 +4526,18 @@ fluid_synth_set_chorus_full(fluid_synth_t* synth, int set, int nr, double level,
|
|||
/* Synth shadow values are set here so that they will be returned if queried */
|
||||
fluid_synth_api_enter(synth);
|
||||
|
||||
ret = fluid_synth_set_chorus_full_LOCAL(synth, set, nr, level, speed, depth_ms, type);
|
||||
|
||||
FLUID_API_RETURN(ret);
|
||||
}
|
||||
|
||||
static int
|
||||
fluid_synth_set_chorus_full_LOCAL(fluid_synth_t* synth, int set, int nr, double level,
|
||||
double speed, double depth_ms, int type)
|
||||
{
|
||||
int ret;
|
||||
fluid_rvoice_param_t param[MAX_EVENT_PARAMS];
|
||||
|
||||
if (set & FLUID_CHORUS_SET_NR)
|
||||
synth->chorus_nr = nr;
|
||||
|
||||
|
@ -4443,7 +4564,7 @@ fluid_synth_set_chorus_full(fluid_synth_t* synth, int set, int nr, double level,
|
|||
synth->eventhandler->mixer,
|
||||
param);
|
||||
|
||||
FLUID_API_RETURN(ret);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4484,7 +4605,7 @@ fluid_synth_get_chorus_level(fluid_synth_t* synth)
|
|||
* @return Chorus speed in Hz (0.29-5.0)
|
||||
*/
|
||||
double
|
||||
fluid_synth_get_chorus_speed_Hz(fluid_synth_t* synth)
|
||||
fluid_synth_get_chorus_speed(fluid_synth_t* synth)
|
||||
{
|
||||
double result;
|
||||
fluid_return_val_if_fail (synth != NULL, 0.0);
|
||||
|
@ -4500,7 +4621,7 @@ fluid_synth_get_chorus_speed_Hz(fluid_synth_t* synth)
|
|||
* @return Chorus depth
|
||||
*/
|
||||
double
|
||||
fluid_synth_get_chorus_depth_ms(fluid_synth_t* synth)
|
||||
fluid_synth_get_chorus_depth(fluid_synth_t* synth)
|
||||
{
|
||||
double result;
|
||||
fluid_return_val_if_fail (synth != NULL, 0.0);
|
||||
|
|
|
@ -46,6 +46,17 @@
|
|||
|
||||
#define FLUID_UNSET_PROGRAM 128 /* Program number used to unset a preset */
|
||||
|
||||
#define FLUID_REVERB_DEFAULT_ROOMSIZE 0.2f /**< Default reverb room size */
|
||||
#define FLUID_REVERB_DEFAULT_DAMP 0.0f /**< Default reverb damping */
|
||||
#define FLUID_REVERB_DEFAULT_WIDTH 0.5f /**< Default reverb width */
|
||||
#define FLUID_REVERB_DEFAULT_LEVEL 0.9f /**< Default reverb level */
|
||||
|
||||
#define FLUID_CHORUS_DEFAULT_N 3 /**< Default chorus voice count */
|
||||
#define FLUID_CHORUS_DEFAULT_LEVEL 2.0f /**< Default chorus level */
|
||||
#define FLUID_CHORUS_DEFAULT_SPEED 0.3f /**< Default chorus speed */
|
||||
#define FLUID_CHORUS_DEFAULT_DEPTH 8.0f /**< Default chorus depth */
|
||||
#define FLUID_CHORUS_DEFAULT_TYPE FLUID_CHORUS_MOD_SINE /**< Default chorus waveform type */
|
||||
|
||||
/***************************************************************
|
||||
*
|
||||
* ENUM
|
||||
|
|
|
@ -15,6 +15,7 @@ ADD_FLUID_TEST(test_sample_rate_change)
|
|||
ADD_FLUID_TEST(test_preset_sample_loading)
|
||||
ADD_FLUID_TEST(test_pointer_alignment)
|
||||
ADD_FLUID_TEST(test_seqbind_unregister)
|
||||
ADD_FLUID_TEST(test_synth_chorus_reverb)
|
||||
ADD_FLUID_TEST(test_snprintf)
|
||||
|
||||
if ( LIBSNDFILE_HASVORBIS )
|
||||
|
|
62
test/test_synth_chorus_reverb.c
Normal file
62
test/test_synth_chorus_reverb.c
Normal file
|
@ -0,0 +1,62 @@
|
|||
|
||||
#include "test.h"
|
||||
#include "fluidsynth.h"
|
||||
|
||||
// this test should make sure that sample rate changed are handled correctly
|
||||
int main(void)
|
||||
{
|
||||
fluid_synth_t *synth;
|
||||
fluid_settings_t *settings = new_fluid_settings();
|
||||
TEST_ASSERT(settings != NULL);
|
||||
|
||||
TEST_SUCCESS(fluid_settings_setnum(settings, "synth.reverb.room-size", 0.1));
|
||||
TEST_SUCCESS(fluid_settings_setnum(settings, "synth.reverb.damp", 0.2));
|
||||
TEST_SUCCESS(fluid_settings_setnum(settings, "synth.reverb.width", 0.3));
|
||||
TEST_SUCCESS(fluid_settings_setnum(settings, "synth.reverb.level", 0.4));
|
||||
|
||||
TEST_SUCCESS(fluid_settings_setint(settings, "synth.chorus.nr", 99));
|
||||
TEST_SUCCESS(fluid_settings_setnum(settings, "synth.chorus.level", 0.5));
|
||||
TEST_SUCCESS(fluid_settings_setnum(settings, "synth.chorus.speed", 0.6));
|
||||
TEST_SUCCESS(fluid_settings_setnum(settings, "synth.chorus.depth", 0.7));
|
||||
|
||||
synth = new_fluid_synth(settings);
|
||||
TEST_ASSERT(synth != NULL);
|
||||
|
||||
// check that the synth is initialized with the correct values
|
||||
TEST_ASSERT(fluid_synth_get_reverb_roomsize(synth) == 0.1);
|
||||
TEST_ASSERT(fluid_synth_get_reverb_damp(synth) == 0.2);
|
||||
TEST_ASSERT(fluid_synth_get_reverb_width(synth) == 0.3);
|
||||
TEST_ASSERT(fluid_synth_get_reverb_level(synth) == 0.4);
|
||||
|
||||
TEST_ASSERT(fluid_synth_get_chorus_nr(synth) == 99);
|
||||
TEST_ASSERT(fluid_synth_get_chorus_level(synth) == 0.5);
|
||||
TEST_ASSERT(fluid_synth_get_chorus_speed(synth) == 0.6);
|
||||
TEST_ASSERT(fluid_synth_get_chorus_depth(synth) == 0.7);
|
||||
|
||||
// update the realtime settings afterward
|
||||
TEST_SUCCESS(fluid_settings_setnum(settings, "synth.reverb.room-size", 0.11));
|
||||
TEST_SUCCESS(fluid_settings_setnum(settings, "synth.reverb.damp", 0.22));
|
||||
TEST_SUCCESS(fluid_settings_setnum(settings, "synth.reverb.width", 0.33));
|
||||
TEST_SUCCESS(fluid_settings_setnum(settings, "synth.reverb.level", 0.44));
|
||||
|
||||
TEST_SUCCESS(fluid_settings_setint(settings, "synth.chorus.nr", 11));
|
||||
TEST_SUCCESS(fluid_settings_setnum(settings, "synth.chorus.level", 0.55));
|
||||
TEST_SUCCESS(fluid_settings_setnum(settings, "synth.chorus.speed", 0.66));
|
||||
TEST_SUCCESS(fluid_settings_setnum(settings, "synth.chorus.depth", 0.77));
|
||||
|
||||
// check that the realtime settings correctly update the values in the synth
|
||||
TEST_ASSERT(fluid_synth_get_reverb_roomsize(synth) == 0.11);
|
||||
TEST_ASSERT(fluid_synth_get_reverb_damp(synth) == 0.22);
|
||||
TEST_ASSERT(fluid_synth_get_reverb_width(synth) == 0.33);
|
||||
TEST_ASSERT(fluid_synth_get_reverb_level(synth) == 0.44);
|
||||
|
||||
TEST_ASSERT(fluid_synth_get_chorus_nr(synth) == 11);
|
||||
TEST_ASSERT(fluid_synth_get_chorus_level(synth) == 0.55);
|
||||
TEST_ASSERT(fluid_synth_get_chorus_speed(synth) == 0.66);
|
||||
TEST_ASSERT(fluid_synth_get_chorus_depth(synth) == 0.77);
|
||||
|
||||
delete_fluid_synth(synth);
|
||||
delete_fluid_settings(settings);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
Loading…
Reference in a new issue