[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 11:44:31 -0800 (PST) |
Hi Josh,
I couldn't do much with Stygmorgan and a few styles I
wanted to try, using Qsynth/FluidSynth. As a side
note, Timidity gives me some wicked distortion/noise
on some fast notes and synth-instruments. FluidSynth
handles it well with no distortion that I can tell.
So I tried the folowing code, it falls back to use
default drumset if the requested drumset is not found.
It doesn't address other instruments (non-drums) at
all, will wait for you patch ;-)
Actually if you have a better, or more efficient way
for instrument validation, please use that. I'm only
hacking it for the drums right now. Keep in mind I
don't know much of the code base at all.
Best regards,
Jimmy
----- changes in src/fluid_synth.c -----
/*
* fluid_synth_program_change
*/
int
fluid_synth_program_change(fluid_synth_t* synth, int
chan, int prognum)
{
fluid_preset_t* preset = NULL;
fluid_channel_t* channel;
unsigned int banknum;
unsigned int sfont_id;
unsigned int tmpbank;
unsigned int tmpprog;
/* fluid_mutex_lock(synth->busy); /\* Don't
interfere with the audio thread *\/ */
/* fluid_mutex_unlock(synth->busy); */
if ((prognum >= 0) && (prognum < FLUID_NUM_PROGRAMS)
&&
(chan >= 0) && (chan < synth->midi_channels)) {
channel = synth->channel[chan];
banknum = fluid_channel_get_banknum(channel);
/* inform the channel of the new program number */
fluid_channel_set_prognum(channel, prognum);
if (synth->verbose) {
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
10 is the percussion channel. */
if (channel->channum == 9) {
/* try to search the drum instrument first */
tmpbank = banknum | DRUM_INST_MASK;
tmpprog = prognum;
preset = fluid_synth_find_preset(synth, tmpbank,
tmpprog);
/* if that fails try to use specified soundbank
*/
if (preset == NULL) {
tmpbank = banknum;
tmpprog = prognum;
preset = fluid_synth_find_preset(synth,
banknum, prognum);
}
/* if that fails try to use instrument 0 of
specified soundbank */
if (preset == NULL) {
tmpbank = banknum;
tmpprog = 0;
preset = fluid_synth_find_preset(synth,
banknum, 0);
if (synth->verbose) {
if (preset) {
FLUID_LOG(FLUID_WARN, "prog\t%d\t%d\t%d
requested, no instrument found, substituted with:
prog\t%d\t%d\t%d", chan, banknum, prognum, chan,
tmpbank, tmpprog);
}
}
}
/* if that fails try to use sound bank 128
explicitly, instrument 0 */
if (preset == NULL) {
tmpbank = 128;
tmpprog = 0;
preset = fluid_synth_find_preset(synth,
banknum, 0);
if (synth->verbose) {
if (preset) {
FLUID_LOG(FLUID_WARN, "prog\t%d\t%d\t%d
requested, no instrument found, substituted with:
prog\t%d\t%d\t%d", chan, banknum, prognum, chan,
tmpbank, tmpprog);
}
}
}
/* if that fails try to use sound bank 0,
instrument 0 */
if (preset == NULL) {
tmpbank = 0;
tmpprog = 0;
preset = fluid_synth_find_preset(synth,
banknum, 0);
if (synth->verbose) {
if (preset) {
FLUID_LOG(FLUID_WARN, "prog\t%d\t%d\t%d
requested, no instrument found, substituted with:
prog\t%d\t%d\t%d", chan, banknum, prognum, chan,
tmpbank, tmpprog);
}
}
}
} else {
preset = fluid_synth_find_preset(synth, banknum,
prognum);
}
if (preset) {
sfont_id = fluid_sfont_get_id(preset->sfont);
fluid_channel_set_sfontnum(channel, sfont_id);
fluid_channel_set_preset(channel, preset);
}
return FLUID_OK;
}
FLUID_LOG(FLUID_ERR, "Index out of range (chan=%d,
prog=%d)", chan, prognum);
return FLUID_FAILED;
}
--- Josh Green <address@hidden> wrote:
> Hello Jimmy,
>
> Seems reasonable to me to use the last selected
> instrument when an
> invalid bank and/or program change is received.
> I've added it as ticket
> #8: http://fluidsynth.resonance.org/trac/ticket/8
>
> I'll try and get to this sometime soon, so that you
> can take advantage
> of its benefits. Hopefully you don't mind building
> from subversion,
> until a new release is made. Best regards,
>
> Josh Green
>
>
> On Thu, 2008-01-03 at 05:16 -0800, jimmy wrote:
> > Thanks for the soundfont pointers, I'll try those
> > soundfonts.
> >
> > I still think FluidSynth should "ignores invalid
> > request" rather than void the channel. Imagine a
> > hardware sound-module, or any hardware
> midi-connected
> > keyboard that would silent the channel because you
> > punch in an instrument number that is "out of
> range"
> > like 999 if it has only 100 instruments. That
> would
> > sound really awful, which is what FluidSynth does.
> I
> > don't think I heard anything that awful on any
> > hardware keyboard because it won't play the drums.
> >
> > Sorry, I don't mean to make it sound like an
> attack or
> > a put down in anyway, I hope to see FluidSynth
> improve
> > and be really versatile in MIDI and/or soundfont
> > handling. I think coding wise, this is very
> minimal
> > change for a simple lookup/check for someone
> familiar
> > with the code base. If it bothers me enough, I
> might
> > have to look into doing that myself someday.
> >
> > I'm a newbie at the musical keyboard. I'd rather
> run
> > 2 instances of FluidSynth, hopefully it can reduce
> > memory on soundfont loading on some older
> > desktop/laptop.
> >
> > Besides playing MIDI file and learn to play along.
> I
> > also try to use Qsynth to with 2 instances of
> > FluidSynth - one as a sound module for StyGMorgan,
> the
> > other to play along with a keyboard, or vkeybd.
> With
> > Qsynth, I can try to change the instruments for
> the
> > styles played by StyGMorgan, which can play Yamaha
> > style files directly. For some styles which uses
> a
> > few different drumsets, or different instruments
> in
> > the style variations, I run into the same problem,
> but
> > worse - backing styles are just short MIDI
> segments
> > being looped. Even if I try to change the
> instrument
> > with Qsynth/FluidSynth, it will reset the
> instrument
> > or the drumset at the next loop, or as I select
> > different variation, or fills within the style.
> >
> > If anyone plays the keyboard, you should try
> > StyGMorgan, I just recently tried it. Pretty
> good,
> > still have some rough edges I think, but better
> than
> > anything else on Linux right now as far as style
> > playing for auto accompaniment. There are tons of
> > style files to try, too.
> >
> > Jimmy
> >
> >
> > --- Julien Claassen <address@hidden> wrote:
> >
> > > Hi!
> > > I suppose timidity just should be your choice
> for
> > > simply playing midi-files.
> > > Fluidsynth (and thus qsynth) can play
> midi-files,
> > > but I always felt that
> > > fluidsynth's main-gola was to play sounds
> yourself
> > > and record them or use them
> > > during performance.
> > > But you could use a complete midi-soundfont.
> There
> > > are a few nice ones:
> > > fluidr3, Hubbe64 and a couple more, although
> these
> > > two are the best I found
> > > for free. Really good work they did.
> > > Check out:
> > > http://www.hammersound.net
> > > There you should find both of them. If not jst
> ask
> > > around, I believe the
> > > fluidr3 is around a lot.
> > > About the warning messages: I don't really
> know,
> > > but fluidsynth should have
> > > a debug compilation/configuration option, that
> you
> > > could use.
> > > Kindest regards
> > > Julien
> > >
> > > --------
> > > Music was my first love and it will be my last
> (John
> > > Miles)
> > >
> > > ======== FIND MY WEB-PROJECT AT: ========
> > > http://ltsb.sourceforge.net
> > > the Linux TextBased Studio guide
> > > ======= AND MY PERSONAL PAGES AT: =======
> > > http://www.juliencoder.de
> > >
> >
> >
> >
> >
>
____________________________________________________________________________________
> > Never miss a thing. Make Yahoo your home page.
> > http://www.yahoo.com/r/hs
> >
> >
> > _______________________________________________
> > fluid-dev mailing list
> > address@hidden
> > http://lists.nongnu.org/mailman/listinfo/fluid-dev
> >
>
>
____________________________________________________________________________________
Never miss a thing. Make Yahoo your home page.
http://www.yahoo.com/r/hs
- [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 <=
- Re: [fluid-dev] invalid instrument/drum selection problem, jimmy, 2008/01/06
- 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