mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2024-11-10 23:11:41 +00:00
Fix default values to be more consistent with MIDI spec. Also fixes ticket #29
This commit is contained in:
parent
c67206e383
commit
94e1720aa5
3 changed files with 58 additions and 20 deletions
|
@ -44,7 +44,7 @@ new_fluid_channel(fluid_synth_t* synth, int num)
|
||||||
chan->preset = NULL;
|
chan->preset = NULL;
|
||||||
|
|
||||||
fluid_channel_init(chan);
|
fluid_channel_init(chan);
|
||||||
fluid_channel_init_ctrl(chan);
|
fluid_channel_init_ctrl(chan, 0);
|
||||||
|
|
||||||
return chan;
|
return chan;
|
||||||
}
|
}
|
||||||
|
@ -52,8 +52,8 @@ new_fluid_channel(fluid_synth_t* synth, int num)
|
||||||
void
|
void
|
||||||
fluid_channel_init(fluid_channel_t* chan)
|
fluid_channel_init(fluid_channel_t* chan)
|
||||||
{
|
{
|
||||||
chan->prognum = (chan->channum == 9)? 0 : chan->channum;
|
chan->prognum = 0;
|
||||||
chan->banknum = (chan->channum == 9)? 128 : 0;
|
chan->banknum = (chan->channum == 9)? 128 : 0; /* ?? */
|
||||||
chan->sfontnum = 0;
|
chan->sfontnum = 0;
|
||||||
|
|
||||||
if (chan->preset) delete_fluid_preset (chan->preset);
|
if (chan->preset) delete_fluid_preset (chan->preset);
|
||||||
|
@ -65,47 +65,85 @@ fluid_channel_init(fluid_channel_t* chan)
|
||||||
chan->nrpn_active = 0;
|
chan->nrpn_active = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
@param is_all_ctrl_off if nonzero, only resets some controllers, according to
|
||||||
|
http://www.midi.org/techspecs/rp15.php
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
fluid_channel_init_ctrl(fluid_channel_t* chan)
|
fluid_channel_init_ctrl(fluid_channel_t* chan, int is_all_ctrl_off)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
chan->key_pressure = 0;
|
chan->key_pressure = 0;
|
||||||
chan->channel_pressure = 0;
|
chan->channel_pressure = 0;
|
||||||
chan->pitch_bend = 0x2000; /* Range is 0x4000, pitch bend wheel starts in centered position */
|
chan->pitch_bend = 0x2000; /* Range is 0x4000, pitch bend wheel starts in centered position */
|
||||||
chan->pitch_wheel_sensitivity = 2; /* two semi-tones */
|
|
||||||
|
|
||||||
for (i = 0; i < GEN_LAST; i++) {
|
for (i = 0; i < GEN_LAST; i++) {
|
||||||
chan->gen[i] = 0.0f;
|
chan->gen[i] = 0.0f;
|
||||||
chan->gen_abs[i] = 0;
|
chan->gen_abs[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (is_all_ctrl_off) {
|
||||||
|
for (i = 0; i < ALL_SOUND_OFF; i++) {
|
||||||
|
if (i >= EFFECTS_DEPTH1 && i <= EFFECTS_DEPTH5) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (i >= SOUND_CTRL1 && i <= SOUND_CTRL10) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (i == BANK_SELECT_MSB || i == BANK_SELECT_LSB || i == VOLUME_MSB ||
|
||||||
|
i == VOLUME_LSB || i == PAN_MSB || i == PAN_LSB) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
SETCC(chan, i, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
for (i = 0; i < 128; i++) {
|
for (i = 0; i < 128; i++) {
|
||||||
SETCC(chan, i, 0);
|
SETCC(chan, i, 0);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set RPN controllers to NULL state */
|
||||||
|
SETCC(chan, RPN_LSB, 127);
|
||||||
|
SETCC(chan, RPN_MSB, 127);
|
||||||
|
|
||||||
|
/* Set NRPN controllers to NULL state */
|
||||||
|
SETCC(chan, NRPN_LSB, 127);
|
||||||
|
SETCC(chan, NRPN_MSB, 127);
|
||||||
|
|
||||||
|
/* Expression (MSB & LSB) */
|
||||||
|
SETCC(chan, EXPRESSION_MSB, 127);
|
||||||
|
SETCC(chan, EXPRESSION_LSB, 127);
|
||||||
|
|
||||||
|
if (!is_all_ctrl_off) {
|
||||||
|
|
||||||
|
chan->pitch_wheel_sensitivity = 2; /* two semi-tones */
|
||||||
|
|
||||||
|
/* Just like panning, a value of 64 indicates no change for sound ctrls */
|
||||||
|
for (i = SOUND_CTRL1; i <= SOUND_CTRL10; i++) {
|
||||||
|
SETCC(chan, i, 64);
|
||||||
|
}
|
||||||
|
|
||||||
/* Volume / initial attenuation (MSB & LSB) */
|
/* Volume / initial attenuation (MSB & LSB) */
|
||||||
SETCC(chan, VOLUME_MSB, 127);
|
SETCC(chan, VOLUME_MSB, 100);
|
||||||
SETCC(chan, VOLUME_LSB, 0);
|
SETCC(chan, VOLUME_LSB, 0);
|
||||||
|
|
||||||
/* Pan (MSB & LSB) */
|
/* Pan (MSB & LSB) */
|
||||||
SETCC(chan, PAN_MSB, 64);
|
SETCC(chan, PAN_MSB, 64);
|
||||||
SETCC(chan, PAN_LSB, 0);
|
SETCC(chan, PAN_LSB, 0);
|
||||||
|
|
||||||
/* Expression (MSB & LSB) */
|
/* Reverb */
|
||||||
SETCC(chan, EXPRESSION_MSB, 127);
|
SETCC(chan, EFFECTS_DEPTH1, 40);
|
||||||
SETCC(chan, EXPRESSION_LSB, 127);
|
}
|
||||||
|
|
||||||
/* Set RPN controllers to NULL state */
|
|
||||||
SETCC(chan, RPN_LSB, 127);
|
|
||||||
SETCC(chan, RPN_MSB, 127);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
fluid_channel_reset(fluid_channel_t* chan)
|
fluid_channel_reset(fluid_channel_t* chan)
|
||||||
{
|
{
|
||||||
fluid_channel_init(chan);
|
fluid_channel_init(chan);
|
||||||
fluid_channel_init_ctrl(chan);
|
fluid_channel_init_ctrl(chan, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -227,7 +265,7 @@ fluid_channel_cc(fluid_channel_t* chan, int num, int value)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ALL_CTRL_OFF:
|
case ALL_CTRL_OFF:
|
||||||
fluid_channel_init_ctrl(chan);
|
fluid_channel_init_ctrl(chan, 1);
|
||||||
fluid_synth_modulate_voices_all(chan->synth, chan->channum);
|
fluid_synth_modulate_voices_all(chan->synth, chan->channum);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,7 @@ struct _fluid_channel_t
|
||||||
fluid_channel_t* new_fluid_channel(fluid_synth_t* synth, int num);
|
fluid_channel_t* new_fluid_channel(fluid_synth_t* synth, int num);
|
||||||
int delete_fluid_channel(fluid_channel_t* chan);
|
int delete_fluid_channel(fluid_channel_t* chan);
|
||||||
void fluid_channel_init(fluid_channel_t* chan);
|
void fluid_channel_init(fluid_channel_t* chan);
|
||||||
void fluid_channel_init_ctrl(fluid_channel_t* chan);
|
void fluid_channel_init_ctrl(fluid_channel_t* chan, int is_all_ctrl_off);
|
||||||
void fluid_channel_reset(fluid_channel_t* chan);
|
void fluid_channel_reset(fluid_channel_t* chan);
|
||||||
int fluid_channel_set_preset(fluid_channel_t* chan, fluid_preset_t* preset);
|
int fluid_channel_set_preset(fluid_channel_t* chan, fluid_preset_t* preset);
|
||||||
fluid_preset_t* fluid_channel_get_preset(fluid_channel_t* chan);
|
fluid_preset_t* fluid_channel_get_preset(fluid_channel_t* chan);
|
||||||
|
|
|
@ -324,7 +324,7 @@ fluid_synth_init(void)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* SF2.01 page 55 section 8.4.9: MIDI continuous controller 93 to Reverb send */
|
/* SF2.01 page 55 section 8.4.9: MIDI continuous controller 93 to Chorus send */
|
||||||
fluid_mod_set_source1(&default_chorus_mod, 93, /* index=93 */
|
fluid_mod_set_source1(&default_chorus_mod, 93, /* index=93 */
|
||||||
FLUID_MOD_CC /* CC=1 */
|
FLUID_MOD_CC /* CC=1 */
|
||||||
| FLUID_MOD_LINEAR /* type=0 */
|
| FLUID_MOD_LINEAR /* type=0 */
|
||||||
|
|
Loading…
Reference in a new issue