Browse Source

Initial bypass implementation, MIDI only for now

tags/22.03
falkTX 3 years ago
parent
commit
faeaa5862c
4 changed files with 50 additions and 7 deletions
  1. +1
    -1
      plugins/Cardinal/src/HostAudio.cpp
  2. +1
    -1
      plugins/Cardinal/src/plugincontext.hpp
  3. +46
    -4
      src/CardinalPlugin.cpp
  4. +2
    -1
      src/PluginContext.hpp

+ 1
- 1
plugins/Cardinal/src/HostAudio.cpp View File

@@ -139,7 +139,7 @@ struct HostAudio2 : HostAudio<2> {
resetMeters = true; resetMeters = true;
} }


void processTerminalOutput(const ProcessArgs&)
void processTerminalOutput(const ProcessArgs&) override
{ {
const int blockFrames = pcontext->engine->getBlockFrames(); const int blockFrames = pcontext->engine->getBlockFrames();




+ 1
- 1
plugins/Cardinal/src/plugincontext.hpp View File

@@ -55,7 +55,7 @@ struct CardinalPluginContext : rack::Context {
double sampleRate; double sampleRate;
float parameters[kModuleParameters]; float parameters[kModuleParameters];
CardinalVariant variant; CardinalVariant variant;
bool playing, reset, bbtValid;
bool bypassed, playing, reset, bbtValid;
int32_t bar, beat, beatsPerBar, beatType; int32_t bar, beat, beatsPerBar, beatType;
uint64_t frame; uint64_t frame;
double barStartTick, beatsPerMinute; double barStartTick, beatsPerMinute;


+ 46
- 4
src/CardinalPlugin.cpp View File

@@ -343,6 +343,9 @@ struct Initializer
void CardinalPluginContext::writeMidiMessage(const rack::midi::Message& message, const uint8_t channel) void CardinalPluginContext::writeMidiMessage(const rack::midi::Message& message, const uint8_t channel)
{ {
if (bypassed)
return;
const size_t size = message.bytes.size(); const size_t size = message.bytes.size();
DISTRHO_SAFE_ASSERT_RETURN(size > 0,); DISTRHO_SAFE_ASSERT_RETURN(size > 0,);
DISTRHO_SAFE_ASSERT_RETURN(message.frame >= 0,); DISTRHO_SAFE_ASSERT_RETURN(message.frame >= 0,);
@@ -429,6 +432,7 @@ class CardinalPlugin : public CardinalBasePlugin
#if DISTRHO_PLUGIN_NUM_INPUTS != 0 #if DISTRHO_PLUGIN_NUM_INPUTS != 0
/* If host audio ins == outs we can get issues for inplace processing. /* If host audio ins == outs we can get issues for inplace processing.
* So allocate a float array that will serve as safe copy for those cases. * So allocate a float array that will serve as safe copy for those cases.
* Also used for bypass, so inputs are fully zero.
*/ */
float** fAudioBufferCopy; float** fAudioBufferCopy;
#endif #endif
@@ -439,6 +443,10 @@ class CardinalPlugin : public CardinalBasePlugin
String fStateScreenshot; String fStateScreenshot;
String fWindowSize; String fWindowSize;
// bypass handling
bool fWasBypassed;
MidiEvent bypassMidiEvents[16];
#ifndef HEADLESS #ifndef HEADLESS
// real values, not VCV interpreted ones // real values, not VCV interpreted ones
float fWindowParameters[kWindowParameterCount]; float fWindowParameters[kWindowParameterCount];
@@ -451,7 +459,8 @@ public:
#if DISTRHO_PLUGIN_NUM_INPUTS != 0 #if DISTRHO_PLUGIN_NUM_INPUTS != 0
fAudioBufferCopy(nullptr), fAudioBufferCopy(nullptr),
#endif #endif
fPreviousFrame(0)
fPreviousFrame(0),
fWasBypassed(false)
{ {
#ifndef HEADLESS #ifndef HEADLESS
fWindowParameters[kWindowParameterShowTooltips] = 1.0f; fWindowParameters[kWindowParameterShowTooltips] = 1.0f;
@@ -485,6 +494,16 @@ public:
} }
} DISTRHO_SAFE_EXCEPTION("create unique temporary path"); } DISTRHO_SAFE_EXCEPTION("create unique temporary path");
// initialize midi events used when entering bypassed state
std::memset(bypassMidiEvents, 0, sizeof(bypassMidiEvents));
for (uint8_t i=0; i<16; ++i)
{
bypassMidiEvents[i].size = 3;
bypassMidiEvents[i].data[0] = 0xB0 + i;
bypassMidiEvents[i].data[1] = 0x7B;
}
const float sampleRate = getSampleRate(); const float sampleRate = getSampleRate();
rack::settings::sampleRate = sampleRate; rack::settings::sampleRate = sampleRate;
@@ -773,7 +792,7 @@ protected:
// bypass // bypass
if (index == kModuleParameters) if (index == kModuleParameters)
return 0.0f;
return context->bypassed ? 1.0f : 0.0f;
#ifndef HEADLESS #ifndef HEADLESS
// window related parameters // window related parameters
@@ -797,7 +816,10 @@ protected:
// bypass // bypass
if (index == kModuleParameters) if (index == kModuleParameters)
{
context->bypassed = value > 0.5f;
return; return;
}
#ifndef HEADLESS #ifndef HEADLESS
// window related parameters // window related parameters
@@ -924,6 +946,8 @@ protected:
{ {
rack::contextSet(context); rack::contextSet(context);
const bool bypassed = context->bypassed;
{ {
const TimePosition& timePos(getTimePosition()); const TimePosition& timePos(getTimePosition());
@@ -977,10 +1001,28 @@ protected:
for (int i=0; i<DISTRHO_PLUGIN_NUM_OUTPUTS; ++i) for (int i=0; i<DISTRHO_PLUGIN_NUM_OUTPUTS; ++i)
std::memset(outputs[i], 0, sizeof(float)*frames); std::memset(outputs[i], 0, sizeof(float)*frames);
context->midiEvents = midiEvents;
context->midiEventCount = midiEventCount;
if (bypassed)
{
if (fWasBypassed != bypassed)
{
context->midiEvents = bypassMidiEvents;
context->midiEventCount = 16;
}
else
{
context->midiEvents = nullptr;
context->midiEventCount = 0;
}
}
else
{
context->midiEvents = midiEvents;
context->midiEventCount = midiEventCount;
}
context->engine->stepBlock(frames); context->engine->stepBlock(frames);
fWasBypassed = bypassed;
} }
void bufferSizeChanged(const uint32_t newBufferSize) override void bufferSizeChanged(const uint32_t newBufferSize) override


+ 2
- 1
src/PluginContext.hpp View File

@@ -52,7 +52,7 @@ struct CardinalPluginContext : rack::Context {
double sampleRate; double sampleRate;
float parameters[kModuleParameters]; float parameters[kModuleParameters];
CardinalVariant variant; CardinalVariant variant;
bool playing, reset, bbtValid;
bool bypassed, playing, reset, bbtValid;
int32_t bar, beat, beatsPerBar, beatType; int32_t bar, beat, beatsPerBar, beatType;
uint64_t frame; uint64_t frame;
double barStartTick, beatsPerMinute; double barStartTick, beatsPerMinute;
@@ -79,6 +79,7 @@ struct CardinalPluginContext : rack::Context {
#else #else
#error cardinal variant not set #error cardinal variant not set
#endif #endif
bypassed(false),
playing(false), playing(false),
reset(false), reset(false),
bbtValid(false), bbtValid(false),


Loading…
Cancel
Save