jamulus/src/vstmain.cpp

118 lines
3.7 KiB
C++
Raw Normal View History

2010-03-05 07:02:21 +01:00
/******************************************************************************\
2019-06-16 11:30:30 +02:00
* Copyright (c) 2004-2019
2010-03-05 07:02:21 +01:00
*
* Author(s):
* Volker Fischer
*
******************************************************************************
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
\******************************************************************************/
#include "vstmain.h"
/* Implementation *************************************************************/
// this function is required for host to get plugin
AudioEffect* createEffectInstance ( audioMasterCallback AudioMaster )
{
2019-06-16 11:30:30 +02:00
return new CLlconVST ( AudioMaster );
2010-03-05 07:02:21 +01:00
}
CLlconVST::CLlconVST ( audioMasterCallback AudioMaster ) :
2010-03-27 08:44:25 +01:00
AudioEffectX ( AudioMaster, 1, 0 ), // 1 program with no parameters (=0)
Client ( LLCON_DEFAULT_PORT_NUMBER )
2010-03-05 07:02:21 +01:00
{
// stereo input/output
2019-06-16 11:30:30 +02:00
setNumInputs ( 2 );
setNumOutputs ( 2 );
2010-03-05 07:02:21 +01:00
2019-06-16 11:30:30 +02:00
setUniqueID ( 'Llco' );
2010-03-05 07:02:21 +01:00
// capabilities of llcon VST plugin
2019-06-16 11:30:30 +02:00
canProcessReplacing(); // supports replacing output
2010-03-05 07:02:21 +01:00
// set default program name
GetName ( strProgName );
2010-03-28 18:13:58 +02:00
// we want a single shot timer to shut down the connection if no
// processing is done anymore (VST host has stopped the stream)
TimerOnOff.setSingleShot ( true );
2010-03-31 22:11:01 +02:00
TimerOnOff.setInterval ( VST_STOP_TIMER_INTERVAL );
2010-03-28 18:13:58 +02:00
// connect timer event
connect ( &TimerOnOff, SIGNAL ( timeout() ),
this, SLOT ( OnTimerOnOff() ) );
2010-04-06 20:23:10 +02:00
// TODO settings
Client.SetServerAddr ( DEFAULT_SERVER_ADDRESS );
2010-03-05 07:02:21 +01:00
}
bool CLlconVST::GetName ( char* cName )
{
// this name is used for program name, effect name, product string and
// vendor string
2019-06-16 11:30:30 +02:00
vst_strncpy ( cName, "Llcon", kVstMaxEffectNameLen );
return true;
2010-03-05 07:02:21 +01:00
}
2010-03-28 18:13:58 +02:00
void CLlconVST::OnTimerOnOff()
{
// stop client since VST host seems to have stopped
Client.Stop();
2010-03-28 18:13:58 +02:00
}
2010-03-05 07:02:21 +01:00
void CLlconVST::processReplacing ( float** pvIn,
float** pvOut,
VstInt32 iNumSamples )
{
2010-03-31 22:11:01 +02:00
int i, j;
// reset stop timer
TimerOnOff.start();
2010-03-31 22:11:01 +02:00
// check if client is running, if not, start it
if ( !Client.IsRunning() )
{
// set buffer size and start
Client.GetSound()->SetMonoBufferSize ( iNumSamples );
2010-03-31 22:11:01 +02:00
Client.Start();
}
2010-03-05 07:02:21 +01:00
// get pointers to actual buffers
float* pfIn0 = pvIn[0];
float* pfIn1 = pvIn[1];
float* pfOut0 = pvOut[0];
float* pfOut1 = pvOut[1];
2010-03-31 22:11:01 +02:00
// copy input data
for ( i = 0, j = 0; i < iNumSamples; i++, j += 2 )
{
2010-04-06 20:16:35 +02:00
Client.GetSound()->vecsTmpAudioSndCrdStereo[j] = pfIn0[i];
Client.GetSound()->vecsTmpAudioSndCrdStereo[j + 1] = pfIn1[i];
2010-03-31 22:11:01 +02:00
}
2010-03-05 07:02:21 +01:00
2010-03-31 22:11:01 +02:00
// call processing callback function
2010-04-06 20:16:35 +02:00
Client.GetSound()->VSTProcessCallback();
2010-03-05 07:02:21 +01:00
2010-03-31 22:11:01 +02:00
// copy output data
for ( i = 0, j = 0; i < iNumSamples; i++, j += 2 )
2010-03-05 07:02:21 +01:00
{
2010-04-06 20:16:35 +02:00
pfOut0[i] = Client.GetSound()->vecsTmpAudioSndCrdStereo[j];
pfOut1[i] = Client.GetSound()->vecsTmpAudioSndCrdStereo[j + 1];
2010-03-05 07:02:21 +01:00
}
}