[SCM] calf/master: + Organ: fixed HOLD controller (it used to release even those notes which were still held on the keyboard)

js at users.alioth.debian.org js at users.alioth.debian.org
Tue May 7 15:36:52 UTC 2013


The following commit has been merged in the master branch:
commit b2526c0a437ad7c1f818cef630b5442ab02ec2f2
Author: kfoltman <kfoltman at 78b06b96-2940-0410-b7fc-879d825d01d8>
Date:   Wed Jan 2 10:57:12 2008 +0000

    + Organ: fixed HOLD controller (it used to release even those notes which were still held on the keyboard)
    
    
    
    git-svn-id: https://calf.svn.sourceforge.net/svnroot/calf/trunk@65 78b06b96-2940-0410-b7fc-879d825d01d8

diff --git a/src/calf/synth.h b/src/calf/synth.h
index eb0bbb4..a9fba28 100644
--- a/src/calf/synth.h
+++ b/src/calf/synth.h
@@ -24,6 +24,7 @@
 
 #include <list>
 #include <stack>
+#include <bitset>
 #include "primitives.h"
 #include "audio_fx.h"
 
@@ -134,6 +135,7 @@ protected:
     bool hold, sostenuto;
     std::list<synth::voice *> active_voices;
     std::stack<synth::voice *> unused_voices;
+    std::bitset<128> gate;
 
     void kill_note(int note, int vel, bool just_one);
 public:
@@ -148,11 +150,7 @@ public:
     virtual void note_on(int note, int vel);
     virtual void first_note_on(int note, int vel) {}
     virtual void control_change(int ctl, int val);
-    virtual void note_off(int note, int vel) {
-        if (keystack.pop(note)) {
-            kill_note(note, vel, keystack_hold.has(note));
-        }        
-    }
+    virtual void note_off(int note, int vel);
     virtual ~basic_synth();
 };
 
diff --git a/src/synth.cpp b/src/synth.cpp
index 943e5f5..faef707 100644
--- a/src/synth.cpp
+++ b/src/synth.cpp
@@ -65,6 +65,7 @@ void basic_synth::note_on(int note, int vel)
         keystack_hold.push(note);
     else
         keystack.push(note);
+    gate.set(note);
     v->note_on(note, vel);
     active_voices.push_back(v);
     if (perc) {
@@ -72,7 +73,13 @@ void basic_synth::note_on(int note, int vel)
     }
 }
 
-
+void basic_synth::note_off(int note, int vel) {
+    gate.reset(note);
+    if (keystack.pop(note)) {
+        kill_note(note, vel, keystack_hold.has(note));
+    }        
+}
+    
 void basic_synth::control_change(int ctl, int val)
 {
     if (ctl == 64) { // HOLD controller
@@ -81,8 +88,15 @@ void basic_synth::control_change(int ctl, int val)
         if (!hold && prev && !sostenuto) {
             // HOLD was released - release all keys which were previously held
             for (int i=0; i<keystack_hold.count(); i++) {
-                kill_note(keystack_hold.nth(i), 0, false);
+                int note = keystack_hold.nth(i);
+                if (!gate.test(note)) {
+                    kill_note(note, 0, false);
+                    keystack_hold.pop(note);
+                    i--;
+                }
             }
+            for (int i=0; i<keystack_hold.count(); i++)
+                keystack.push(keystack_hold.nth(i));
             keystack_hold.clear();
         }
     }

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list