Make VST sync always-on and non-global (#6418)
This commit is contained in:
@@ -26,7 +26,6 @@
|
||||
#define REMOTE_PLUGIN_BASE_H
|
||||
|
||||
#include "MidiEvent.h"
|
||||
#include "VstSyncData.h"
|
||||
|
||||
#include <atomic>
|
||||
#include <vector>
|
||||
@@ -352,6 +351,7 @@ enum RemoteMessageIDs
|
||||
IdHostInfoGotten,
|
||||
IdInitDone,
|
||||
IdQuit,
|
||||
IdSyncKey,
|
||||
IdSampleRateInformation,
|
||||
IdBufferSizeInformation,
|
||||
IdInformationUpdated,
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#endif
|
||||
|
||||
#include "SharedMemory.h"
|
||||
#include "VstSyncData.h"
|
||||
|
||||
namespace lmms
|
||||
{
|
||||
@@ -124,8 +125,7 @@ private:
|
||||
void doProcessing();
|
||||
|
||||
SharedMemory<float[]> m_audioBuffer;
|
||||
SharedMemory<const VstSyncData> m_vstSyncShm;
|
||||
const VstSyncData* m_vstSyncData;
|
||||
SharedMemory<const VstSyncData> m_vstSyncData;
|
||||
|
||||
int m_inputCount;
|
||||
int m_outputCount;
|
||||
@@ -182,7 +182,6 @@ RemotePluginClient::RemotePluginClient( const std::string& _shm_in, const std::s
|
||||
RemotePluginClient::RemotePluginClient( const char * socketPath ) :
|
||||
RemotePluginBase(),
|
||||
#endif
|
||||
m_vstSyncData( nullptr ),
|
||||
m_inputCount( 0 ),
|
||||
m_outputCount( 0 ),
|
||||
m_sampleRate( 44100 ),
|
||||
@@ -211,26 +210,6 @@ RemotePluginClient::RemotePluginClient( const char * socketPath ) :
|
||||
fprintf( stderr, "Could not connect to local server.\n" );
|
||||
}
|
||||
#endif
|
||||
|
||||
try
|
||||
{
|
||||
m_vstSyncShm.attach("usr_bin_lmms");
|
||||
m_vstSyncData = m_vstSyncShm.get();
|
||||
m_bufferSize = m_vstSyncData->m_bufferSize;
|
||||
m_sampleRate = m_vstSyncData->m_sampleRate;
|
||||
}
|
||||
catch (const std::runtime_error&)
|
||||
{
|
||||
// if attaching shared memory fails
|
||||
sendMessage( IdSampleRateInformation );
|
||||
sendMessage( IdBufferSizeInformation );
|
||||
if( waitForMessage( IdBufferSizeInformation ).id
|
||||
!= IdBufferSizeInformation )
|
||||
{
|
||||
fprintf( stderr, "Could not get buffer size information\n" );
|
||||
}
|
||||
}
|
||||
sendMessage( IdHostInfoGotten );
|
||||
}
|
||||
|
||||
|
||||
@@ -253,7 +232,7 @@ RemotePluginClient::~RemotePluginClient()
|
||||
|
||||
const VstSyncData* RemotePluginClient::getVstSyncData()
|
||||
{
|
||||
return m_vstSyncData;
|
||||
return m_vstSyncData.get();
|
||||
}
|
||||
|
||||
|
||||
@@ -268,6 +247,22 @@ bool RemotePluginClient::processMessage( const message & _m )
|
||||
case IdUndefined:
|
||||
return false;
|
||||
|
||||
case IdSyncKey:
|
||||
try
|
||||
{
|
||||
m_vstSyncData.attach(_m.getString(0));
|
||||
}
|
||||
catch (const std::runtime_error& error)
|
||||
{
|
||||
debugMessage(std::string{"Failed to attach sync data: "} + error.what() + '\n');
|
||||
std::exit(EXIT_FAILURE);
|
||||
}
|
||||
m_bufferSize = m_vstSyncData->m_bufferSize;
|
||||
m_sampleRate = m_vstSyncData->m_sampleRate;
|
||||
reply_message.id = IdHostInfoGotten;
|
||||
reply = true;
|
||||
break;
|
||||
|
||||
case IdSampleRateInformation:
|
||||
m_sampleRate = _m.getInt();
|
||||
updateSampleRate();
|
||||
|
||||
@@ -95,7 +95,6 @@ private slots:
|
||||
void toggleRunningAutoSave(bool enabled);
|
||||
void toggleSmoothScroll(bool enabled);
|
||||
void toggleAnimateAFP(bool enabled);
|
||||
void toggleSyncVSTPlugins(bool enabled);
|
||||
void vstEmbedMethodChanged();
|
||||
void toggleVSTAlwaysOnTop(bool en);
|
||||
void toggleDisableAutoQuit(bool enabled);
|
||||
@@ -164,7 +163,6 @@ private:
|
||||
QString m_vstEmbedMethod;
|
||||
LedCheckBox * m_vstAlwaysOnTopCheckBox;
|
||||
bool m_vstAlwaysOnTop;
|
||||
bool m_syncVSTPlugins;
|
||||
bool m_disableAutoQuit;
|
||||
|
||||
|
||||
|
||||
@@ -366,6 +366,8 @@ public:
|
||||
void setScale(unsigned int index, std::shared_ptr<Scale> newScale);
|
||||
void setKeymap(unsigned int index, std::shared_ptr<Keymap> newMap);
|
||||
|
||||
const std::string& syncKey() const noexcept { return m_vstSyncController.sharedMemoryKey(); }
|
||||
|
||||
public slots:
|
||||
void playSong();
|
||||
void record();
|
||||
|
||||
@@ -40,45 +40,23 @@ class VstSyncController : public QObject
|
||||
Q_OBJECT
|
||||
public:
|
||||
VstSyncController();
|
||||
~VstSyncController() override;
|
||||
|
||||
void setAbsolutePosition( double 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 setPlaybackJumped( bool jumped )
|
||||
{
|
||||
m_syncData->m_playbackJumped = jumped;
|
||||
}
|
||||
|
||||
void setAbsolutePosition(double ticks);
|
||||
void setPlaybackState(bool enabled);
|
||||
void setTempo(int newTempo);
|
||||
void setTimeSignature(int num, int denom);
|
||||
void startCycle(int startTick, int endTick);
|
||||
void stopCycle();
|
||||
void setPlaybackJumped(bool jumped);
|
||||
void update();
|
||||
|
||||
const std::string& sharedMemoryKey() const noexcept { return m_syncData.key(); }
|
||||
|
||||
private slots:
|
||||
void updateSampleRate();
|
||||
|
||||
|
||||
private:
|
||||
VstSyncData* m_syncData;
|
||||
SharedMemory<VstSyncData> m_shm;
|
||||
SharedMemory<VstSyncData> m_syncData;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -46,7 +46,6 @@ struct VstSyncData
|
||||
int timeSigDenom;
|
||||
bool isPlaying;
|
||||
bool isCycle;
|
||||
bool hasSHM;
|
||||
float cycleStart;
|
||||
float cycleEnd;
|
||||
bool m_playbackJumped;
|
||||
|
||||
Reference in New Issue
Block a user