Small headless optimizations
Signed-off-by: falkTX <falktx@falktx.com>
This commit is contained in:
parent
e68b175101
commit
dbbc955df6
6 changed files with 92 additions and 10 deletions
|
|
@ -29,6 +29,8 @@ struct HostAudio : TerminalModule {
|
||||||
const int numParams;
|
const int numParams;
|
||||||
const int numInputs;
|
const int numInputs;
|
||||||
const int numOutputs;
|
const int numOutputs;
|
||||||
|
bool bypassed = false;
|
||||||
|
bool in2connected = false;
|
||||||
int dataFrame = 0;
|
int dataFrame = 0;
|
||||||
int64_t lastBlockFrame = -1;
|
int64_t lastBlockFrame = -1;
|
||||||
|
|
||||||
|
|
@ -74,8 +76,12 @@ struct HostAudio : TerminalModule {
|
||||||
// only checked on input
|
// only checked on input
|
||||||
if (lastBlockFrame != blockFrame)
|
if (lastBlockFrame != blockFrame)
|
||||||
{
|
{
|
||||||
|
bypassed = isBypassed();
|
||||||
dataFrame = 0;
|
dataFrame = 0;
|
||||||
lastBlockFrame = blockFrame;
|
lastBlockFrame = blockFrame;
|
||||||
|
|
||||||
|
if (numIO == 2)
|
||||||
|
in2connected = inputs[1].isConnected();
|
||||||
}
|
}
|
||||||
|
|
||||||
// only incremented on output
|
// only incremented on output
|
||||||
|
|
@ -83,7 +89,7 @@ struct HostAudio : TerminalModule {
|
||||||
DISTRHO_SAFE_ASSERT_INT2_RETURN(k < blockFrames, k, blockFrames,);
|
DISTRHO_SAFE_ASSERT_INT2_RETURN(k < blockFrames, k, blockFrames,);
|
||||||
|
|
||||||
// from host into cardinal, shows as output plug
|
// from host into cardinal, shows as output plug
|
||||||
if (isBypassed())
|
if (bypassed)
|
||||||
{
|
{
|
||||||
for (int i=0; i<numOutputs; ++i)
|
for (int i=0; i<numOutputs; ++i)
|
||||||
outputs[i].setVoltage(0.0f);
|
outputs[i].setVoltage(0.0f);
|
||||||
|
|
@ -114,19 +120,24 @@ struct HostAudio : TerminalModule {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct HostAudio2 : HostAudio<2> {
|
struct HostAudio2 : HostAudio<2> {
|
||||||
|
#ifndef HEADLESS
|
||||||
// for stereo meter
|
// for stereo meter
|
||||||
int internalDataFrame = 0;
|
int internalDataFrame = 0;
|
||||||
float internalDataBuffer[2][128];
|
float internalDataBuffer[2][128];
|
||||||
volatile bool resetMeters = true;
|
volatile bool resetMeters = true;
|
||||||
float gainMeterL = 0.0f;
|
float gainMeterL = 0.0f;
|
||||||
float gainMeterR = 0.0f;
|
float gainMeterR = 0.0f;
|
||||||
|
#endif
|
||||||
|
|
||||||
HostAudio2()
|
HostAudio2()
|
||||||
: HostAudio<2>()
|
: HostAudio<2>()
|
||||||
{
|
{
|
||||||
|
#ifndef HEADLESS
|
||||||
std::memset(internalDataBuffer, 0, sizeof(internalDataBuffer));
|
std::memset(internalDataBuffer, 0, sizeof(internalDataBuffer));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef HEADLESS
|
||||||
void onReset() override
|
void onReset() override
|
||||||
{
|
{
|
||||||
HostAudio<2>::onReset();
|
HostAudio<2>::onReset();
|
||||||
|
|
@ -138,6 +149,7 @@ struct HostAudio2 : HostAudio<2> {
|
||||||
HostAudio<2>::onSampleRateChange(e);
|
HostAudio<2>::onSampleRateChange(e);
|
||||||
resetMeters = true;
|
resetMeters = true;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void processTerminalOutput(const ProcessArgs&) override
|
void processTerminalOutput(const ProcessArgs&) override
|
||||||
{
|
{
|
||||||
|
|
@ -147,7 +159,7 @@ struct HostAudio2 : HostAudio<2> {
|
||||||
const int k = dataFrame++;
|
const int k = dataFrame++;
|
||||||
DISTRHO_SAFE_ASSERT_INT2_RETURN(k < blockFrames, k, blockFrames,);
|
DISTRHO_SAFE_ASSERT_INT2_RETURN(k < blockFrames, k, blockFrames,);
|
||||||
|
|
||||||
if (isBypassed())
|
if (bypassed)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
float** const dataOuts = pcontext->dataOuts;
|
float** const dataOuts = pcontext->dataOuts;
|
||||||
|
|
@ -155,9 +167,6 @@ struct HostAudio2 : HostAudio<2> {
|
||||||
// gain (stereo variant only)
|
// gain (stereo variant only)
|
||||||
const float gain = std::pow(params[0].getValue(), 2.f);
|
const float gain = std::pow(params[0].getValue(), 2.f);
|
||||||
|
|
||||||
// left/mono check
|
|
||||||
const bool in2connected = inputs[1].isConnected();
|
|
||||||
|
|
||||||
// read stereo values
|
// read stereo values
|
||||||
float valueL = inputs[0].getVoltageSum() * 0.1f;
|
float valueL = inputs[0].getVoltageSum() * 0.1f;
|
||||||
float valueR = inputs[1].getVoltageSum() * 0.1f;
|
float valueR = inputs[1].getVoltageSum() * 0.1f;
|
||||||
|
|
@ -189,6 +198,7 @@ struct HostAudio2 : HostAudio<2> {
|
||||||
dataOuts[1][k] += valueL;
|
dataOuts[1][k] += valueL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef HEADLESS
|
||||||
const int j = internalDataFrame++;
|
const int j = internalDataFrame++;
|
||||||
internalDataBuffer[0][j] = valueL;
|
internalDataBuffer[0][j] = valueL;
|
||||||
internalDataBuffer[1][j] = valueR;
|
internalDataBuffer[1][j] = valueR;
|
||||||
|
|
@ -209,6 +219,7 @@ struct HostAudio2 : HostAudio<2> {
|
||||||
|
|
||||||
resetMeters = false;
|
resetMeters = false;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -223,7 +234,7 @@ struct HostAudio8 : HostAudio<8> {
|
||||||
const int k = dataFrame++;
|
const int k = dataFrame++;
|
||||||
DISTRHO_SAFE_ASSERT_INT2_RETURN(k < blockFrames, k, blockFrames,);
|
DISTRHO_SAFE_ASSERT_INT2_RETURN(k < blockFrames, k, blockFrames,);
|
||||||
|
|
||||||
if (isBypassed())
|
if (bypassed)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
float** const dataOuts = pcontext->dataOuts;
|
float** const dataOuts = pcontext->dataOuts;
|
||||||
|
|
@ -244,6 +255,7 @@ struct HostAudio8 : HostAudio<8> {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifndef HEADLESS
|
||||||
// --------------------------------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
template<int numIO>
|
template<int numIO>
|
||||||
|
|
@ -343,8 +355,31 @@ struct HostAudioWidget8 : HostAudioWidget<8> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#else
|
||||||
// --------------------------------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
struct HostAudioWidget2 : ModuleWidget {
|
||||||
|
HostAudioWidget2(HostAudio2* const module) {
|
||||||
|
setModule(module);
|
||||||
|
for (uint i=0; i<2; ++i) {
|
||||||
|
addInput(createInput<PJ301MPort>({}, module, i));
|
||||||
|
addOutput(createOutput<PJ301MPort>({}, module, i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
struct HostAudioWidget8 : ModuleWidget {
|
||||||
|
HostAudioWidget8(HostAudio8* const module) {
|
||||||
|
setModule(module);
|
||||||
|
for (uint i=0; i<8; ++i) {
|
||||||
|
addInput(createInput<PJ301MPort>({}, module, i));
|
||||||
|
addOutput(createOutput<PJ301MPort>({}, module, i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------------------------------------------
|
||||||
|
#endif
|
||||||
|
|
||||||
Model* modelHostAudio2 = createModel<HostAudio2, HostAudioWidget2>("HostAudio2");
|
Model* modelHostAudio2 = createModel<HostAudio2, HostAudioWidget2>("HostAudio2");
|
||||||
Model* modelHostAudio8 = createModel<HostAudio8, HostAudioWidget8>("HostAudio8");
|
Model* modelHostAudio8 = createModel<HostAudio8, HostAudioWidget8>("HostAudio8");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -124,6 +124,7 @@ struct HostCV : TerminalModule {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifndef HEADLESS
|
||||||
struct HostCVWidget : ModuleWidgetWith8HP {
|
struct HostCVWidget : ModuleWidgetWith8HP {
|
||||||
HostCVWidget(HostCV* const module)
|
HostCVWidget(HostCV* const module)
|
||||||
{
|
{
|
||||||
|
|
@ -184,6 +185,17 @@ struct HostCVWidget : ModuleWidgetWith8HP {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
#else
|
||||||
|
struct HostCVWidget : ModuleWidget {
|
||||||
|
HostCVWidget(HostCV* const module) {
|
||||||
|
setModule(module);
|
||||||
|
for (uint i=0; i<HostCV::NUM_INPUTS; ++i)
|
||||||
|
addInput(createInput<PJ301MPort>({}, module, i));
|
||||||
|
for (uint i=0; i<HostCV::NUM_OUTPUTS; ++i)
|
||||||
|
addOutput(createOutput<PJ301MPort>({}, module, i));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -695,6 +695,7 @@ struct HostMIDI : TerminalModule {
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#ifndef HEADLESS
|
||||||
struct HostMIDIWidget : ModuleWidgetWith9HP {
|
struct HostMIDIWidget : ModuleWidgetWith9HP {
|
||||||
HostMIDI* const module;
|
HostMIDI* const module;
|
||||||
|
|
||||||
|
|
@ -829,6 +830,17 @@ struct HostMIDIWidget : ModuleWidgetWith9HP {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
#else
|
||||||
|
struct HostMIDIWidget : ModuleWidget {
|
||||||
|
HostMIDIWidget(HostMIDI* const module) {
|
||||||
|
setModule(module);
|
||||||
|
for (uint i=0; i<HostMIDI::NUM_INPUTS; ++i)
|
||||||
|
addInput(createInput<PJ301MPort>({}, module, i));
|
||||||
|
for (uint i=0; i<HostMIDI::NUM_OUTPUTS; ++i)
|
||||||
|
addOutput(createOutput<PJ301MPort>({}, module, i));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,6 @@
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
USE_NAMESPACE_DISTRHO;
|
|
||||||
|
|
||||||
struct HostParameters : TerminalModule {
|
struct HostParameters : TerminalModule {
|
||||||
enum ParamIds {
|
enum ParamIds {
|
||||||
NUM_PARAMS
|
NUM_PARAMS
|
||||||
|
|
@ -91,6 +89,8 @@ struct HostParameters : TerminalModule {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
#ifndef HEADLESS
|
#ifndef HEADLESS
|
||||||
struct CardinalParameterPJ301MPort : PJ301MPort {
|
struct CardinalParameterPJ301MPort : PJ301MPort {
|
||||||
void onDragStart(const DragStartEvent& e) override {
|
void onDragStart(const DragStartEvent& e) override {
|
||||||
|
|
@ -159,11 +159,14 @@ struct HostParametersWidget : ModuleWidgetWith9HP {
|
||||||
struct HostParametersWidget : ModuleWidget {
|
struct HostParametersWidget : ModuleWidget {
|
||||||
HostParametersWidget(HostParameters* const module) {
|
HostParametersWidget(HostParameters* const module) {
|
||||||
setModule(module);
|
setModule(module);
|
||||||
|
for (uint i=0; i<HostParameters::NUM_OUTPUTS; ++i)
|
||||||
for (int i=0; i<24; ++i)
|
|
||||||
addOutput(createOutput<PJ301MPort>({}, module, i));
|
addOutput(createOutput<PJ301MPort>({}, module, i));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
Model* modelHostParameters = createModel<HostParameters, HostParametersWidget>("HostParameters");
|
Model* modelHostParameters = createModel<HostParameters, HostParametersWidget>("HostParameters");
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,8 @@
|
||||||
|
|
||||||
#include "plugincontext.hpp"
|
#include "plugincontext.hpp"
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
struct HostTime : TerminalModule {
|
struct HostTime : TerminalModule {
|
||||||
enum ParamIds {
|
enum ParamIds {
|
||||||
NUM_PARAMS
|
NUM_PARAMS
|
||||||
|
|
@ -166,6 +168,9 @@ struct HostTime : TerminalModule {
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#ifndef HEADLESS
|
||||||
struct HostTimeWidget : ModuleWidget {
|
struct HostTimeWidget : ModuleWidget {
|
||||||
static constexpr const float startX = 10.0f;
|
static constexpr const float startX = 10.0f;
|
||||||
static constexpr const float startY_top = 71.0f;
|
static constexpr const float startY_top = 71.0f;
|
||||||
|
|
@ -285,5 +290,18 @@ struct HostTimeWidget : ModuleWidget {
|
||||||
ModuleWidget::drawLayer(args, layer);
|
ModuleWidget::drawLayer(args, layer);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
#else
|
||||||
|
struct HostTimeWidget : ModuleWidget {
|
||||||
|
HostTimeWidget(HostTime* const module) {
|
||||||
|
setModule(module);
|
||||||
|
for (uint i=0; i<HostTime::kHostTimeCount; ++i)
|
||||||
|
addOutput(createOutput<PJ301MPort>({}, module, i));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
Model* modelHostTime = createModel<HostTime, HostTimeWidget>("HostTime");
|
Model* modelHostTime = createModel<HostTime, HostTimeWidget>("HostTime");
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@
|
||||||
|
|
||||||
using namespace rack;
|
using namespace rack;
|
||||||
|
|
||||||
|
#ifndef HEADLESS
|
||||||
struct CardinalLedDisplayChoice : LedDisplayChoice {
|
struct CardinalLedDisplayChoice : LedDisplayChoice {
|
||||||
bool alignTextCenter = true;
|
bool alignTextCenter = true;
|
||||||
|
|
||||||
|
|
@ -403,3 +404,4 @@ struct OpenGlWidgetWithBrowserPreview : OpenGlWidget {
|
||||||
|
|
||||||
virtual void drawFramebufferForBrowserPreview() = 0;
|
virtual void drawFramebufferForBrowserPreview() = 0;
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue