Here is a newer version of the pitch bend patch. I've seen through
experimenting (myself, and two friends who also mix the same style of
music) that ramping back on release is a pretty bad idea. Right now
the sensitivity is dependent on the latency. ATM my latency is 25 ms.

I'll be sending another patch later. This one is merely a sample, as
well as hopefully something for asantoni to play with.

Later I'll send patches that configure the back and fwd buttons on the
M-Audio XSession Pro to alternate between pitch bend (while the track
is playing) and search when the track is paused. This is all done via
MIDIScript.

-- 
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS d- s+:- a-- C+++(++++)$ UL+++$ P+ L+++>++++ E W++ N o?
K- w++(---) O? M-- V PS+++ PE-(--) Y+(++) PGP t(+) 5(+) X++
R b+>++ DI+ D+ G e h-(--) r y+
------END GEEK CODE BLOCK------
Index: src/engine/enginebuffer.cpp
===================================================================
--- src/engine/enginebuffer.cpp	(revision 2670)
+++ src/engine/enginebuffer.cpp	(working copy)
@@ -49,6 +49,7 @@
     m_pOtherEngineBuffer = 0;
 
     m_bTempPress = false;
+    m_bTempRelease = false;
 
     m_dAbsPlaypos = 0.;
     m_dBufferPlaypos = 0.;
@@ -620,13 +621,15 @@
     if (buttonRateTempDown->get() && !m_bTempPress)
     {
         m_bTempPress = true;
-        m_dOldRate = rateSlider->get();
-        rateSlider->sub(m_pRateDir->get() * m_dTemp / (100. * m_pRateRange->get()));
+        m_dTempRateChange = m_pRateDir->get() * m_dTemp / (100. * m_pRateRange->get()) / RATE_TEMP_STEP;
+        
+        if ( ! m_bTempRelease )
+            m_dOldRate = rateSlider->get();
     }
     else if (!buttonRateTempDown->get())
     {
         m_bTempPress = false;
-        rateSlider->set(m_dOldRate);
+        m_bTempRelease = true;
     }
 }
 
@@ -636,13 +639,15 @@
     if (buttonRateTempDownSmall->get() && !m_bTempPress)
     {
         m_bTempPress = true;
-        m_dOldRate = rateSlider->get();
-        rateSlider->sub(m_pRateDir->get() * m_dTempSmall / (100. * m_pRateRange->get()));
+        m_dTempRateChange = m_pRateDir->get() * m_dTemp / (100. * m_pRateRange->get()) / RATE_TEMP_STEP_SMALL;
+        
+        if ( ! m_bTempRelease )
+            m_dOldRate = rateSlider->get();
     }
     else if (!buttonRateTempDownSmall->get())
     {
         m_bTempPress = false;
-        rateSlider->set(m_dOldRate);
+        m_bTempRelease = true;
     }
 }
 
@@ -652,13 +657,15 @@
     if (buttonRateTempUp->get() && !m_bTempPress)
     {
         m_bTempPress = true;
-        m_dOldRate = rateSlider->get();
-        rateSlider->add(m_pRateDir->get() * m_dTemp / (100. * m_pRateRange->get()));
+        m_dTempRateChange = m_pRateDir->get() * m_dTemp / (100. * m_pRateRange->get()) / RATE_TEMP_STEP;
+        
+        if ( ! m_bTempRelease )
+            m_dOldRate = rateSlider->get();
     }
     else if (!buttonRateTempUp->get())
     {
         m_bTempPress = false;
-        rateSlider->set(m_dOldRate);
+        m_bTempRelease = true;
     }
 }
 
@@ -668,13 +675,15 @@
     if (buttonRateTempUpSmall->get() && !m_bTempPress)
     {
         m_bTempPress = true;
-        m_dOldRate = rateSlider->get();
-        rateSlider->add(m_pRateDir->get() * m_dTempSmall / (100. * m_pRateRange->get()));
+        m_dTempRateChange = m_pRateDir->get() * m_dTemp / (100. * m_pRateRange->get()) / RATE_TEMP_STEP_SMALL;
+        
+        if ( ! m_bTempRelease )
+            m_dOldRate = rateSlider->get();
     }
     else if (!buttonRateTempUpSmall->get())
     {
         m_bTempPress = false;
-        rateSlider->set(m_dOldRate);
+        m_bTempRelease = true;
     }
 }
 
@@ -977,6 +986,43 @@
             rate_old = rate;
         }
 
+        // Change Rate if we're holding one of the Pitch Bend buttons
+        if ( m_bTempPress ) {
+            if ( buttonRateTempUp->get())
+                rateSlider->add(m_dTempRateChange);
+            if ( buttonRateTempDown->get())
+                rateSlider->sub(m_dTempRateChange);
+        }
+        // Check if we are returning to the original rate
+        // to ramp back down the pitch bend
+        else if ((m_bTempRelease)) {
+            // ramping back towards the old rate
+            /*
+            if (rateSlider->get() != m_dOldRate ) {
+                double temp_rate;
+                double temp_change;
+                
+                
+                temp_rate = rateSlider->get();
+                temp_change = m_dTempRateChange * 4;
+                
+                temp_change = ( temp_change > fabs( temp_rate - m_dOldRate ) ?
+                                fabs( temp_rate - m_dOldRate ) : temp_change );
+                
+                // see which way we ramp to go back to the original value
+                if ( temp_rate < m_dOldRate )
+                    rateSlider->add(temp_change);
+                else
+                    rateSlider->sub(temp_change);
+            }
+            // back at the old rate... reset
+            else
+            */
+            
+            m_bTempRelease = false;
+            rateSlider->set(m_dOldRate);
+        }
+
         bool at_start = false;
         bool at_end = false;
 
Index: src/engine/enginebuffer.h
===================================================================
--- src/engine/enginebuffer.h	(revision 2670)
+++ src/engine/enginebuffer.h	(working copy)
@@ -60,6 +60,10 @@
 // stopped or started.
 const int kiRampLength = 50;
 
+// Rate Temp Step for Ramping Pitch Bend
+// Sets the amount of steps the Ramping pitch bend takes per sample
+const int RATE_TEMP_STEP = 8.;
+const int RATE_TEMP_STEP_SMALL = RATE_TEMP_STEP * 10.;
 
 class EngineBuffer : public EngineObject
 {
@@ -160,6 +164,10 @@
     static double m_dTemp, m_dTempSmall, m_dPerm, m_dPermSmall;
     /** Is true if a rate temp button is pressed */
     double m_bTempPress;
+    /** Is true if a rate button was released */
+    bool m_bTempRelease;
+    /** Set to the rate change used for rate temp */
+    double m_dTempRateChange;
 
     ControlPushButton *playButton, *audioBeatMark, *buttonBeatSync;
     ControlPushButton *buttonRateTempDown, *buttonRateTempDownSmall, *buttonRateTempUp, *buttonRateTempUpSmall;
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Mixxx-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mixxx-devel

Reply via email to