mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2025-02-26 13:50:50 +00:00
Better message when substituting presets, and store XG LSB changes even in drum mode.
This commit is contained in:
parent
b05e61fedf
commit
3c13165c34
2 changed files with 37 additions and 38 deletions
|
@ -233,8 +233,7 @@ fluid_channel_set_bank_lsb(fluid_channel_t* chan, int banklsb)
|
||||||
|
|
||||||
style = chan->synth->bank_select;
|
style = chan->synth->bank_select;
|
||||||
if (style == FLUID_BANK_STYLE_GM ||
|
if (style == FLUID_BANK_STYLE_GM ||
|
||||||
style == FLUID_BANK_STYLE_GS ||
|
style == FLUID_BANK_STYLE_GS)
|
||||||
chan->channel_type == CHANNEL_TYPE_DRUM)
|
|
||||||
return; /* ignored */
|
return; /* ignored */
|
||||||
|
|
||||||
oldval = chan->sfont_bank_prog;
|
oldval = chan->sfont_bank_prog;
|
||||||
|
@ -255,7 +254,7 @@ fluid_channel_set_bank_msb(fluid_channel_t* chan, int bankmsb)
|
||||||
|
|
||||||
if (style == FLUID_BANK_STYLE_XG)
|
if (style == FLUID_BANK_STYLE_XG)
|
||||||
{
|
{
|
||||||
/* XG bank (128*MSB+LSB), save MSB, do drum-channel auto-switch */
|
/* XG bank, do drum-channel auto-switch */
|
||||||
/* The number "120" was based on several keyboards having drums at 120 - 127,
|
/* The number "120" was based on several keyboards having drums at 120 - 127,
|
||||||
reference: http://lists.nongnu.org/archive/html/fluid-dev/2011-02/msg00003.html */
|
reference: http://lists.nongnu.org/archive/html/fluid-dev/2011-02/msg00003.html */
|
||||||
chan->channel_type = (120 <= bankmsb) ? CHANNEL_TYPE_DRUM : CHANNEL_TYPE_MELODIC;
|
chan->channel_type = (120 <= bankmsb) ? CHANNEL_TYPE_DRUM : CHANNEL_TYPE_MELODIC;
|
||||||
|
|
|
@ -1877,60 +1877,60 @@ fluid_synth_program_change(fluid_synth_t* synth, int chan, int prognum)
|
||||||
{
|
{
|
||||||
fluid_preset_t* preset = NULL;
|
fluid_preset_t* preset = NULL;
|
||||||
fluid_channel_t* channel;
|
fluid_channel_t* channel;
|
||||||
int subst_bank, subst_prog, banknum, result;
|
int subst_bank, subst_prog, banknum = 0, result;
|
||||||
|
|
||||||
fluid_return_val_if_fail (prognum >= 0 && prognum <= 128, FLUID_FAILED);
|
fluid_return_val_if_fail (prognum >= 0 && prognum <= 128, FLUID_FAILED);
|
||||||
FLUID_API_ENTRY_CHAN(FLUID_FAILED);
|
FLUID_API_ENTRY_CHAN(FLUID_FAILED);
|
||||||
|
|
||||||
channel = synth->channel[chan];
|
channel = synth->channel[chan];
|
||||||
fluid_channel_get_sfont_bank_prog(channel, NULL, &banknum, NULL);
|
if (channel->channel_type == CHANNEL_TYPE_DRUM)
|
||||||
|
banknum = DRUM_INST_BANK;
|
||||||
|
else
|
||||||
|
fluid_channel_get_sfont_bank_prog(channel, NULL, &banknum, NULL);
|
||||||
|
|
||||||
if (synth->verbose)
|
if (synth->verbose)
|
||||||
FLUID_LOG(FLUID_INFO, "prog\t%d\t%d\t%d", chan, banknum, prognum);
|
FLUID_LOG(FLUID_INFO, "prog\t%d\t%d\t%d", chan, banknum, prognum);
|
||||||
|
|
||||||
/* Special handling of channel 10 (or 9 counting from 0). channel
|
/* I think this is a hack for MIDI files that do bank changes in GM mode.
|
||||||
* 10 is the percussion channel.
|
* Proper way to handle this would probably be to ignore bank changes when in
|
||||||
*
|
* GM mode. - JG
|
||||||
* FIXME - I think this
|
* This is now possible by setting synth.midi-bank-select=gm, but let the hack
|
||||||
* is a hack for MIDI files that do bank changes in GM mode. Proper way to
|
* stay for the time being. - DH
|
||||||
* handle this would probably be to ignore bank changes when in GM mode. - JG
|
|
||||||
*/
|
*/
|
||||||
if (prognum != FLUID_UNSET_PROGRAM)
|
if (prognum != FLUID_UNSET_PROGRAM)
|
||||||
{
|
{
|
||||||
if (channel->channel_type == CHANNEL_TYPE_DRUM)
|
subst_bank = banknum;
|
||||||
preset = fluid_synth_find_preset(synth, DRUM_INST_BANK, prognum);
|
subst_prog = prognum;
|
||||||
else preset = fluid_synth_find_preset(synth, banknum, prognum);
|
|
||||||
|
preset = fluid_synth_find_preset(synth, subst_bank, subst_prog);
|
||||||
|
|
||||||
/* Fallback to another preset if not found */
|
/* Fallback to another preset if not found */
|
||||||
if (!preset)
|
if (!preset) {
|
||||||
{
|
/* Percussion: Fallback to preset 0 in percussion bank */
|
||||||
subst_bank = banknum;
|
if (subst_bank == DRUM_INST_BANK) {
|
||||||
subst_prog = prognum;
|
|
||||||
|
|
||||||
/* Melodic instrument? */
|
|
||||||
if ((channel->channel_type != CHANNEL_TYPE_DRUM) && (DRUM_INST_BANK != banknum))
|
|
||||||
{
|
|
||||||
subst_bank = 0;
|
|
||||||
|
|
||||||
/* Fallback first to bank 0:prognum */
|
|
||||||
preset = fluid_synth_find_preset(synth, 0, prognum);
|
|
||||||
|
|
||||||
/* Fallback to first preset in bank 0 */
|
|
||||||
if (!preset && prognum != 0)
|
|
||||||
{
|
|
||||||
preset = fluid_synth_find_preset(synth, 0, 0);
|
|
||||||
subst_prog = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else /* Percussion: Fallback to preset 0 in percussion bank */
|
|
||||||
{
|
|
||||||
preset = fluid_synth_find_preset(synth, DRUM_INST_BANK, 0);
|
|
||||||
subst_prog = 0;
|
subst_prog = 0;
|
||||||
|
preset = fluid_synth_find_preset(synth, subst_bank, subst_prog);
|
||||||
|
}
|
||||||
|
/* Melodic instrument */
|
||||||
|
else {
|
||||||
|
/* Fallback first to bank 0:prognum */
|
||||||
|
subst_bank = 0;
|
||||||
|
preset = fluid_synth_find_preset(synth, subst_bank, subst_prog);
|
||||||
|
|
||||||
|
/* Fallback to first preset in bank 0 (usually piano...) */
|
||||||
|
if (!preset)
|
||||||
|
{
|
||||||
|
subst_prog = 0;
|
||||||
|
preset = fluid_synth_find_preset(synth, subst_bank, subst_prog);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preset)
|
if (preset)
|
||||||
FLUID_LOG(FLUID_WARN, "Instrument not found on channel %d [bank=%d prog=%d], substituted [bank=%d prog=%d]",
|
FLUID_LOG(FLUID_WARN, "Instrument not found on channel %d [bank=%d prog=%d], substituted [bank=%d prog=%d]",
|
||||||
chan, banknum, prognum, subst_bank, subst_prog);
|
chan, banknum, prognum, subst_bank, subst_prog);
|
||||||
|
else
|
||||||
|
FLUID_LOG(FLUID_WARN, "No preset found on channel %d [bank=%d prog=%d]",
|
||||||
|
chan, banknum, prognum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue