From 50c2242caad44c5ccf684e6bc6c287e31189ba0b Mon Sep 17 00:00:00 2001 From: Mike Choi Date: Mon, 11 Feb 2013 00:19:08 +0100 Subject: [PATCH] VST sync patch: compatibility fix for 64bit builds It seems 64bit builds for some reason have problems with VST Sync feature on, workaround seems to be converting VST sync patch from double to floats, which does work both with 32 and 64bit builds. Double precision seems to produce odd numbers with 64bit build. (tested on VirtualBox Linux Mint 14.1 64 bit OS) (cherry picked from commit 011f87e6e60cccd16f3783e9c4885e03d95c1e56) Signed-off-by: Tobias Doerffel --- include/VST_sync_shm.h | 8 ++++---- plugins/vst_base/RemoteVstPlugin.cpp | 6 +++--- src/core/song.cpp | 18 +++++++++--------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/include/VST_sync_shm.h b/include/VST_sync_shm.h index 595b21cd9..7b6a813d5 100644 --- a/include/VST_sync_shm.h +++ b/include/VST_sync_shm.h @@ -39,19 +39,19 @@ struct sncVST { bool isPlayin; - double ppqPos; + float ppqPos; int timeSigNumer; int timeSigDenom; bool isCycle; bool hasSHM; - double cycleStart; - double cycleEnd; + float cycleStart; + float cycleEnd; int m_bufferSize; int m_sampleRate; int m_bpm; #ifdef VST_SNC_LATENCY - double m_latency; + float m_latency; #endif } ; diff --git a/plugins/vst_base/RemoteVstPlugin.cpp b/plugins/vst_base/RemoteVstPlugin.cpp index 254d70071..122dda3bc 100644 --- a/plugins/vst_base/RemoteVstPlugin.cpp +++ b/plugins/vst_base/RemoteVstPlugin.cpp @@ -319,8 +319,8 @@ private: // host to plugin synchronisation data structure struct in { - double lastppqPos; - double m_Timestamp; + float lastppqPos; + float m_Timestamp; } ; in * m_in; @@ -1482,7 +1482,7 @@ intptr_t RemoteVstPlugin::hostCallback( AEffect * _effect, int32_t _opcode, __plugin->m_in->lastppqPos += ( __plugin->m_SncVSTplug->hasSHM ? __plugin->m_SncVSTplug->m_bpm : - __plugin->m_bpm ) / (double)10340; + __plugin->m_bpm ) / (float)10340; _timeInfo.ppqPos = __plugin->m_in->lastppqPos; } // _timeInfo.ppqPos = __plugin->m_SncVSTplug->ppqPos; diff --git a/src/core/song.cpp b/src/core/song.cpp index e1ce8ae86..6fdba2b21 100644 --- a/src/core/song.cpp +++ b/src/core/song.cpp @@ -243,7 +243,7 @@ void song::setTempo() #ifdef VST_SNC_LATENCY m_SncVSTplug->m_latency = m_SncVSTplug->m_bufferSize * tempo / - ( (double) m_SncVSTplug->m_sampleRate * 60 ); + ( (float) m_SncVSTplug->m_sampleRate * 60 ); #endif emit tempoChanged( tempo ); @@ -471,7 +471,7 @@ void song::processNextBuffer() #ifdef VST_SNC_LATENCY m_SncVSTplug->m_latency = m_SncVSTplug->m_bufferSize * m_SncVSTplug->m_bpm / - ( (double) m_SncVSTplug->m_sampleRate * 60 ); + ( (float) m_SncVSTplug->m_sampleRate * 60 ); #endif float current_frame = m_playPos[m_playMode].currentFrame(); @@ -482,10 +482,10 @@ void song::processNextBuffer() + (int)( current_frame / frames_per_tick ); #ifdef VST_SNC_LATENCY - m_SncVSTplug->ppqPos = ( ( ticks + 0 ) / (double)48 ) - + m_SncVSTplug->ppqPos = ( ( ticks + 0 ) / (float)48 ) - m_SncVSTplug->m_latency; #else - m_SncVSTplug->ppqPos = ( ( ticks + 0 ) / (double)48 ); + m_SncVSTplug->ppqPos = ( ( ticks + 0 ) / (float)48 ); #endif // did we play a whole tact? @@ -523,11 +523,11 @@ void song::processNextBuffer() midiTime::ticksPerTact() ); #ifdef VST_SNC_LATENCY m_SncVSTplug->ppqPos = ( ( ticks + 0 ) - / (double)48 ) + / (float)48 ) - m_SncVSTplug->m_latency; #else m_SncVSTplug->ppqPos = ( ( ticks + 0 ) - / (double)48 ); + / (float)48 ); #endif } } @@ -538,10 +538,10 @@ void song::processNextBuffer() m_SncVSTplug->isCycle = true; m_SncVSTplug->cycleStart = ( tl->loopBegin().getTicks() ) - / (double)48; + / (float)48; m_SncVSTplug->cycleEnd = ( tl->loopEnd().getTicks() ) - / (double)48; + / (float)48; if( m_playPos[m_playMode] >= tl->loopEnd() ) { m_playPos[m_playMode].setTicks( @@ -1362,7 +1362,7 @@ void song::updateSampleRateSHM() #ifdef VST_SNC_LATENCY m_SncVSTplug->m_latency = m_SncVSTplug->m_bufferSize * m_SncVSTplug->m_bpm / - ( (double) m_SncVSTplug->m_sampleRate * 60 ); + ( (float) m_SncVSTplug->m_sampleRate * 60 ); #endif }