Browse Source

Initial code for juce-less VST3 native hosting

Signed-off-by: falkTX <falktx@falktx.com>
tags/v2.5.0
falkTX 2 years ago
parent
commit
6e96ae86cb
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
3 changed files with 2033 additions and 83 deletions
  1. +23
    -23
      source/backend/plugin/CarlaPluginVST2.cpp
  2. +2007
    -57
      source/backend/plugin/CarlaPluginVST3.cpp
  3. +3
    -3
      source/discovery/carla-discovery.cpp

+ 23
- 23
source/backend/plugin/CarlaPluginVST2.cpp View File

@@ -1,6 +1,6 @@
/* /*
* Carla VST Plugin * Carla VST Plugin
* Copyright (C) 2011-2021 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2011-2022 Filipe Coelho <falktx@falktx.com>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
@@ -158,18 +158,18 @@ public:
clearBuffers(); clearBuffers();


#ifdef CARLA_OS_MAC #ifdef CARLA_OS_MAC
if (fMacBundleRef != nullptr)
{
CFBundleCloseBundleResourceMap(fMacBundleRef, fMacBundleRefNum);
if (fMacBundleRef != nullptr)
{
CFBundleCloseBundleResourceMap(fMacBundleRef, fMacBundleRefNum);


if (CFGetRetainCount(fMacBundleRef) == 1)
CFBundleUnloadExecutable(fMacBundleRef);
if (CFGetRetainCount(fMacBundleRef) == 1)
CFBundleUnloadExecutable(fMacBundleRef);


if (CFGetRetainCount(fMacBundleRef) > 0)
CFRelease(fMacBundleRef);
if (CFGetRetainCount(fMacBundleRef) > 0)
CFRelease(fMacBundleRef);


fMacBundleRef = nullptr;
}
fMacBundleRef = nullptr;
}
#endif #endif
} }


@@ -1172,11 +1172,11 @@ public:


try { try {
dispatcher(effMainsChanged, 0, 1); dispatcher(effMainsChanged, 0, 1);
} catch(...) {}
} CARLA_SAFE_EXCEPTION("effMainsChanged on");


try { try {
dispatcher(effStartProcess, 0, 0); dispatcher(effStartProcess, 0, 0);
} catch(...) {}
} CARLA_SAFE_EXCEPTION("effStartProcess on");


fFirstActive = true; fFirstActive = true;
} }
@@ -1187,11 +1187,11 @@ public:


try { try {
dispatcher(effStopProcess); dispatcher(effStopProcess);
} catch(...) {}
} CARLA_SAFE_EXCEPTION("effStartProcess off");


try { try {
dispatcher(effMainsChanged); dispatcher(effMainsChanged);
} catch(...) {}
} CARLA_SAFE_EXCEPTION("effMainsChanged off");
} }


void process(const float* const* const audioIn, void process(const float* const* const audioIn,
@@ -1261,7 +1261,7 @@ public:


fTimeInfo.flags = 0; fTimeInfo.flags = 0;


if (fFirstActive || ! fLastTimeInfo.compareIgnoringRollingFrames(timeInfo, fBufferSize))
if (fFirstActive || ! fLastTimeInfo.compareIgnoringRollingFrames(timeInfo, frames))
{ {
fTimeInfo.flags |= kVstTransportChanged; fTimeInfo.flags |= kVstTransportChanged;
fLastTimeInfo = timeInfo; fLastTimeInfo = timeInfo;
@@ -1289,7 +1289,7 @@ public:
// const double ppqTick = timeInfo.bbt.tick / timeInfo.bbt.ticksPerBeat; // const double ppqTick = timeInfo.bbt.tick / timeInfo.bbt.ticksPerBeat;


// PPQ Pos // PPQ Pos
fTimeInfo.ppqPos = fTimeInfo.samplePos / (fTimeInfo.sampleRate * 60 / fTimeInfo.tempo);
fTimeInfo.ppqPos = fTimeInfo.samplePos / (fTimeInfo.sampleRate * 60 / timeInfo.bbt.beatsPerMinute);
// fTimeInfo.ppqPos = ppqBar + ppqBeat + ppqTick; // fTimeInfo.ppqPos = ppqBar + ppqBeat + ppqTick;
fTimeInfo.flags |= kVstPpqPosValid; fTimeInfo.flags |= kVstPpqPosValid;


@@ -1302,8 +1302,8 @@ public:
fTimeInfo.flags |= kVstBarsValid; fTimeInfo.flags |= kVstBarsValid;


// Time Signature // Time Signature
fTimeInfo.timeSigNumerator = static_cast<int32_t>(timeInfo.bbt.beatsPerBar);
fTimeInfo.timeSigDenominator = static_cast<int32_t>(timeInfo.bbt.beatType);
fTimeInfo.timeSigNumerator = static_cast<int32_t>(timeInfo.bbt.beatsPerBar + 0.5f);
fTimeInfo.timeSigDenominator = static_cast<int32_t>(timeInfo.bbt.beatType + 0.5f);
fTimeInfo.flags |= kVstTimeSigValid; fTimeInfo.flags |= kVstTimeSigValid;
} }
else else
@@ -1313,7 +1313,7 @@ public:
fTimeInfo.flags |= kVstTempoValid; fTimeInfo.flags |= kVstTempoValid;


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


@@ -2500,7 +2500,7 @@ public:
{ {
CFRelease(fMacBundleRef); CFRelease(fMacBundleRef);
fMacBundleRef = nullptr; fMacBundleRef = nullptr;
pData->engine->setLastError("Failed to load VST bundle executable");
pData->engine->setLastError("Failed to load VST2 bundle executable");
return false; return false;
} }


@@ -2514,7 +2514,7 @@ public:
CFBundleUnloadExecutable(fMacBundleRef); CFBundleUnloadExecutable(fMacBundleRef);
CFRelease(fMacBundleRef); CFRelease(fMacBundleRef);
fMacBundleRef = nullptr; fMacBundleRef = nullptr;
pData->engine->setLastError("Not a VST plugin");
pData->engine->setLastError("Not a VST2 plugin");
return false; return false;
} }


@@ -2543,7 +2543,7 @@ public:


if (vstFn == nullptr) if (vstFn == nullptr)
{ {
pData->engine->setLastError("Could not find the VST main entry in the plugin library");
pData->engine->setLastError("Could not find the VST2 main entry in the plugin library");
return false; return false;
} }
} }
@@ -2695,7 +2695,7 @@ public:


pData->options = 0x0; pData->options = 0x0;


if (pData->latency.frames != 0 || hasMidiOutput() || isPluginOptionEnabled(options, PLUGIN_OPTION_FIXED_BUFFERS))
if (fEffect->initialDelay > 0 || hasMidiOutput() || isPluginOptionEnabled(options, PLUGIN_OPTION_FIXED_BUFFERS))
pData->options |= PLUGIN_OPTION_FIXED_BUFFERS; pData->options |= PLUGIN_OPTION_FIXED_BUFFERS;


if (fEffect->flags & effFlagsProgramChunks) if (fEffect->flags & effFlagsProgramChunks)


+ 2007
- 57
source/backend/plugin/CarlaPluginVST3.cpp
File diff suppressed because it is too large
View File


+ 3
- 3
source/discovery/carla-discovery.cpp View File

@@ -1477,14 +1477,14 @@ static void do_vst3_check(lib_t& libHandle, const char* const filename, const bo
binaryfilename += CARLA_OS_SEP_STR; binaryfilename += CARLA_OS_SEP_STR;


binaryfilename += "Contents" CARLA_OS_SEP_STR V3_CONTENT_DIR CARLA_OS_SEP_STR; binaryfilename += "Contents" CARLA_OS_SEP_STR V3_CONTENT_DIR CARLA_OS_SEP_STR;
binaryfilename += File(filename).getFileNameWithoutExtension();
binaryfilename += water::File(filename).getFileNameWithoutExtension();
# ifdef CARLA_OS_WIN # ifdef CARLA_OS_WIN
binaryfilename += ".vst3"; binaryfilename += ".vst3";
# else # else
binaryfilename += ".so"; binaryfilename += ".so";
# endif # endif


if (! File(binaryfilename).existsAsFile())
if (! water::File(binaryfilename).existsAsFile())
{ {
DISCOVERY_OUT("error", "Failed to find a suitable VST3 bundle binary"); DISCOVERY_OUT("error", "Failed to find a suitable VST3 bundle binary");
return; return;
@@ -1501,12 +1501,12 @@ static void do_vst3_check(lib_t& libHandle, const char* const filename, const bo
} }


#ifndef CARLA_OS_MAC #ifndef CARLA_OS_MAC
// ensure entry and exist points are available
v3_entry = lib_symbol<V3_ENTRYFN>(libHandle, V3_ENTRYFNNAME); v3_entry = lib_symbol<V3_ENTRYFN>(libHandle, V3_ENTRYFNNAME);
v3_exit = lib_symbol<V3_EXITFN>(libHandle, V3_EXITFNNAME); v3_exit = lib_symbol<V3_EXITFN>(libHandle, V3_EXITFNNAME);
v3_get = lib_symbol<V3_GETFN>(libHandle, V3_GETFNNAME); v3_get = lib_symbol<V3_GETFN>(libHandle, V3_GETFNNAME);
#endif #endif


// ensure entry and exit points are available
if (v3_entry == nullptr || v3_exit == nullptr || v3_get == nullptr) if (v3_entry == nullptr || v3_exit == nullptr || v3_get == nullptr)
{ {
DISCOVERY_OUT("error", "Not a VST3 plugin"); DISCOVERY_OUT("error", "Not a VST3 plugin");


Loading…
Cancel
Save