[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [fluid-dev] invalid instrument/drum selection problem
From: |
jimmy |
Subject: |
Re: [fluid-dev] invalid instrument/drum selection problem |
Date: |
Sun, 6 Jan 2008 16:53:19 -0800 (PST) |
Hi Josh,
Below is the changes I tried. It does seem to keep
the existing dromset for any invalid drum-bank
requests. Also changed the constant DRUM_INST_MASK ,
which could potentially requires a re-compile of any
other programss using this constant. I think the
DRUM_INST_MASK should be 128, not a hex number, which
I believe might have been change along with 8-bit,
16-bit, 32-bit porting that now breaks some midi drum
bank select that needed the 120 offset added in the
old 7-bit unsigned int days.
FWIW, you could try the current FluidSynth and this
patch with the midi files from:
geocities.com/timessquare/lair/5396/midipark.html
they are not mine, and you don't have to try these.
In fact, you should try with other midi files you have
to be sure.
Jimmy
----- Patches for drumset validation below, also
attached as a file if word-wrapping makes it hard to
read -----
diff -r fluidsynth.svn.20071227/src/fluid_chan.c
fluidsynth.test/src/fluid_chan.c
175,176c175,187
< chan->banknum = banknum;
< return FLUID_OK;
---
> int tmpchan;
> unsigned int tmpbanknum;
>
> if (chan) {
> tmpchan = fluid_channel_get_num(chan);
> tmpbanknum = banknum;
> if ((tmpchan == 9) && (tmpbanknum <
DRUM_INST_MASK)) {
> tmpbanknum = tmpbanknum | DRUM_INST_MASK;
> }
> chan->banknum = tmpbanknum;
> return FLUID_OK;
> }
> return FLUID_FAILED;
diff -r fluidsynth.svn.20071227/src/fluid_synth.c
fluidsynth.test/src/fluid_synth.c
1171a1172
> unsigned int tmpbank;
1175a1177,1178
>
>
1180d1182
< banknum = fluid_channel_get_banknum(channel);
1182,1183c1184,1185
< /* inform the channel of the new program number
*/
< fluid_channel_set_prognum(channel, prognum);
---
> banknum = fluid_channel_get_banknum(channel);
> preset = fluid_synth_find_preset(synth, banknum,
prognum);
1193,1198c1195,1198
< /* try to search the drum instrument first */
< preset = fluid_synth_find_preset(synth,
banknum | DRUM_INST_MASK, prognum);
<
< /* if that fails try to search the melodic
instrument */
< if (preset == NULL) {
< preset = fluid_synth_find_preset(synth, banknum,
prognum);
---
> /* try to search the drum instrument, drum
bank number starts from 128 (DRUM_INST_MASK) */
> tmpbank = banknum;
> if (tmpbank < DRUM_INST_MASK) {
> tmpbank = tmpbank | DRUM_INST_MASK;
1199a1200
> preset = fluid_synth_find_preset(synth,
tmpbank, prognum);
1205,1207c1206,1214
< sfont_id = preset?
fluid_sfont_get_id(preset->sfont) : 0;
< fluid_channel_set_sfontnum(channel, sfont_id);
< fluid_channel_set_preset(channel, preset);
---
> if (preset) {
> sfont_id = fluid_sfont_get_id(preset->sfont);
> fluid_channel_set_sfontnum(channel,
sfont_id);
> fluid_channel_set_preset(channel, preset);
> fluid_channel_set_prognum(channel, prognum);
> }
> else {
> FLUID_LOG(FLUID_WARN, "Ignoring invalid
prog\t%d\t%d\t%d", chan, banknum, prognum);
> }
1220a1228,1236
>
> fluid_preset_t* preset = NULL;
> fluid_preset_t* preset2 = NULL;
> fluid_channel_t* channel;
> unsigned int tmpbank;
> unsigned int tmpprog;
>
> tmpbank = bank;
>
1222c1238,1256
< fluid_channel_set_banknum(synth->channel[chan],
bank);
---
> channel = synth->channel[chan];
>
> if ((channel) && (channel->channum == 9) &&
(bank < DRUM_INST_MASK)) {
> tmpbank = tmpbank + DRUM_INST_MASK;
> }
>
> tmpprog = fluid_channel_get_prognum(channel);
> /* See if this bank has a valid instrument at 0
*/
> preset = fluid_synth_find_preset(channel->synth,
tmpbank, 0);
> /* See if this bank has a valid instrument at
tmpprog */
> preset2 =
fluid_synth_find_preset(channel->synth, tmpbank,
tmpprog);
>
> /* If it seems like a valid band, then change it
*/
> if ((preset) || (preset2)) {
>
fluid_channel_set_banknum(synth->channel[chan],
tmpbank);
> }
> else {
> FLUID_LOG(FLUID_WARN, "Ignoring invalid bank
select (channel=%d,bank=%d)", chan, tmpbank);
> }
1270a1305,1306
> FLUID_LOG(FLUID_INFO, "program select --- ---
(banknum=%d,preset_num=%d)", bank_num, preset_num);
>
1308a1345,1346
> FLUID_LOG(FLUID_INFO, "program select2 --- ---
(banknum=%d,preset_num=%d)", bank_num, preset_num);
>
diff -r fluidsynth.svn.20071227/src/fluid_synth.h
fluidsynth.test/src/fluid_synth.h
48c48
< #define DRUM_INST_MASK ((unsigned
int)0x80000000)
---
> #define DRUM_INST_MASK ((unsigned int)128)
____________________________________________________________________________________
Looking for last minute shopping deals?
Find them fast with Yahoo! Search.
http://tools.search.yahoo.com/newsearch/category.php?category=shopping
diff -r fluidsynth.svn.20071227/src/fluid_chan.c
fluidsynth.test/src/fluid_chan.c
175,176c175,187
< chan->banknum = banknum;
< return FLUID_OK;
---
> int tmpchan;
> unsigned int tmpbanknum;
>
> if (chan) {
> tmpchan = fluid_channel_get_num(chan);
> tmpbanknum = banknum;
> if ((tmpchan == 9) && (tmpbanknum < DRUM_INST_MASK)) {
> tmpbanknum = tmpbanknum | DRUM_INST_MASK;
> }
> chan->banknum = tmpbanknum;
> return FLUID_OK;
> }
> return FLUID_FAILED;
diff -r fluidsynth.svn.20071227/src/fluid_synth.c
fluidsynth.test/src/fluid_synth.c
1171a1172
> unsigned int tmpbank;
1175a1177,1178
>
>
1180d1182
< banknum = fluid_channel_get_banknum(channel);
1182,1183c1184,1185
< /* inform the channel of the new program number */
< fluid_channel_set_prognum(channel, prognum);
---
> banknum = fluid_channel_get_banknum(channel);
> preset = fluid_synth_find_preset(synth, banknum, prognum);
1193,1198c1195,1198
< /* try to search the drum instrument first */
< preset = fluid_synth_find_preset(synth, banknum | DRUM_INST_MASK,
prognum);
<
< /* if that fails try to search the melodic instrument */
< if (preset == NULL) {
< preset = fluid_synth_find_preset(synth, banknum, prognum);
---
> /* try to search the drum instrument, drum bank number starts from 128
> (DRUM_INST_MASK) */
> tmpbank = banknum;
> if (tmpbank < DRUM_INST_MASK) {
> tmpbank = tmpbank | DRUM_INST_MASK;
1199a1200
> preset = fluid_synth_find_preset(synth, tmpbank, prognum);
1205,1207c1206,1214
< sfont_id = preset? fluid_sfont_get_id(preset->sfont) : 0;
< fluid_channel_set_sfontnum(channel, sfont_id);
< fluid_channel_set_preset(channel, preset);
---
> if (preset) {
> sfont_id = fluid_sfont_get_id(preset->sfont);
> fluid_channel_set_sfontnum(channel, sfont_id);
> fluid_channel_set_preset(channel, preset);
> fluid_channel_set_prognum(channel, prognum);
> }
> else {
> FLUID_LOG(FLUID_WARN, "Ignoring invalid prog\t%d\t%d\t%d", chan,
> banknum, prognum);
> }
1220a1228,1236
>
> fluid_preset_t* preset = NULL;
> fluid_preset_t* preset2 = NULL;
> fluid_channel_t* channel;
> unsigned int tmpbank;
> unsigned int tmpprog;
>
> tmpbank = bank;
>
1222c1238,1256
< fluid_channel_set_banknum(synth->channel[chan], bank);
---
> channel = synth->channel[chan];
>
> if ((channel) && (channel->channum == 9) && (bank < DRUM_INST_MASK)) {
> tmpbank = tmpbank + DRUM_INST_MASK;
> }
>
> tmpprog = fluid_channel_get_prognum(channel);
> /* See if this bank has a valid instrument at 0 */
> preset = fluid_synth_find_preset(channel->synth, tmpbank, 0);
> /* See if this bank has a valid instrument at tmpprog */
> preset2 = fluid_synth_find_preset(channel->synth, tmpbank, tmpprog);
>
> /* If it seems like a valid band, then change it */
> if ((preset) || (preset2)) {
> fluid_channel_set_banknum(synth->channel[chan], tmpbank);
> }
> else {
> FLUID_LOG(FLUID_WARN, "Ignoring invalid bank select
> (channel=%d,bank=%d)", chan, tmpbank);
> }
1270a1305,1306
> FLUID_LOG(FLUID_INFO, "program select --- --- (banknum=%d,preset_num=%d)",
> bank_num, preset_num);
>
1308a1345,1346
> FLUID_LOG(FLUID_INFO, "program select2 --- --- (banknum=%d,preset_num=%d)",
> bank_num, preset_num);
>
diff -r fluidsynth.svn.20071227/src/fluid_synth.h
fluidsynth.test/src/fluid_synth.h
48c48
< #define DRUM_INST_MASK ((unsigned int)0x80000000)
---
> #define DRUM_INST_MASK ((unsigned int)128)
- [fluid-dev] invalid instrument/drum selection problem, jimmy, 2008/01/02
- Re: [fluid-dev] invalid instrument/drum selection problem, Julien Claassen, 2008/01/03
- Re: [fluid-dev] invalid instrument/drum selection problem, jimmy, 2008/01/03
- Re: [fluid-dev] invalid instrument/drum selection problem, Josh Green, 2008/01/03
- Re: [fluid-dev] invalid instrument/drum selection problem, jimmy, 2008/01/03
- Re: [fluid-dev] invalid instrument/drum selection problem, jimmy, 2008/01/06
- Re: [fluid-dev] invalid instrument/drum selection problem,
jimmy <=
- Re: [fluid-dev] invalid instrument/drum selection problem, Josh Green, 2008/01/07
- Re: [fluid-dev] invalid instrument/drum selection problem, jimmy, 2008/01/07
- Re: [fluid-dev] invalid instrument/drum selection problem, Josh Green, 2008/01/07
- Re: [fluid-dev] invalid instrument/drum selection problem, jimmy, 2008/01/07
- Re: [fluid-dev] invalid instrument/drum selection problem, jimmy, 2008/01/07
- Re: [fluid-dev] invalid instrument/drum selection problem, Josh Green, 2008/01/07
- Re: [fluid-dev] invalid instrument/drum selection problem, Bernhard Schelling, 2008/01/07
- Re: [fluid-dev] invalid instrument/drum selection problem, Josh Green, 2008/01/09
- Re: [fluid-dev] invalid instrument/drum selection problem, Edenyard, 2008/01/09
- Re: [fluid-dev] invalid instrument/drum selection problem, Josh Green, 2008/01/09