fluid-dev
[Top][All Lists]
Advanced

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

[fluid-dev] About sustain and sostenuto pedal


From: jean-jacques.ceresa
Subject: [fluid-dev] About sustain and sostenuto pedal
Date: Wed, 04 Feb 2015 19:42:09 +0100
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130911 Thunderbird/17.0.9

Hi,

Fluidsynth actualy supports sustain pedal (cc 64) but it seems not supports sostenuto pedal (cc 66).
As sostenuto pedal effect is great (as FluidSynth is !)  I'am currently working to add sostenuto pedal support.

Before returning this work I need to be confirmation on a function behavior I disagree ligthly
(see fluid_synth_release_voice_on_same_note_LOCAL() below ) .

On noteOn context, the function , is useful to release previous playing note (with same channel,key ).
(Note this function is only called on noteOn messages context).

/*
 * If the same note is hit twice on the same channel, then the older
 * voice process is advanced to the release stage.  Using a mechanical
 * MIDI controller, the only way this can happen is when the sustain
 * pedal is held.  In this case the behaviour implemented here is
 * natural for many instruments.  Note: One noteon event can trigger
 * several voice processes, for example a stereo sample.  Don't
 * release those...
 * v 1.1.3
*/
static void
fluid_synth_release_voice_on_same_note_LOCAL(fluid_synth_t* synth, int chan,
                                             int key)
{
  int i;
  fluid_voice_t* voice;

  for (i = 0; i < synth->polyphony; i++) {
    voice = synth->voice[i];
    if ( _PLAYING(voice)                    // note is playing on
    && (voice->chan == chan)         // same channel and
    && (voice->key == key)              // same key
    && (fluid_voice_get_id(voice) != synth->noteid))   // (see point 1 below )
    {
      fluid_voice_noteoff(voice);    // Force the note into release volume stage. (see point 2 below )
    }
  }
}


/*
 * fluid_voice_noteoff
 * v 1.1.3
 */
int
fluid_voice_noteoff(fluid_voice_t* voice)
{
  unsigned int at_tick;

  fluid_profile(FLUID_PROF_VOICE_NOTE, voice->ref,0);

  // Sustain the note if peedal is pressed
  if (voice->channel && fluid_channel_sustained(voice->channel)) {
    voice->status = FLUID_VOICE_SUSTAINED;
  }
  else
  { // Force the note into release volume stage
    at_tick = fluid_channel_get_min_note_length_ticks (voice->channel);
    UPDATE_RVOICE_I1(fluid_rvoice_noteoff, at_tick);
    voice->has_noteoff = 1;
  }

  return FLUID_OK;
}

Point 1) See the (fluid_voice_get_id(voice) != synth->noteid) _expression_.
As this function need ONLY to be called on noteOn messages context, this _expression_ is always TRUE,
so it seems superfluous.

Point 2) The goal is to release previous same note. That is to FORCE the note in the release stage, even
if the sustain pedal is currently pressed.
So fluid_voice_noteoff() does the job but  sustain the note if pedal is pressed . So calling
fluid_voice_noteoff() seems unbecoming.
A better choice would be to call only the part of code in fluid_voice_noteoff() that force the note to release stage.

Thanks for your expertise on this 2 points.

Regards
jjc

 







reply via email to

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