Browse Source

carla-plugin: send transport info

tags/1.9.5
falkTX 10 years ago
parent
commit
a72caa5323
4 changed files with 52 additions and 18 deletions
  1. +31
    -8
      source/backend/engine/CarlaEngineNative.cpp
  2. +10
    -0
      source/carla_backend.py
  3. +5
    -10
      source/carla_panels.py
  4. +6
    -0
      source/modules/native-plugins/resources/carla-plugin

+ 31
- 8
source/backend/engine/CarlaEngineNative.cpp View File

@@ -1002,7 +1002,7 @@ protected:
CARLA_SAFE_ASSERT_RETURN(fIsRunning,);
CARLA_SAFE_ASSERT_RETURN(fUiServer.isOk(),);

const EngineOptions& options(getOptions());
const EngineOptions& options(pData->options);
const CarlaMutexLocker cml(fUiServer.getWriteLock());

std::sprintf(fTmpBuf, "ENGINE_OPTION_%i\n", ENGINE_OPTION_PROCESS_MODE);
@@ -1270,13 +1270,6 @@ protected:
{
const PendingRtEventsRunner prt(this);

if (pData->curPluginCount == 0 && ! kIsPatchbay)
{
FloatVectorOperations::copy(outBuffer[0], inBuffer[0], static_cast<int>(frames));
FloatVectorOperations::copy(outBuffer[1], inBuffer[1], static_cast<int>(frames));
return;
}

// ---------------------------------------------------------------
// Time Info

@@ -1303,6 +1296,16 @@ protected:
pData->timeInfo.bbt.beatsPerMinute = timeInfo->bbt.beatsPerMinute;
}

// ---------------------------------------------------------------
// Do nothing if no plugins and rack mode

if (pData->curPluginCount == 0 && ! kIsPatchbay)
{
FloatVectorOperations::copy(outBuffer[0], inBuffer[0], static_cast<int>(frames));
FloatVectorOperations::copy(outBuffer[1], inBuffer[1], static_cast<int>(frames));
return;
}

// ---------------------------------------------------------------
// initialize events

@@ -1451,9 +1454,29 @@ protected:
return;

{
const EngineTimeInfo& timeInfo(pData->timeInfo);
const CarlaMutexLocker cml(fUiServer.getWriteLock());
const ScopedLocale csl;

// send transport
fUiServer.writeAndFixMsg("transport");
fUiServer.writeAndFixMsg(bool2str(timeInfo.playing));

if (timeInfo.valid & EngineTimeInfo::kValidBBT)
{
std::sprintf(fTmpBuf, P_UINT64 ":%i:%i:%i\n", timeInfo.frame, timeInfo.bbt.bar, timeInfo.bbt.beat, timeInfo.bbt.tick);
fUiServer.writeMsg(fTmpBuf);
std::sprintf(fTmpBuf, "%f\n", timeInfo.bbt.beatsPerMinute);
fUiServer.writeMsg(fTmpBuf);
}
else
{
std::sprintf(fTmpBuf, P_UINT64 ":0:0:0\n", timeInfo.frame);
fUiServer.writeMsg(fTmpBuf);
fUiServer.writeMsg("0.0\n");
}

// send peaks and param outputs for all plugins
for (uint i=0; i < pData->curPluginCount; ++i)
{
const EnginePluginData& plugData(pData->plugins[i]);


+ 10
- 0
source/carla_backend.py View File

@@ -3204,6 +3204,16 @@ class CarlaHostPlugin(CarlaHostMeta):
self.fSupportedFileExts = fileexts
self.fMaxPluginNumber = maxnum

def _set_transport(self, playing, frame, bar, beat, tick, bpm):
self.fTransportInfo = {
"playing": playing,
"frame": frame,
"bar": bar,
"beat": beat,
"tick": tick,
"bpm": bpm
}

def _add(self, pluginId):
if len(self.fPluginsInfo) != pluginId:
return


+ 5
- 10
source/carla_panels.py View File

@@ -58,7 +58,7 @@ class CarlaPanelTime(QDialog):

self.fLastTransportFrame = 0
self.fLastTransportState = False
self.fSampleRate = host.get_sample_rate() if host.is_engine_running() else 0.0
self.fSampleRate = 0.0

#if view == TRANSPORT_VIEW_HMS:
#self.fCurTransportView = TRANSPORT_VIEW_HMS
@@ -90,17 +90,12 @@ class CarlaPanelTime(QDialog):
host.EngineStartedCallback.connect(self.slot_handleEngineStartedCallback)
host.SampleRateChangedCallback.connect(self.slot_handleSampleRateChangedCallback)

# ----------------------------------------------------------------------------------------------------
# Final setup

self.refreshTransport(True)

# --------------------------------------------------------------------------------------------------------
# Button actions

@pyqtSlot(bool)
def slot_transportPlayPause(self, toggled):
if not self.host.is_engine_running():
if self.host.isPlugin or not self.host.is_engine_running():
return

if toggled:
@@ -112,7 +107,7 @@ class CarlaPanelTime(QDialog):

@pyqtSlot()
def slot_transportStop(self):
if not self.host.is_engine_running():
if self.host.isPlugin or not self.host.is_engine_running():
return

self.host.transport_pause()
@@ -122,7 +117,7 @@ class CarlaPanelTime(QDialog):

@pyqtSlot()
def slot_transportBackwards(self):
if not self.host.is_engine_running():
if self.host.isPlugin or not self.host.is_engine_running():
return

newFrame = self.host.get_current_transport_frame() - 100000
@@ -134,7 +129,7 @@ class CarlaPanelTime(QDialog):

@pyqtSlot()
def slot_transportForwards(self):
if self.fSampleRate == 0.0 or not self.host.is_engine_running():
if self.fSampleRate == 0.0 or self.host.isPlugin or not self.host.is_engine_running():
return

newFrame = self.host.get_current_transport_frame() + int(self.fSampleRate*2.5)


+ 6
- 0
source/modules/native-plugins/resources/carla-plugin View File

@@ -331,6 +331,12 @@ class CarlaMiniW(ExternalUI, HostWindow):
srate = float(self.readlineblock())
self.host.fSampleRate = srate

elif msg == "transport":
playing = bool(self.readlineblock() == "true")
frame, bar, beat, tick = [int(i) for i in self.readlineblock().split(":")]
bpm = float(self.readlineblock())
self.host._set_transport(playing, frame, bar, beat, tick, bpm)

elif msg == "error":
error = self.readlineblock().replace("\r", "\n")
engineCallback(self.host, ENGINE_CALLBACK_ERROR, 0, 0, 0, 0.0, error)


Loading…
Cancel
Save