fluid-dev
[Top][All Lists]
Advanced

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

[fluid-dev] Propose change: all_notes_off, all_sounds_off


From: jimmy
Subject: [fluid-dev] Propose change: all_notes_off, all_sounds_off
Date: Tue, 25 Jan 2011 15:23:14 -0800 (PST)

Propose changes for handling of "All notes off", "All sounds off".

GOAL FOR THIS PATCH:
--------------------
Turn off all notes/sounds on all channels at once.

If FluidSynth allows the parameter "chan" value -1 to mean operate on all 
channels, it is a reasonably simple and efficient change.
--------------------


The code changes are in:

   static int fluid_synth_all_notes_off_LOCAL(fluid_synth_t* synth, int chan)
   static int fluid_synth_all_sounds_off_LOCAL(fluid_synth_t* synth, int chan)

will affect behaviors of:

   int fluid_synth_all_notes_off(fluid_synth_t* synth, int chan)
   int fluid_synth_all_sounds_off(fluid_synth_t* synth, int chan)

the main difference between the two functions are:

   fluid_synth_all_notes_off() will calls fluid_voice_noteoff();
   fluid_synth_all_sounds_off_LOCAL() will calls fluid_voice_off(();

although, I don't know what's the differences between fluid_voice_noteoff(), 
and fluid_voice_off();

---

Previously, "All notes off", "All sounds off" will only operate on individual 
channel.

To do so for 16, 32, 48, 64 channels, one has to loop through for each channel. 
 Not too bad, but looking at the implementation, it is just not effecient at 
all.

This patch is based on somewhat dated fluidsynth.svn399.20101221 (5 week old) 
code.

Let's hear if this is a reasonable change to the code base, or not.

Jimmy

----- Patch starts below: -----
diff -ur fluidsynth.svn399.20101221/src/synth/fluid_synth.c 
fluidsynth.svn399.20101221.jnAllSoundsOff/src/synth/fluid_synth.c
--- fluidsynth.svn399.20101221/src/synth/fluid_synth.c  2010-12-21 
19:02:53.000000000 -0500
+++ fluidsynth.svn399.20101221.jnAllSoundsOff/src/synth/fluid_synth.c   
2011-01-25 12:57:46.000000000 -0500
@@ -1455,7 +1455,7 @@
 /**
  * Turn off all notes on a MIDI channel (put them into release phase).
  * @param synth FluidSynth instance
- * @param chan MIDI channel number (0 to MIDI channel count - 1)
+ * @param chan MIDI channel number (0 to MIDI channel count - 1), (chan=-1 
selects all channels)
  * @return FLUID_OK on success, FLUID_FAILED otherwise
  */
 int
@@ -1467,7 +1467,7 @@
   return fluid_synth_all_notes_off_LOCAL (synth, chan);
 }
 
-/* Local synthesis thread variant of all notes off */
+/* Local synthesis thread variant of all notes off, (chan=-1 selects all 
channels) */
 static int
 fluid_synth_all_notes_off_LOCAL(fluid_synth_t* synth, int chan)
 {
@@ -1477,7 +1477,7 @@
   for (i = 0; i < synth->polyphony; i++) {
     voice = synth->voice[i];
 
-    if (_PLAYING(voice) && (voice->chan == chan))
+    if (_PLAYING(voice) && ((-1 == chan) || (chan == voice->chan)))
       fluid_voice_noteoff(voice);
   }
   return FLUID_OK;
@@ -1486,7 +1486,7 @@
 /**
  * Immediately stop all notes on a MIDI channel (skips release phase).
  * @param synth FluidSynth instance
- * @param chan MIDI channel number (0 to MIDI channel count - 1)
+ * @param chan MIDI channel number (0 to MIDI channel count - 1), (chan=-1 
selects all channels)
  * @return FLUID_OK on success, FLUID_FAILED otherwise
  */
 int
@@ -1499,7 +1499,7 @@
   FLUID_API_RETURN(result);
 }
 
-/* Local synthesis thread variant of all sounds off */
+/* Local synthesis thread variant of all sounds off, (chan=-1 selects all 
channels) */
 static int
 fluid_synth_all_sounds_off_LOCAL(fluid_synth_t* synth, int chan)
 {
@@ -1509,7 +1509,7 @@
   for (i = 0; i < synth->polyphony; i++) {
     voice = synth->voice[i];
 
-    if (_PLAYING(voice) && (voice->chan == chan))
+    if (_PLAYING(voice) && ((-1 == chan) || (chan == voice->chan)))
       fluid_voice_off(voice);
   }
   return FLUID_OK;
----- Patch ended above -----




      



reply via email to

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