|
@@ -32,8 +32,9 @@ |
|
|
# include "ImGuiWidget.hpp" |
|
|
# include "ImGuiWidget.hpp" |
|
|
# include "ModuleWidgets.hpp" |
|
|
# include "ModuleWidgets.hpp" |
|
|
# include "extra/FileBrowserDialog.hpp" |
|
|
# include "extra/FileBrowserDialog.hpp" |
|
|
|
|
|
# include "extra/Mutex.hpp" |
|
|
|
|
|
# include "extra/Runner.hpp" |
|
|
# include "extra/ScopedPointer.hpp" |
|
|
# include "extra/ScopedPointer.hpp" |
|
|
# include "extra/Thread.hpp" |
|
|
|
|
|
# include "../../src/extra/SharedResourcePointer.hpp" |
|
|
# include "../../src/extra/SharedResourcePointer.hpp" |
|
|
#else |
|
|
#else |
|
|
# include "extra/Mutex.hpp" |
|
|
# include "extra/Mutex.hpp" |
|
@@ -589,7 +590,7 @@ static intptr_t host_dispatcher(const NativeHostHandle handle, const NativeHostD |
|
|
// -------------------------------------------------------------------------------------------------------------------- |
|
|
// -------------------------------------------------------------------------------------------------------------------- |
|
|
|
|
|
|
|
|
#ifndef HEADLESS |
|
|
#ifndef HEADLESS |
|
|
struct IldaeilWidget : ImGuiWidget, IdleCallback, Thread { |
|
|
|
|
|
|
|
|
struct IldaeilWidget : ImGuiWidget, IdleCallback, Runner { |
|
|
static constexpr const uint kButtonHeight = 20; |
|
|
static constexpr const uint kButtonHeight = 20; |
|
|
|
|
|
|
|
|
struct PluginInfoCache { |
|
|
struct PluginInfoCache { |
|
@@ -670,6 +671,19 @@ struct IldaeilWidget : ImGuiWidget, IdleCallback, Thread { |
|
|
kIdleNothing |
|
|
kIdleNothing |
|
|
} fIdleState = kIdleInit; |
|
|
} fIdleState = kIdleInit; |
|
|
|
|
|
|
|
|
|
|
|
struct RunnerData { |
|
|
|
|
|
bool needsReinit = true; |
|
|
|
|
|
uint pluginCount = 0; |
|
|
|
|
|
uint pluginIndex = 0; |
|
|
|
|
|
|
|
|
|
|
|
void init() |
|
|
|
|
|
{ |
|
|
|
|
|
needsReinit = true; |
|
|
|
|
|
pluginCount = 0; |
|
|
|
|
|
pluginIndex = 0; |
|
|
|
|
|
} |
|
|
|
|
|
} fRunnerData; |
|
|
|
|
|
|
|
|
PluginType fPluginType = PLUGIN_LV2; |
|
|
PluginType fPluginType = PLUGIN_LV2; |
|
|
PluginType fNextPluginType = fPluginType; |
|
|
PluginType fNextPluginType = fPluginType; |
|
|
uint fPluginCount = 0; |
|
|
uint fPluginCount = 0; |
|
@@ -741,8 +755,7 @@ struct IldaeilWidget : ImGuiWidget, IdleCallback, Thread { |
|
|
module->fUI = nullptr; |
|
|
module->fUI = nullptr; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (isThreadRunning()) |
|
|
|
|
|
stopThread(-1); |
|
|
|
|
|
|
|
|
stopRunner(); |
|
|
|
|
|
|
|
|
fPluginGenericUI = nullptr; |
|
|
fPluginGenericUI = nullptr; |
|
|
|
|
|
|
|
@@ -1046,13 +1059,13 @@ struct IldaeilWidget : ImGuiWidget, IdleCallback, Thread { |
|
|
{ |
|
|
{ |
|
|
case kIdleInit: |
|
|
case kIdleInit: |
|
|
fIdleState = kIdleNothing; |
|
|
fIdleState = kIdleNothing; |
|
|
startThread(); |
|
|
|
|
|
|
|
|
initAndStartRunner(); |
|
|
break; |
|
|
break; |
|
|
|
|
|
|
|
|
case kIdleInitPluginAlreadyLoaded: |
|
|
case kIdleInitPluginAlreadyLoaded: |
|
|
fIdleState = kIdleNothing; |
|
|
fIdleState = kIdleNothing; |
|
|
createOrUpdatePluginGenericUI(handle); |
|
|
createOrUpdatePluginGenericUI(handle); |
|
|
startThread(); |
|
|
|
|
|
|
|
|
initAndStartRunner(); |
|
|
break; |
|
|
break; |
|
|
|
|
|
|
|
|
case kIdlePluginLoadedFromDSP: |
|
|
case kIdlePluginLoadedFromDSP: |
|
@@ -1087,10 +1100,9 @@ struct IldaeilWidget : ImGuiWidget, IdleCallback, Thread { |
|
|
case kIdleChangePluginType: |
|
|
case kIdleChangePluginType: |
|
|
fIdleState = kIdleNothing; |
|
|
fIdleState = kIdleNothing; |
|
|
fPluginSelected = -1; |
|
|
fPluginSelected = -1; |
|
|
if (isThreadRunning()) |
|
|
|
|
|
stopThread(-1); |
|
|
|
|
|
|
|
|
stopRunner(); |
|
|
fPluginType = fNextPluginType; |
|
|
fPluginType = fNextPluginType; |
|
|
startThread(); |
|
|
|
|
|
|
|
|
initAndStartRunner(); |
|
|
break; |
|
|
break; |
|
|
|
|
|
|
|
|
case kIdleNothing: |
|
|
case kIdleNothing: |
|
@@ -1130,93 +1142,117 @@ struct IldaeilWidget : ImGuiWidget, IdleCallback, Thread { |
|
|
loadPlugin(handle, label); |
|
|
loadPlugin(handle, label); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void run() override |
|
|
|
|
|
|
|
|
bool initAndStartRunner() |
|
|
{ |
|
|
{ |
|
|
const char* path; |
|
|
|
|
|
switch (fPluginType) |
|
|
|
|
|
{ |
|
|
|
|
|
case PLUGIN_LV2: |
|
|
|
|
|
path = std::getenv("LV2_PATH"); |
|
|
|
|
|
break; |
|
|
|
|
|
case PLUGIN_JSFX: |
|
|
|
|
|
path = getPathForJSFX(); |
|
|
|
|
|
break; |
|
|
|
|
|
default: |
|
|
|
|
|
path = nullptr; |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (isRunnerActive()) |
|
|
|
|
|
stopRunner(); |
|
|
|
|
|
|
|
|
if (path != nullptr) |
|
|
|
|
|
carla_set_engine_option(module->fCarlaHostHandle, ENGINE_OPTION_PLUGIN_PATH, fPluginType, path); |
|
|
|
|
|
|
|
|
|
|
|
fPluginCount = 0; |
|
|
|
|
|
delete[] fPlugins; |
|
|
|
|
|
|
|
|
|
|
|
uint count; |
|
|
|
|
|
|
|
|
fRunnerData.needsReinit = true; |
|
|
|
|
|
return startRunner(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool run() override |
|
|
|
|
|
{ |
|
|
|
|
|
if (fRunnerData.needsReinit) |
|
|
{ |
|
|
{ |
|
|
const MutexLocker cml(sPluginInfoLoadMutex); |
|
|
|
|
|
|
|
|
fRunnerData.needsReinit = false; |
|
|
|
|
|
|
|
|
d_stdout("Will scan plugins now..."); |
|
|
|
|
|
count = carla_get_cached_plugin_count(fPluginType, path); |
|
|
|
|
|
d_stdout("Scanning found %u plugins", count); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
const char* path; |
|
|
|
|
|
switch (fPluginType) |
|
|
|
|
|
{ |
|
|
|
|
|
case PLUGIN_LV2: |
|
|
|
|
|
path = std::getenv("LV2_PATH"); |
|
|
|
|
|
break; |
|
|
|
|
|
case PLUGIN_JSFX: |
|
|
|
|
|
path = getPathForJSFX(); |
|
|
|
|
|
break; |
|
|
|
|
|
default: |
|
|
|
|
|
path = nullptr; |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (fDrawingState == kDrawingLoading) |
|
|
|
|
|
{ |
|
|
|
|
|
fDrawingState = kDrawingPluginList; |
|
|
|
|
|
fPluginSearchFirstShow = true; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (path != nullptr) |
|
|
|
|
|
carla_set_engine_option(module->fCarlaHostHandle, ENGINE_OPTION_PLUGIN_PATH, fPluginType, path); |
|
|
|
|
|
|
|
|
if (count != 0) |
|
|
|
|
|
{ |
|
|
|
|
|
fPlugins = new PluginInfoCache[count]; |
|
|
|
|
|
|
|
|
fPluginCount = 0; |
|
|
|
|
|
delete[] fPlugins; |
|
|
|
|
|
|
|
|
for (uint i=0, j; i < count && ! shouldThreadExit(); ++i) |
|
|
|
|
|
{ |
|
|
{ |
|
|
const MutexLocker cml(sPluginInfoLoadMutex); |
|
|
const MutexLocker cml(sPluginInfoLoadMutex); |
|
|
|
|
|
|
|
|
const CarlaCachedPluginInfo* const info = carla_get_cached_plugin_info(fPluginType, i); |
|
|
|
|
|
DISTRHO_SAFE_ASSERT_CONTINUE(info != nullptr); |
|
|
|
|
|
|
|
|
|
|
|
if (! info->valid) |
|
|
|
|
|
continue; |
|
|
|
|
|
if (info->audioIns != 0 && info->audioIns != 2) |
|
|
|
|
|
continue; |
|
|
|
|
|
if (info->midiIns != 0 && info->midiIns != 1) |
|
|
|
|
|
continue; |
|
|
|
|
|
if (info->midiOuts != 0 && info->midiOuts != 1) |
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
d_stdout("Will scan plugins now..."); |
|
|
|
|
|
fRunnerData.pluginCount = carla_get_cached_plugin_count(fPluginType, path); |
|
|
|
|
|
d_stdout("Scanning found %u plugins", fRunnerData.pluginCount); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (fPluginType == PLUGIN_INTERNAL) |
|
|
|
|
|
{ |
|
|
|
|
|
if (std::strcmp(info->label, "audiogain_s") == 0) |
|
|
|
|
|
continue; |
|
|
|
|
|
if (std::strcmp(info->label, "cv2audio") == 0) |
|
|
|
|
|
continue; |
|
|
|
|
|
if (std::strcmp(info->label, "lfo") == 0) |
|
|
|
|
|
continue; |
|
|
|
|
|
if (std::strcmp(info->label, "midi2cv") == 0) |
|
|
|
|
|
continue; |
|
|
|
|
|
if (std::strcmp(info->label, "midithrough") == 0) |
|
|
|
|
|
continue; |
|
|
|
|
|
if (std::strcmp(info->label, "3bandsplitter") == 0) |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (fDrawingState == kDrawingLoading) |
|
|
|
|
|
{ |
|
|
|
|
|
fDrawingState = kDrawingPluginList; |
|
|
|
|
|
fPluginSearchFirstShow = true; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
j = fPluginCount; |
|
|
|
|
|
fPlugins[j].name = strdup(info->name); |
|
|
|
|
|
fPlugins[j].label = strdup(info->label); |
|
|
|
|
|
++fPluginCount; |
|
|
|
|
|
|
|
|
if (fRunnerData.pluginCount != 0) |
|
|
|
|
|
{ |
|
|
|
|
|
fPlugins = new PluginInfoCache[fRunnerData.pluginCount]; |
|
|
|
|
|
fPluginScanningFinished = false; |
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
fPlugins = nullptr; |
|
|
|
|
|
fPluginScanningFinished = true; |
|
|
|
|
|
return false; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
fPlugins = nullptr; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (! shouldThreadExit()) |
|
|
|
|
|
fPluginScanningFinished = true; |
|
|
|
|
|
|
|
|
const uint index = fRunnerData.pluginIndex++; |
|
|
|
|
|
DISTRHO_SAFE_ASSERT_UINT2_RETURN(index < fRunnerData.pluginCount, |
|
|
|
|
|
index, fRunnerData.pluginCount, false); |
|
|
|
|
|
|
|
|
|
|
|
do { |
|
|
|
|
|
const MutexLocker cml(sPluginInfoLoadMutex); |
|
|
|
|
|
|
|
|
|
|
|
const CarlaCachedPluginInfo* const info = carla_get_cached_plugin_info(fPluginType, index); |
|
|
|
|
|
DISTRHO_SAFE_ASSERT_CONTINUE(info != nullptr); |
|
|
|
|
|
|
|
|
|
|
|
if (! info->valid) |
|
|
|
|
|
break; |
|
|
|
|
|
if (info->audioIns != 0 && info->audioIns != 2) |
|
|
|
|
|
break; |
|
|
|
|
|
if (info->midiIns != 0 && info->midiIns != 1) |
|
|
|
|
|
break; |
|
|
|
|
|
if (info->midiOuts != 0 && info->midiOuts != 1) |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
if (fPluginType == PLUGIN_INTERNAL) |
|
|
|
|
|
{ |
|
|
|
|
|
if (std::strcmp(info->label, "audiogain_s") == 0) |
|
|
|
|
|
break; |
|
|
|
|
|
if (std::strcmp(info->label, "cv2audio") == 0) |
|
|
|
|
|
break; |
|
|
|
|
|
if (std::strcmp(info->label, "lfo") == 0) |
|
|
|
|
|
break; |
|
|
|
|
|
if (std::strcmp(info->label, "midi2cv") == 0) |
|
|
|
|
|
break; |
|
|
|
|
|
if (std::strcmp(info->label, "midithrough") == 0) |
|
|
|
|
|
break; |
|
|
|
|
|
if (std::strcmp(info->label, "3bandsplitter") == 0) |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const uint pindex = fPluginCount; |
|
|
|
|
|
fPlugins[pindex].name = strdup(info->name); |
|
|
|
|
|
fPlugins[pindex].label = strdup(info->label); |
|
|
|
|
|
++fPluginCount; |
|
|
|
|
|
} while (false); |
|
|
|
|
|
|
|
|
|
|
|
// run again |
|
|
|
|
|
if (fRunnerData.pluginIndex != fRunnerData.pluginCount) |
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
|
|
// stop here |
|
|
|
|
|
fPluginScanningFinished = true; |
|
|
|
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void drawImGui() override |
|
|
void drawImGui() override |
|
|