From d8eb5a9752048a9d7668a7fd3de186cc81939da6 Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Tue, 6 Apr 2010 16:41:30 +0000 Subject: [PATCH] first VST version, unfortunately not working (crashes) --- src/client.h | 5 +++++ src/vstmain.cpp | 22 ++++++++-------------- src/vstsound.h | 22 +++++++++++++--------- 3 files changed, 26 insertions(+), 23 deletions(-) diff --git a/src/client.h b/src/client.h index 82564975..f591db71 100755 --- a/src/client.h +++ b/src/client.h @@ -218,6 +218,11 @@ public: CVector vstrIPAddress; QString strName; +#ifdef LLCON_VST_PLUGIN + // VST version must have direct access to sound object + CSound* GetSound() { return &Sound; } +#endif + protected: // callback function must be static, otherwise it does not work static void AudioCallback ( CVector& psData, void* arg ); diff --git a/src/vstmain.cpp b/src/vstmain.cpp index b4b476dd..fef50e58 100755 --- a/src/vstmain.cpp +++ b/src/vstmain.cpp @@ -84,9 +84,8 @@ void CLlconVST::processReplacing ( float** pvIn, // check if client is running, if not, start it if ( !Client.IsRunning() ) { - -// TODO set iNumSamples in Sound class somehow - + // set buffer size and start + Client.GetSound()->SetMonoBufferSize ( iNumSamples ); Client.Start(); } @@ -99,23 +98,18 @@ void CLlconVST::processReplacing ( float** pvIn, // copy input data for ( i = 0, j = 0; i < iNumSamples; i++, j += 2 ) { -/* - pSound->vecsTmpAudioSndCrdStereo[j] = pfIn0[i]; - pSound->vecsTmpAudioSndCrdStereo[j + 1] = pfIn1[i]; -*/ + (*Client.GetSound()->GetBuffer())[j] = pfIn0[i]; + (*Client.GetSound()->GetBuffer())[j + 1] = pfIn1[i]; } -/* // call processing callback function - pSound->ProcessCallback ( pSound->vecsTmpAudioSndCrdStereo ); -*/ + Client.GetSound()->VSTProcessCallback ( + *Client.GetSound()->GetBuffer() ); // copy output data for ( i = 0, j = 0; i < iNumSamples; i++, j += 2 ) { -/* - pfOut0[i] = pSound->vecsTmpAudioSndCrdStereo[j]; - pfOut1[i] = pSound->vecsTmpAudioSndCrdStereo[j + 1]; -*/ + pfOut0[i] = (*Client.GetSound()->GetBuffer())[j]; + pfOut1[i] = (*Client.GetSound()->GetBuffer())[j + 1]; } } diff --git a/src/vstsound.h b/src/vstsound.h index b018c9ae..f2af3a04 100755 --- a/src/vstsound.h +++ b/src/vstsound.h @@ -35,23 +35,27 @@ class CSound : public CSoundBase { public: CSound ( void (*fpNewCallback) ( CVector& psData, void* arg ), void* arg ) : - CSoundBase ( true, fpNewCallback, arg ) - { - // TODO - } + CSoundBase ( true, fpNewCallback, arg ), iVSTMonoBufferSize ( 0 ) {} + virtual ~CSound() {} - virtual int Init ( const int iNewPrefMonoBufferSize ) + // special VST functions + void SetMonoBufferSize ( const int iNVBS ) { iVSTMonoBufferSize = iNVBS; } + CVector* GetBuffer() { return &vecsAudioSndCrdStereo; } + void VSTProcessCallback ( CVector& psData ) { - // TODO we have to query the current VST frame size somehow - -const int iVSTMonoBufferSize = iNewPrefMonoBufferSize; + CSoundBase::ProcessCallback ( psData ); + } + virtual int Init ( const int ) + { // init base class CSoundBase::Init ( iVSTMonoBufferSize ); - return iVSTMonoBufferSize; } + +protected: + int iVSTMonoBufferSize; }; #endif // !defined ( _VSTSOUND_H__9518A346345768_11D3_8C0D_EEBF182CF549__INCLUDED_ )