This commit is contained in:
Raine M. Ekman
2014-02-03 22:09:56 +02:00
13 changed files with 403 additions and 354 deletions

View File

@@ -27,7 +27,7 @@
#include "export.h"
#include "MidiEvent.h"
#include "VST_sync_shm.h"
#include "VstSyncData.h"
#include <vector>
#include <cstdio>
@@ -813,7 +813,7 @@ public:
RemotePluginClient( key_t _shm_in, key_t _shm_out );
virtual ~RemotePluginClient();
#ifdef USE_QT_SHMEM
sncVST * getQtVSTshm();
VstSyncData * getQtVSTshm();
#endif
virtual bool processMessage( const message & _m );
@@ -883,7 +883,7 @@ private:
QSharedMemory m_shmObj;
QSharedMemory m_shmQtID;
#endif
sncVST * m_SncVSTplug;
VstSyncData * m_vstSyncData;
float * m_shm;
int m_inputCount;
@@ -1013,7 +1013,7 @@ RemotePluginClient::RemotePluginClient( key_t _shm_in, key_t _shm_out ) :
m_shmObj(),
m_shmQtID( "/usr/bin/lmms" ),
#endif
m_SncVSTplug( NULL ),
m_vstSyncData( NULL ),
m_shm( NULL ),
m_inputCount( 0 ),
m_outputCount( 0 ),
@@ -1023,9 +1023,9 @@ RemotePluginClient::RemotePluginClient( key_t _shm_in, key_t _shm_out ) :
#ifdef USE_QT_SHMEM
if( m_shmQtID.attach( QSharedMemory::ReadOnly ) )
{
m_SncVSTplug = (sncVST *) m_shmQtID.data();
m_bufferSize = m_SncVSTplug->m_bufferSize;
m_sampleRate = m_SncVSTplug->m_sampleRate;
m_vstSyncData = (VstSyncData *) m_shmQtID.data();
m_bufferSize = m_vstSyncData->m_bufferSize;
m_sampleRate = m_vstSyncData->m_sampleRate;
return;
}
#else
@@ -1044,18 +1044,18 @@ RemotePluginClient::RemotePluginClient( key_t _shm_in, key_t _shm_out ) :
}
else
{ // attach segment
m_SncVSTplug = (sncVST *)shmat(m_shmID, 0, 0);
if( m_SncVSTplug == (sncVST *)( -1 ) )
m_vstSyncData = (VstSyncData *)shmat(m_shmID, 0, 0);
if( m_vstSyncData == (VstSyncData *)( -1 ) )
{
perror( "RemotePluginClient::shmat" );
}
else
{
m_bufferSize = m_SncVSTplug->m_bufferSize;
m_sampleRate = m_SncVSTplug->m_sampleRate;
m_bufferSize = m_vstSyncData->m_bufferSize;
m_sampleRate = m_vstSyncData->m_sampleRate;
// detach segment
if( shmdt(m_SncVSTplug) == -1 )
if( shmdt(m_vstSyncData) == -1 )
{
perror("RemotePluginClient::shmdt");
}
@@ -1087,9 +1087,9 @@ RemotePluginClient::~RemotePluginClient()
#ifdef USE_QT_SHMEM
sncVST * RemotePluginClient::getQtVSTshm()
VstSyncData * RemotePluginClient::getQtVSTshm()
{
return m_SncVSTplug;
return m_vstSyncData;
}
#endif

View File

@@ -0,0 +1,99 @@
/*
* VstSyncController.h - type declarations needed for VST to lmms host sync
*
* Copyright (c) 2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2013 Mike Choi <rdavidian71/at/gmail/dot/com>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
* 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 (see COPYING); if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
*/
#ifndef VST_SYNC_CONTROLLER_H
#define VST_SYNC_CONTROLLER_H
#include <QtCore/QObject>
#include <QtCore/QSharedMemory>
#include "VstSyncData.h"
class VstSyncController : public QObject
{
Q_OBJECT
public:
VstSyncController();
~VstSyncController();
void setAbsolutePosition( int ticks );
void setPlaybackState( bool enabled )
{
m_syncData->isPlaying = enabled;
}
void setTempo( int newTempo );
void setTimeSignature( int num, int denom )
{
m_syncData->timeSigNumer = num;
m_syncData->timeSigDenom = denom;
}
void startCycle( int startTick, int endTick );
void stopCycle()
{
m_syncData->isCycle = false;
}
void update();
private slots:
void updateSampleRate();
private:
struct VstSyncData
{
bool isPlaying;
float ppqPos;
int timeSigNumer;
int timeSigDenom;
bool isCycle;
bool hasSHM;
float cycleStart;
float cycleEnd;
int m_bufferSize;
int m_sampleRate;
int m_bpm;
#ifdef VST_SNC_LATENCY
float m_latency;
#endif
} ;
VstSyncData* m_syncData;
int m_shmID;
QSharedMemory m_shm;
};
#endif

View File

@@ -1,8 +1,9 @@
/*
* VST_sync_shm.h - type declarations needed for VST to lmms host sync
* VstSyncData.h - type declarations needed for VST to lmms host sync
*
* Copyright (c) 2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2013 Mike Choi <rdavidian71/at/gmail/dot/com>
*
* Copyright (c) 2004-2013 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
* This program is free software; you can redistribute it and/or
@@ -22,8 +23,8 @@
*
*/
#ifndef _VST_SYNC_SHM_H
#define _VST_SYNC_SHM_H
#ifndef VST_SYNC_DATA_H
#define VST_SYNC_DATA_H
// VST sync frequency (in ms), how often will be VST plugin synced
// keep it power of two if possible (not used by now)
@@ -36,9 +37,11 @@
#define VST_SNC_SHM_KEY_FILE "/dev/null"
//#define VST_SNC_SHM_RND_KEY 3561653564469
struct sncVST
struct VstSyncData
{
bool isPlayin;
bool isPlaying;
float ppqPos;
int timeSigNumer;
int timeSigDenom;

View File

@@ -32,7 +32,7 @@
#include "AutomatableModel.h"
#include "Controller.h"
#include "MeterModel.h"
#include "VST_sync_shm.h"
#include "VstSyncController.h"
class AutomationTrack;
class pattern;
@@ -296,8 +296,6 @@ private slots:
void updateFramesPerTick();
void updateSampleRateSHM();
private:
@@ -356,21 +354,8 @@ private:
tick_t m_elapsedTicks;
tact_t m_elapsedTacts;
enum Actions
{
ActionStop,
ActionPlaySong,
ActionPlayTrack,
ActionPlayBB,
ActionPlayPattern,
ActionPause,
ActionResumeFromPause
} ;
QVector<Actions> m_actions;
VstSyncController m_vstSyncController;
int m_shmID;
sncVST * m_SncVSTplug;
QSharedMemory m_shmQtID;
friend class engine;
friend class songEditor;