Browse Source

VST: Get timeInfo from host; misc changes

tags/1.9.4
falkTX 11 years ago
parent
commit
6f9ea7a67b
2 changed files with 80 additions and 19 deletions
  1. +2
    -1
      source/backend/engine/CarlaEngineJack.cpp
  2. +78
    -18
      source/backend/plugin/VstPlugin.cpp

+ 2
- 1
source/backend/engine/CarlaEngineJack.cpp View File

@@ -506,7 +506,8 @@ public:
carla_debug("CarlaEngineJack::CarlaEngineJack()"); carla_debug("CarlaEngineJack::CarlaEngineJack()");


#ifdef BUILD_BRIDGE #ifdef BUILD_BRIDGE
fOptions.processMode = PROCESS_MODE_MULTIPLE_CLIENTS;
fOptions.processMode = PROCESS_MODE_MULTIPLE_CLIENTS;
fOptions.transportMode = TRANSPORT_MODE_JACK;
#endif #endif


carla_zeroStruct<jack_position_t>(fTransportPos); carla_zeroStruct<jack_position_t>(fTransportPos);


+ 78
- 18
source/backend/plugin/VstPlugin.cpp View File

@@ -972,6 +972,61 @@ public:
kData->needsReset = false; kData->needsReset = false;
} }


// --------------------------------------------------------------------------------------------------------
// Set TimeInfo

const EngineTimeInfo& timeInfo = kData->engine->getTimeInfo();

fTimeInfo.flags = kVstTransportChanged;

if (timeInfo.playing)
fTimeInfo.flags |= kVstTransportPlaying;

fTimeInfo.samplePos = timeInfo.frame;
fTimeInfo.sampleRate = kData->engine->getSampleRate();

fTimeInfo.nanoSeconds = timeInfo.time;
fTimeInfo.flags |= kVstNanosValid;

if (timeInfo.valid & EngineTimeInfo::ValidBBT)
{
double ppqBar = double(timeInfo.bbt.bar - 1) * timeInfo.bbt.beatsPerBar;
double ppqBeat = double(timeInfo.bbt.beat - 1);
double ppqTick = double(timeInfo.bbt.tick) / timeInfo.bbt.ticksPerBeat;

// PPQ Pos
fTimeInfo.ppqPos = ppqBar + ppqBeat + ppqTick;
fTimeInfo.flags |= kVstPpqPosValid;

// Tempo
fTimeInfo.tempo = timeInfo.bbt.beatsPerMinute;
fTimeInfo.flags |= kVstTempoValid;

// Bars
fTimeInfo.barStartPos = ppqBar;
fTimeInfo.flags |= kVstBarsValid;

// Time Signature
fTimeInfo.timeSigNumerator = timeInfo.bbt.beatsPerBar;
fTimeInfo.timeSigDenominator = timeInfo.bbt.beatType;
fTimeInfo.flags |= kVstTimeSigValid;
}
else
{
// Tempo
fTimeInfo.tempo = 120.0;
fTimeInfo.flags |= kVstTempoValid;

// Time Signature
fTimeInfo.timeSigNumerator = 4;
fTimeInfo.timeSigDenominator = 4;
fTimeInfo.flags |= kVstTimeSigValid;

// Missing info
fTimeInfo.ppqPos = 0.0;
fTimeInfo.barStartPos = 0.0;
}

// -------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------
// Event Input and Processing // Event Input and Processing


@@ -1626,36 +1681,35 @@ protected:
switch (opcode) switch (opcode)
{ {
case audioMasterAutomate: case audioMasterAutomate:
if (! fEnabled)
break;

// plugins should never do this: // plugins should never do this:
CARLA_SAFE_ASSERT(fEnabled);
CARLA_SAFE_ASSERT_INT(index < static_cast<int32_t>(kData->param.count), index); CARLA_SAFE_ASSERT_INT(index < static_cast<int32_t>(kData->param.count), index);


if (index < 0 || index >= static_cast<int32_t>(kData->param.count) || ! fEnabled)
if (index < 0 || index >= static_cast<int32_t>(kData->param.count))
break; break;


if (fIsProcessing)
if (fGui.isVisible && ! fIsProcessing)
{
// Called from GUI
setParameterValue(index, opt, false, true, true);
}
else if (fIsProcessing)
{ {
// Called from engine // Called from engine
const float fixedValue = kData->param.fixValue(index, opt);

if (kData->engine->isOffline()) if (kData->engine->isOffline())
{ {
setParameterValue(index, opt, true, true, true);
CarlaPlugin::setParameterValue(index, fixedValue, true, true, true);
} }
else else
{ {
setParameterValue(index, opt, false, false, false);
postponeRtEvent(kPluginPostRtEventParameterChange, index, 0, opt);
CarlaPlugin::setParameterValue(index, fixedValue, false, false, false);
postponeRtEvent(kPluginPostRtEventParameterChange, index, 0, fixedValue);
} }
} }
else if (! kData->active)
{
// On init?
setParameterValue(index, opt, false, false, false);
}
else if (fGui.isVisible)
{
// Called from GUI
setParameterValue(index, opt, false, true, true);
}
else else
{ {
carla_stdout("audioMasterAutomate called from unknown source"); carla_stdout("audioMasterAutomate called from unknown source");
@@ -2007,12 +2061,18 @@ public:
fEffect = vstFn(carla_vst_audioMasterCallback); fEffect = vstFn(carla_vst_audioMasterCallback);
sLastVstPlugin = nullptr; sLastVstPlugin = nullptr;


if (fEffect == nullptr || fEffect->magic != kEffectMagic)
if (fEffect == nullptr)
{ {
kData->engine->setLastError("Plugin failed to initialize"); kData->engine->setLastError("Plugin failed to initialize");
return false; return false;
} }


if (fEffect->magic != kEffectMagic)
{
kData->engine->setLastError("Plugin is not valid (wrong vst effect magic code)");
return false;
}

#ifdef VESTIGE_HEADER #ifdef VESTIGE_HEADER
fEffect->ptr1 = this; fEffect->ptr1 = this;
#else #else
@@ -2178,7 +2238,7 @@ private:


static intptr_t VSTCALLBACK carla_vst_audioMasterCallback(AEffect* effect, int32_t opcode, int32_t index, intptr_t value, void* ptr, float opt) static intptr_t VSTCALLBACK carla_vst_audioMasterCallback(AEffect* effect, int32_t opcode, int32_t index, intptr_t value, void* ptr, float opt)
{ {
#ifdef DEBUG
#if defined(DEBUG) && ! defined(CARLA_OS_WIN)
if (opcode != audioMasterGetTime && opcode != audioMasterProcessEvents && opcode != audioMasterGetCurrentProcessLevel && opcode != audioMasterGetOutputLatency) if (opcode != audioMasterGetTime && opcode != audioMasterProcessEvents && opcode != audioMasterGetCurrentProcessLevel && opcode != audioMasterGetOutputLatency)
carla_debug("carla_vst_audioMasterCallback(%p, %02i:%s, %i, " P_INTPTR ", %p, %f)", effect, opcode, vstMasterOpcode2str(opcode), index, value, ptr, opt); carla_debug("carla_vst_audioMasterCallback(%p, %02i:%s, %i, " P_INTPTR ", %p, %f)", effect, opcode, vstMasterOpcode2str(opcode), index, value, ptr, opt);
#endif #endif


Loading…
Cancel
Save