1
Fork 0

Fix headless build; Ignore 2 main CV ins for befaco lv2 test

Signed-off-by: falkTX <falktx@falktx.com>
This commit is contained in:
falkTX 2021-11-02 09:36:36 +00:00
parent 9018ce34c4
commit 9ee6524004
No known key found for this signature in database
GPG Key ID: CDBAA37ABC74FBA0
4 changed files with 26 additions and 9 deletions

View File

@ -33,7 +33,7 @@ bool cpuMeter = false;
} }
Context::~Context() { Context::~Context() {
} }
static thread_local Context* threadContext = nullptr; static thread_local Context* threadContext;
Context* contextGet() { Context* contextGet() {
DISTRHO_SAFE_ASSERT(threadContext != nullptr); DISTRHO_SAFE_ASSERT(threadContext != nullptr);
return threadContext; return threadContext;
@ -121,8 +121,8 @@ struct PluginLv2 {
frameCount frameCount
}; };
const float* CV1_INPUT = (float*)ports[0]; // const float* CV1_INPUT = (float*)ports[0];
const float* CV2_INPUT = (float*)ports[1]; // const float* CV2_INPUT = (float*)ports[1];
const float* IN1_INPUT = (float*)ports[2]; const float* IN1_INPUT = (float*)ports[2];
const float* IN2_INPUT = (float*)ports[3]; const float* IN2_INPUT = (float*)ports[3];
const float* MIX_CV_INPUT = (float*)ports[4]; const float* MIX_CV_INPUT = (float*)ports[4];
@ -141,8 +141,8 @@ struct PluginLv2 {
for (uint32_t i=0; i<sampleCount; ++i) for (uint32_t i=0; i<sampleCount; ++i)
{ {
module->inputs[0].setVoltage(CV1_INPUT[i]); // module->inputs[0].setVoltage(CV1_INPUT[i]);
module->inputs[1].setVoltage(CV2_INPUT[i]); // module->inputs[1].setVoltage(CV2_INPUT[i]);
module->inputs[2].setVoltage(IN1_INPUT[i] * 10); module->inputs[2].setVoltage(IN1_INPUT[i] * 10);
module->inputs[3].setVoltage(IN2_INPUT[i] * 10); module->inputs[3].setVoltage(IN2_INPUT[i] * 10);
module->inputs[4].setVoltage(MIX_CV_INPUT[i]); module->inputs[4].setVoltage(MIX_CV_INPUT[i]);

View File

@ -17,8 +17,9 @@
<urn:Cardinal:Befaco> <urn:Cardinal:Befaco>
a lv2:Plugin, doap:Project ; a lv2:Plugin, doap:Project ;
# NOTE port 0 and 1 are actually CV ins, but we need some kind of optionally-connected stuff implemented first
lv2:port [ lv2:port [
a lv2:InputPort, lv2:CVPort, mod:CVPort ; a lv2:OutputPort, lv2:ControlPort ;
lv2:index 0 ; lv2:index 0 ;
lv2:symbol "lv2_audio_in_1" ; lv2:symbol "lv2_audio_in_1" ;
lv2:name "CV1_INPUT" ; lv2:name "CV1_INPUT" ;
@ -26,7 +27,7 @@
lv2:minimum 0; lv2:minimum 0;
lv2:maximum 10; lv2:maximum 10;
] , [ ] , [
a lv2:InputPort, lv2:CVPort, mod:CVPort ; a lv2:OutputPort, lv2:ControlPort ;
lv2:index 1 ; lv2:index 1 ;
lv2:symbol "lv2_audio_in_2" ; lv2:symbol "lv2_audio_in_2" ;
lv2:name "CV2_INPUT" ; lv2:name "CV2_INPUT" ;

View File

@ -28,7 +28,7 @@ Plugin* pluginInstance__Befaco;
namespace rack { namespace rack {
Context::~Context() { Context::~Context() {
} }
static thread_local Context* threadContext = nullptr; static thread_local Context* threadContext;
Context* contextGet() { Context* contextGet() {
DISTRHO_SAFE_ASSERT(threadContext != nullptr); DISTRHO_SAFE_ASSERT(threadContext != nullptr);
return threadContext; return threadContext;

View File

@ -15,7 +15,11 @@
* For a full copy of the GNU General Public License see the LICENSE file. * For a full copy of the GNU General Public License see the LICENSE file.
*/ */
#include "glBars.hpp" #ifndef HEADLESS
# include "glBars.hpp"
#else
# include "plugin.hpp"
#endif
#define SAMPLES_PER_DRAW 256 #define SAMPLES_PER_DRAW 256
@ -34,24 +38,29 @@ struct glBarsModule : Module {
NUM_LIGHTS NUM_LIGHTS
}; };
#ifndef HEADLESS
glBarsState state; glBarsState state;
float audioData[SAMPLES_PER_DRAW]; float audioData[SAMPLES_PER_DRAW];
unsigned audioDataFill = 0; unsigned audioDataFill = 0;
#endif
glBarsModule() { glBarsModule() {
config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS); config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS);
} }
void process(const ProcessArgs&) override { void process(const ProcessArgs&) override {
#ifndef HEADLESS
audioData[audioDataFill++] = inputs[IN1_INPUT].getVoltage(); audioData[audioDataFill++] = inputs[IN1_INPUT].getVoltage();
if (audioDataFill == SAMPLES_PER_DRAW) { if (audioDataFill == SAMPLES_PER_DRAW) {
audioDataFill = 0; audioDataFill = 0;
state.AudioData(audioData, SAMPLES_PER_DRAW); state.AudioData(audioData, SAMPLES_PER_DRAW);
} }
#endif
} }
}; };
#ifndef HEADLESS
struct glBarsRendererWidget : OpenGlWidget { struct glBarsRendererWidget : OpenGlWidget {
glBarsModule* const glBars; glBarsModule* const glBars;
@ -73,12 +82,17 @@ struct glBarsRendererWidget : OpenGlWidget {
glBars->state.Render(); glBars->state.Render();
} }
}; };
#endif
struct glBarsWidget : ModuleWidget { struct glBarsWidget : ModuleWidget {
#ifndef HEADLESS
glBarsRendererWidget* const glBarsRenderer; glBarsRendererWidget* const glBarsRenderer;
#endif
glBarsWidget(glBarsModule* const module) glBarsWidget(glBarsModule* const module)
#ifndef HEADLESS
: glBarsRenderer(new glBarsRendererWidget(module)) : glBarsRenderer(new glBarsRendererWidget(module))
#endif
{ {
setModule(module); setModule(module);
setPanel(APP->window->loadSvg(asset::plugin(pluginInstance, "res/glBars.svg"))); setPanel(APP->window->loadSvg(asset::plugin(pluginInstance, "res/glBars.svg")));
@ -88,9 +102,11 @@ struct glBarsWidget : ModuleWidget {
addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0))); addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0)));
addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH))); addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
#ifndef HEADLESS
glBarsRenderer->box.pos = Vec(2 * RACK_GRID_WIDTH, 0); glBarsRenderer->box.pos = Vec(2 * RACK_GRID_WIDTH, 0);
glBarsRenderer->box.size = Vec(box.size.x - 2 * RACK_GRID_WIDTH, box.size.y); glBarsRenderer->box.size = Vec(box.size.x - 2 * RACK_GRID_WIDTH, box.size.y);
addChild(glBarsRenderer); addChild(glBarsRenderer);
#endif
addInput(createInput<PJ301MPort>(Vec(3, 54), module, glBarsModule::IN1_INPUT)); addInput(createInput<PJ301MPort>(Vec(3, 54), module, glBarsModule::IN1_INPUT));
} }