fluid-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [fluid-dev] Breath control patch.


From: Peter Gebauer
Subject: Re: [fluid-dev] Breath control patch.
Date: Wed, 18 Feb 2009 16:11:15 +0100
User-agent: Mutt/1.5.18 (2008-05-17)

Hi Chris!

Thanks for your enlightening reposponse. I have been reading up on
midi and soundfonts since this post, the major problem is that
none of the soundfonts I've found so far has this modulator.
Also, there's no code in fluidsynth for handling controller change
for breath that I can see, but I'm a fluidsynth and C novice by all 
standards.

I have now rewritten the code to only change voices for the channel
and make sure that the voice is indeed playing. Here's the latest version:

int
fluid_voice_set_attenuation(fluid_voice_t* voice, int val)
{
    if (_ON(voice)) {
        fluid_gen_set_mod(&voice->gen[GEN_ATTENUATION], 0.0);
        fluid_voice_gen_set(voice, GEN_ATTENUATION, 1440.0 * (1.0 - val / 
127.0));
        fluid_voice_update_param(voice, GEN_ATTENUATION);
    }
    return FLUID_OK;
}

It's called from the fluid_chan_cc switch statement.

It basically does what fluid_voice_modulate does. To make a proper
modulator support I'd have to define enumerations for the modulator
and so on, this was just a quick and dirty hack to test the EWI.
I'd love it if someone more experienced with fluidsynth would consider
adding breath modulator with some defaults if the soundfont does not
define it. For instance, it's confusing that a Saxophone-like EWI
does not work properly with the GM Saxophone instrument.

My testing abilities are severily limited due to the fact that I've
borrowed an EWI for a few hours and now have no access to one. I'm
currently testing with a simple midi sequence that sends controller
change for breath (0x02). What little testing I have done with an
actual EWI showed good results. As long as the volume envelope sustain 
value isn't too low and the instrument has no decay before noteoff it works 
very nicely!

Best regards, Peter


On 2009-02-17 (Tue) 12:03, S. Christian Collins wrote:
> Peter,
>
> In this case, FluidSynth behaves exactly as it should.  If you want the  
> breath controller (CC2) to adjust volume, then you will need to specify  
> that as a modulator in the SoundFont you wish to control.  When such a  
> modulator is created, FluidSynth will control the volume using the  
> breath controller.  It is done this way so that other parameters may be  
> controlled by the breath controller, not just volume.
>
> -~Chris
>
> Peter Gebauer wrote:
>> (if this post appears twice it's because I had the wrong return path-before,
>> wanted to make sure it got posted properly)
>>
>> Hi guys!
>>
>> I was experimenting with a friend's EWI (Electronic Wind Instrument) and
>> the breath controller didn't update the output volume after note on.
>>
>> Anyway, I browsed the source code and decided to write a hack that changes
>> attenuation based on note on velocity and the controller value.
>> Here's what I have so far, it "works", but as you can see a lot of things
>> are missing, like changing voices for the current channel only, etc.
>>
>> int
>> fluid_channel_breath_attenuation(fluid_channel_t* chan, int val)
>> {
>>     fluid_synth_t* synth;
>>     int i;
>>     int vel;
>>     float value;
>>     fluid_voice_t* voice;
>>     synth = chan->synth;
>>     for (i = 0; i < synth->polyphony; i++) {
>>         voice = synth->voice[i];
>>         vel = fluid_voice_gen_get(voice, GEN_VELOCITY);
>>         value = 1920.0 * (1.0 - (val - vel) / 127.0) - 960.0;
>>         fluid_voice_gen_set(voice, GEN_ATTENUATION, value);
>>         fluid_voice_update_param(voice, GEN_ATTENUATION);
>>     }
>>     return FLUID_OK;
>> }
>>
>> Any hints on how to improve this snippet would be useful.
>> I'm not good with C and I just started looking at fluidsynth yesterday,
>> so I'm expecting a lot of useful feedback. :)
>>
>> Thanks!
>>
>>
>>
>> _______________________________________________
>> fluid-dev mailing list
>> address@hidden
>> http://lists.nongnu.org/mailman/listinfo/fluid-dev
>>
>>   

> _______________________________________________
> fluid-dev mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/fluid-dev





reply via email to

[Prev in Thread] Current Thread [Next in Thread]