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