Do plugin init/destroy ourselves, clean whitespace

Signed-off-by: falkTX <falktx@falktx.com>
This commit is contained in:
falkTX 2021-10-17 22:56:50 +01:00
parent 9ce1e18c1f
commit e56bbe28a4
No known key found for this signature in database
GPG key ID: CDBAA37ABC74FBA0
3 changed files with 473 additions and 280 deletions

117
plugins/Core.json Normal file
View file

@ -0,0 +1,117 @@
{
"slug": "Core",
"name": "Core",
"version": "2.0.0",
"license": "GPL-3.0-or-later",
"author": "VCV",
"brand": "VCV",
"authorEmail": "support@vcvrack.com",
"authorUrl": "https://vcvrack.com/",
"pluginUrl": "",
"manualUrl": "https://vcvrack.com/manual/Core",
"sourceUrl": "https://github.com/VCVRack/Rack",
"donateUrl": "",
"changelogUrl": "https://github.com/VCVRack/Rack/blob/v2/CHANGELOG.md",
"description": "Necessary modules built into VCV Rack",
"modules": [
{
"slug": "AudioInterface2",
"name": "Audio-2",
"description": "Sends audio and CV to/from an audio device",
"manualUrl": "https://vcvrack.com/manual/Core#Audio",
"tags": [
"External"
]
},
{
"slug": "MIDIToCVInterface",
"name": "MIDI-CV",
"description": "Converts MIDI from an external device to CV and gates",
"manualUrl": "https://vcvrack.com/manual/Core#MIDI-CV",
"tags": [
"External",
"MIDI",
"Polyphonic"
]
},
{
"slug": "MIDICCToCVInterface",
"name": "MIDI-CC",
"description": "Converts MIDI CC from an external device to CV",
"manualUrl": "https://vcvrack.com/manual/Core#MIDI-CC",
"tags": [
"External",
"MIDI"
]
},
{
"slug": "MIDITriggerToCVInterface",
"name": "MIDI-Gate",
"description": "Converts MIDI notes from an external device to gates",
"manualUrl": "https://vcvrack.com/manual/Core#MIDI-Gate",
"tags": [
"External",
"MIDI"
]
},
{
"slug": "MIDI-Map",
"name": "MIDI-Map",
"description": "Controls parameters (knobs, sliders, switches) directly with MIDI CC",
"manualUrl": "https://vcvrack.com/manual/Core#MIDI-Map",
"tags": [
"External",
"MIDI"
]
},
{
"slug": "CV-MIDI",
"name": "CV-MIDI",
"description": "Converts CV to MIDI and sends to an external device",
"manualUrl": "https://vcvrack.com/manual/Core#CV-MIDI",
"tags": [
"External",
"MIDI",
"Polyphonic"
]
},
{
"slug": "CV-CC",
"name": "CV-CC",
"description": "Converts CV to MIDI CC and sends to an external device",
"manualUrl": "https://vcvrack.com/manual/Core#CV-CC",
"tags": [
"External",
"MIDI"
]
},
{
"slug": "CV-Gate",
"name": "CV-Gate",
"description": "Converts gates to MIDI notes and sends to an external device",
"manualUrl": "https://vcvrack.com/manual/Core#CV-Gate",
"tags": [
"External",
"MIDI"
]
},
{
"slug": "Blank",
"name": "Blank",
"description": "A resizable blank panel",
"manualUrl": "https://vcvrack.com/manual/Core#Blank",
"tags": [
"Blank"
]
},
{
"slug": "Notes",
"name": "Notes",
"description": "Write text for patch notes or artist attribution",
"manualUrl": "https://vcvrack.com/manual/Core#Notes",
"tags": [
"Blank"
]
}
]
}

View file

@ -168,6 +168,22 @@ Plugin* pluginInstance__GrandeModular;
Plugin* pluginInstance__ZetaCarinaeModules;
namespace rack {
// core plugins
namespace core {
extern Model* modelAudioInterface2;
extern Model* modelMIDI_CV;
extern Model* modelMIDI_CC;
extern Model* modelMIDI_Gate;
extern Model* modelMIDI_Map;
extern Model* modelCV_MIDI;
extern Model* modelCV_CC;
extern Model* modelCV_Gate;
extern Model* modelBlank;
extern Model* modelNotes;
}
// regular plugins
namespace plugin {
struct StaticPluginLoader {
@ -175,6 +191,34 @@ struct StaticPluginLoader {
FILE* file;
json_t* rootJ;
// core
StaticPluginLoader(Plugin* const p)
: plugin(p),
file(nullptr),
rootJ(nullptr)
{
p->path = system::join(CARDINAL_PLUGINS_DIR, "Core.json");
if ((file = std::fopen(p->path.c_str(), "r")) == nullptr)
{
d_stderr2("Manifest file %s does not exist", p->path.c_str());
return;
}
json_error_t error;
if ((rootJ = json_loadf(file, 0, &error)) == nullptr)
{
d_stderr2("JSON parsing error at %s %d:%d %s", p->path.c_str(), error.line, error.column, error.text);
return;
}
// force ABI, we use static plugins so this doesnt matter as long as it builds
json_t* const version = json_string((APP_VERSION_MAJOR + ".0").c_str());
json_object_set(rootJ, "version", version);
json_decref(version);
}
// regular plugins
StaticPluginLoader(Plugin* const p, const char* const name)
: plugin(p),
file(nullptr),
@ -222,9 +266,29 @@ struct StaticPluginLoader {
}
};
static void initStatic__Core()
{
Plugin* const p = new Plugin;
const StaticPluginLoader spl(p);
if (spl.ok())
{
p->addModel(rack::core::modelAudioInterface2);
p->addModel(rack::core::modelMIDI_CV);
p->addModel(rack::core::modelMIDI_CC);
p->addModel(rack::core::modelMIDI_Gate);
p->addModel(rack::core::modelMIDI_Map);
p->addModel(rack::core::modelCV_MIDI);
p->addModel(rack::core::modelCV_CC);
p->addModel(rack::core::modelCV_Gate);
p->addModel(rack::core::modelBlank);
p->addModel(rack::core::modelNotes);
}
}
static void initStatic__AnimatedCircuits()
{
Plugin* p = new Plugin;
Plugin* const p = new Plugin;
pluginInstance__AnimatedCircuits = p;
const StaticPluginLoader spl(p, "AnimatedCircuits");
@ -236,7 +300,7 @@ static void initStatic__AnimatedCircuits()
static void initStatic__AudibleInstruments()
{
Plugin* p = new Plugin;
Plugin* const p = new Plugin;
pluginInstance__AudibleInstruments = p;
const StaticPluginLoader spl(p, "AudibleInstruments");
@ -267,7 +331,7 @@ static void initStatic__AudibleInstruments()
static void initStatic__Befaco()
{
Plugin* p = new Plugin;
Plugin* const p = new Plugin;
pluginInstance__Befaco = p;
const StaticPluginLoader spl(p, "Befaco");
@ -285,7 +349,7 @@ static void initStatic__Befaco()
static void initStatic__BogaudioModules()
{
Plugin* p = new Plugin;
Plugin* const p = new Plugin;
pluginInstance__BogaudioModules = p;
const StaticPluginLoader spl(p, "BogaudioModules");
@ -432,7 +496,7 @@ static void initStatic__BogaudioModules()
static void initStatic__Fundamental()
{
Plugin* p = new Plugin;
Plugin* const p = new Plugin;
pluginInstance__Fundamental = p;
const StaticPluginLoader spl(p, "Fundamental");
@ -470,7 +534,7 @@ static void initStatic__Fundamental()
static void initStatic__GrandeModular()
{
Plugin* p = new Plugin;
Plugin* const p = new Plugin;
pluginInstance__GrandeModular = p;
const StaticPluginLoader spl(p, "GrandeModular");
@ -513,6 +577,7 @@ static void initStatic__ZetaCarinaeModules()
void initStaticPlugins()
{
initStatic__Core();
initStatic__AnimatedCircuits();
initStatic__AudibleInstruments();
initStatic__Befaco();
@ -522,5 +587,12 @@ void initStaticPlugins()
initStatic__ZetaCarinaeModules();
}
void destroyStaticPlugins()
{
for (Plugin* p : plugins)
delete p;
plugins.clear();
}
}
}

View file

@ -18,9 +18,7 @@
#include <asset.hpp>
#include <audio.hpp>
#include <context.hpp>
#include <gamepad.hpp>
#include <library.hpp>
#include <keyboard.hpp>
#include <midi.hpp>
#include <patch.hpp>
#include <plugin.hpp>
@ -39,11 +37,13 @@
#ifdef NDEBUG
# undef DEBUG
#endif
#include "DistrhoPlugin.hpp"
namespace rack {
namespace plugin {
void initStaticPlugins();
void destroyStaticPlugins();
}
}
@ -69,6 +69,9 @@ struct Initializer {
settings::autosaveInterval = 0;
settings::discordUpdateActivity = false;
settings::isPlugin = true;
settings::skipLoadOnLaunch = true;
settings::showTipsOnLaunch = true;
settings::threadCount = 1;
system::init();
asset::init();
logger::init();
@ -117,20 +120,21 @@ struct Initializer {
audio::init(); // does nothing
midi::init(); // does nothing
// rtaudioInit();
plugin::init();
ui::init();
plugin::initStaticPlugins();
ui::init();
}
~Initializer()
{
using namespace rack;
ui::destroy();
ui::destroy(); // does nothing
INFO("Destroying plugins");
plugin::destroyStaticPlugins();
midi::destroy();
audio::destroy();
plugin::destroy();
INFO("Destroying logger");
logger::destroy();
}