Skip to content

Instantly share code, notes, and snippets.

@giuliomoro
Created January 28, 2023 18:34
Show Gist options
  • Save giuliomoro/b58a342aa5a480cd31c371829fffe3fd to your computer and use it in GitHub Desktop.
Save giuliomoro/b58a342aa5a480cd31c371829fffe3fd to your computer and use it in GitHub Desktop.
#include <Bela.h>
#include "RNBO.h"
#include <string>
#include <MiscUtilities.h>
#include <algorithm>
//#define BELA_RNBO_USE_TRILL // uncomment to use Trill
#ifdef BELA_RNBO_USE_TRILL
#include <libraries/Trill/Trill.h>
#endif // BELA_RNBO_USE_TRILL
static const unsigned int kNoParam = -1; // use this below if you want to skip a channel
// A list of exposed parameters is printed when the program starts. Enter here
// the indeces of those you want to control from analog ins.
// The first n analog ins will be used to set these parameters. These values
// are set at every block, which means that the default value or the value set
// by a preset will be immediately overridden if the corresponding paramter is
// controlled by analogIn
static std::vector<unsigned int> parametersFromAnalog = {};
// same but for mapping digital ins to parameters. These are only updated upon
// change, so preset-loaded values are not necessarily overridden immediately
static std::vector<unsigned int> parametersFromDigital = {};
// mapping parameters to digital out, e.g.: to display a toggle state with an LED
static std::vector<unsigned int> parametersToDigital = {
5, // out 0
6, // out 1
3, // out 2
4, // out 3
7, // out 4
8, // out 5
0, // out 6
1, // out 7
9, // out 8
kNoParam, // out 9
2, // out 10
// below are optional, here just for completeness
kNoParam, // out 11
kNoParam, // out 12
kNoParam, // out 13
kNoParam, // out 14
kNoParam, // out 15
};
#ifdef BELA_RNBO_USE_TRILL
// same but for mapping Trill location to parameters.
static std::vector<unsigned int> parametersFromTrillLocation = {};
// same but for mapping Trill size to parameters.
static std::vector<unsigned int> parametersFromTrillSize = {};
static std::vector<Trill*> trills {
// add/edit more Trills here
new Trill(1, Trill::BAR),
};
static std::vector<float> trillLocationParametersPast(parametersFromTrillLocation.size());
static std::vector<float> trillSizeParametersPast(parametersFromTrillSize.size());
#endif // BELA_RNBO_USE_TRILL
// whether to show hidden parameters when printing the parameters list
bool showHiddenParameters = true;
// has to be a pointer to ensure that it gets initialised after
// initialisation for the static PlatformInterfaceStdLib platformInstance has already taken place
static RNBO::CoreObject* rnbo;
static RNBO::PresetList* presetList;
static std::vector<bool> digitalParametersPast(parametersFromDigital.size());
void Bela_userSettings(BelaInitSettings *settings)
{
settings->uniformSampleRate = 1;
settings->interleave = 0;
settings->analogOutputsPersist = 0;
}
template <typename T>
static ssize_t findIndex(const T value, std::vector<T> const& vals)
{
ssize_t found = -1;
for(size_t i = 0; i < vals.size(); ++i)
{
if(value == vals[i])
{
found = i;
break;
}
}
return found;
}
#ifdef BELA_RNBO_USE_TRILL
static void loop(void*)
{
while(!Bela_stopRequested())
{
for(auto& t : trills)
t->readI2C();
usleep(5000);
}
}
#endif // BELA_RNBO_USE_TRILL
bool setup(BelaContext *context, void *userData)
{
#ifdef BELA_RNBO_USE_TRILL
Bela_runAuxiliaryTask(loop);
#endif // BELA_RNBO_USE_TRILL
// verify settings have been applied
if(context->flags & BELA_FLAG_INTERLEAVED)
{
fprintf(stderr, "You need a non-interleaved buffer\n");
return false;
}
if(context->analogSampleRate != context->audioSampleRate)
{
fprintf(stderr, "You need the analog and audio channels to have the same sampling rate\n");
return false;
}
rnbo = new RNBO::CoreObject;
parametersFromAnalog.resize(std::min(parametersFromAnalog.size(), context->analogInChannels));
parametersFromDigital.resize(std::min(parametersFromDigital.size(), context->digitalChannels));
#ifdef BELA_RNBO_USE_TRILL
parametersFromTrillLocation.resize(std::min(parametersFromTrillLocation.size(), trills.size()));
parametersFromTrillSize.resize(std::min(parametersFromTrillSize.size(), trills.size()));
#endif // BELA_RNBO_USE_TRILL
unsigned int hiddenParameters = 0;
printf("Available parameters: %u\n", rnbo->getNumParameters());
for(unsigned int n = 0; n < rnbo->getNumParameters(); ++n)
{
RNBO::ParameterInfo info;
rnbo->getParameterInfo(n, &info);
if((!info.visible || info.debug) && !showHiddenParameters)
{
hiddenParameters++;
continue;
}
printf("[%d] %s", n, rnbo->getParameterName(n));
ssize_t analog = findIndex(n, parametersFromAnalog);
ssize_t digitalIn = findIndex(n, parametersFromDigital);
ssize_t digitalOut = findIndex(n, parametersToDigital);
#ifdef BELA_RNBO_USE_TRILL
ssize_t trillLocation = findIndex(n, parametersFromTrillLocation);
ssize_t trillSize = findIndex(n, parametersFromTrillSize);
#endif // BELA_RNBO_USE_TRILL
if(analog >= 0)
printf(" - controlled by analog in %d", analog);
if(digitalIn >= 0) {
printf(" - controlled by digital in %d", digitalIn);
pinMode(context, 0, digitalIn, INPUT);
}
if(digitalOut >= 0) {
printf(" - controlling digital out %d", digitalOut);
pinMode(context, 0, digitalOut, OUTPUT);
}
#ifdef BELA_RNBO_USE_TRILL
if(trillLocation >= 0)
printf(" - controlled by Trill location %d", trillLocation);
if(trillSize >= 0)
printf(" - controlled by Trill size %d", trillSize);
#endif // BELA_RNBO_USE_TRILL
printf("\n");
if(analog >= 0 && digitalIn >= 0)
fprintf(stderr, "Parameter %d controlled by both analog and digital in. Digital in ignored\n", n);
}
if(hiddenParameters)
printf("(%d hidden parameters)\n", hiddenParameters);
std::string presetFile = "presets.json";
printf("Loading presets from %s\n", presetFile.c_str());
std::string s = IoUtils::readTextFile(presetFile);
if(s.size())
{
// load presets, see C++ snippets from https://rnbo.cycling74.com/learn/presets-with-snapshots
presetList = new RNBO::PresetList(s);
printf("Found %d presets\n", presetList->size());
if(presetList->size())
{
unsigned int idx = 0;
RNBO::UniquePresetPtr preset = presetList->presetAtIndex(idx);
printf("Loading preset %d: %s\n", idx, presetList->presetNameAtIndex(idx).c_str());
rnbo->setPreset(std::move(preset));
}
}
rnbo->prepareToProcess(context->audioSampleRate, context->audioFrames, true);
return true;
}
template <typename T, typename F, typename A>
static void sendOnChange(std::vector<T>& past, std::vector<unsigned int>& parameters, F func, A arg = (void*)nullptr)
{
for(unsigned int c = 0; c < parameters.size(); ++c)
{
float value = func(c, arg);
// only send on change
if(value != past[c])
{
if(kNoParam != parameters[c])
{
rnbo->setParameterValueNormalized(parameters[c], value);
past[c] = value;
}
}
}
}
void render(BelaContext *context, void *userData)
{
unsigned int nFrames = context->audioFrames;
unsigned int nAnalogParameters = parametersFromAnalog.size();
for(unsigned int c = 0; c < nAnalogParameters; ++c)
{
if(kNoParam != parametersFromAnalog[c])
rnbo->setParameterValueNormalized(parametersFromAnalog[c], analogReadNI(context, 0, c));
}
sendOnChange(digitalParametersPast, parametersFromDigital, [](unsigned int c, BelaContext* context ) -> float { return digitalRead(context, 0, c); }, context);
for(unsigned int c = 0; c < parametersToDigital.size(); ++c)
{
if(kNoParam != parametersToDigital[c])
{
digitalWrite(context, 0, c, rnbo->getParameterValue(parametersToDigital[c]) > 0.5f);
rt_printf("%.2f ", rnbo->getParameterValue(parametersToDigital[c]));
}
}
rt_printf("\n");
#ifdef BELA_RNBO_USE_TRILL
sendOnChange(trillLocationParametersPast, parametersFromTrillLocation, [](unsigned int c, void*) { return trills[c]->compoundTouchLocation(); });
sendOnChange(trillSizeParametersPast, parametersFromTrillSize, [](unsigned int c, void*) { return trills[c]->compoundTouchSize(); });
#endif // BELA_RNBO_USE_TRILL
unsigned int maxInChannels = context->audioInChannels + context->analogInChannels - nAnalogParameters;
unsigned int nInChannels = rnbo->getNumInputChannels();
if(nInChannels > maxInChannels)
nInChannels = maxInChannels;
float* inputs[nInChannels];
for(unsigned int c = 0; c < nInChannels; ++c)
{
if(c < context->audioInChannels)
inputs[c] = (float*)(context->audioIn + c * nFrames);
else
inputs[c] = (float*)(context->analogIn + (c - nAnalogParameters - context->audioInChannels) * nFrames);
}
unsigned int maxOutChannels = context->audioOutChannels + context->analogOutChannels;
unsigned int nOutChannels = rnbo->getNumOutputChannels();
if(nOutChannels > maxOutChannels)
nOutChannels = maxOutChannels;
float* outputs[nOutChannels];
for(unsigned int c = 0; c < nOutChannels; ++c)
{
if(c < context->audioOutChannels)
outputs[c] = context->audioOut + c * nFrames;
else
outputs[c] = context->analogOut + (c - (context->audioOutChannels)) * nFrames;
}
rnbo->process(inputs, nInChannels, outputs, nOutChannels, nFrames);
}
void cleanup(BelaContext *context, void *userData)
{
#ifdef BELA_RNBO_USE_TRILL
for(auto& p : trills)
delete p;
#endif // BELA_RNBO_USE_TRILL
delete presetList;
delete rnbo;
}
/*******************************************************************************************************************
Cycling '74 License for Max-Generated Code for Export
Copyright (c) 2022 Cycling '74
The code that Max generates automatically and that end users are capable of exporting and using, and any
associated documentation files (the “Software”) is a work of authorship for which Cycling '74 is the author
and owner for copyright purposes. A license is hereby granted, free of charge, to any person obtaining a
copy of the Software (“Licensee”) to use, copy, modify, merge, publish, and distribute copies of the Software,
and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The Software is licensed to Licensee only for non-commercial use. Users who wish to make commercial use of the
Software must contact the copyright owner to determine if a license for commercial use is available, and the
terms and conditions for same, which may include fees or royalties. For commercial use, please send inquiries
to licensing@cycling74.com. The determination of whether a use is commercial use or non-commercial use is based
upon the use, not the user. The Software may be used by individuals, institutions, governments, corporations, or
other business whether for-profit or non-profit so long as the use itself is not a commercialization of the
materials or a use that generates or is intended to generate income, revenue, sales or profit.
The above copyright notice and this license shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
Please see https://support.cycling74.com/hc/en-us/articles/10730637742483-RNBO-Export-Licensing-FAQ for additional information
*******************************************************************************************************************/
#include "RNBO_Common.h"
#include "RNBO_AudioSignal.h"
namespace RNBO {
#define floor(x) ((long)(x))
#if defined(__GNUC__) || defined(__clang__)
#define RNBO_RESTRICT __restrict__
#elif defined(_MSC_VER)
#define RNBO_RESTRICT __restrict
#endif
#define FIXEDSIZEARRAYINIT(...) { }
class rnbomatic : public PatcherInterfaceImpl {
public:
rnbomatic()
{
}
~rnbomatic()
{
}
rnbomatic* getTopLevelPatcher() {
return this;
}
void cancelClockEvents()
{
getEngine()->flushClockEvents(this, -1688633604, false);
}
template <typename T> void listquicksort(T& arr, T& sortindices, Int l, Int h, bool ascending) {
if (l < h) {
Int p = (Int)(this->listpartition(arr, sortindices, l, h, ascending));
this->listquicksort(arr, sortindices, l, p - 1, ascending);
this->listquicksort(arr, sortindices, p + 1, h, ascending);
}
}
template <typename T> Int listpartition(T& arr, T& sortindices, Int l, Int h, bool ascending) {
number x = arr[(Index)h];
Int i = (Int)(l - 1);
for (Int j = (Int)(l); j <= h - 1; j++) {
bool asc = (bool)((bool)(ascending) && arr[(Index)j] <= x);
bool desc = (bool)((bool)(!(bool)(ascending)) && arr[(Index)j] >= x);
if ((bool)(asc) || (bool)(desc)) {
i++;
this->listswapelements(arr, i, j);
this->listswapelements(sortindices, i, j);
}
}
i++;
this->listswapelements(arr, i, h);
this->listswapelements(sortindices, i, h);
return i;
}
template <typename T> void listswapelements(T& arr, Int a, Int b) {
auto tmp = arr[(Index)a];
arr[(Index)a] = arr[(Index)b];
arr[(Index)b] = tmp;
}
number mstosamps(MillisecondTime ms) {
return ms * this->sr * 0.001;
}
MillisecondTime currenttime() {
return this->_currentTime;
}
number tempo() {
return this->getTopLevelPatcher()->globaltransport_getTempo();
}
number mstobeats(number ms) {
return ms * this->tempo() * 0.008 / (number)480;
}
MillisecondTime sampstoms(number samps) {
return samps * 1000 / this->sr;
}
Index getNumMidiInputPorts() const {
return 0;
}
void processMidiEvent(MillisecondTime , int , ConstByteArray , Index ) {}
Index getNumMidiOutputPorts() const {
return 0;
}
void process(
SampleValue ** inputs,
Index numInputs,
SampleValue ** outputs,
Index numOutputs,
Index n
) {
RNBO_UNUSED(numOutputs);
RNBO_UNUSED(outputs);
this->vs = n;
this->updateTime(this->getEngine()->getCurrentTime());
SampleValue * in1 = (numInputs >= 1 && inputs[0] ? inputs[0] : this->zeroBuffer);
this->peakamp_01_perform(in1, n);
this->stackprotect_perform(n);
this->globaltransport_advance();
this->audioProcessSampleCount += this->vs;
}
void prepareToProcess(number sampleRate, Index maxBlockSize, bool force) {
if (this->maxvs < maxBlockSize || !this->didAllocateSignals) {
this->globaltransport_tempo = resizeSignal(this->globaltransport_tempo, this->maxvs, maxBlockSize);
this->globaltransport_state = resizeSignal(this->globaltransport_state, this->maxvs, maxBlockSize);
this->zeroBuffer = resizeSignal(this->zeroBuffer, this->maxvs, maxBlockSize);
this->dummyBuffer = resizeSignal(this->dummyBuffer, this->maxvs, maxBlockSize);
this->didAllocateSignals = true;
}
const bool sampleRateChanged = sampleRate != this->sr;
const bool maxvsChanged = maxBlockSize != this->maxvs;
const bool forceDSPSetup = sampleRateChanged || maxvsChanged || force;
if (sampleRateChanged || maxvsChanged) {
this->vs = maxBlockSize;
this->maxvs = maxBlockSize;
this->sr = sampleRate;
this->invsr = 1 / sampleRate;
}
this->peakamp_01_dspsetup(forceDSPSetup);
this->globaltransport_dspsetup(forceDSPSetup);
if (sampleRateChanged)
this->onSampleRateChanged(sampleRate);
}
void setProbingTarget(MessageTag id) {
switch (id) {
default:
this->setProbingIndex(-1);
break;
}
}
void setProbingIndex(ProbingIndex ) {}
Index getProbingChannels(MessageTag outletId) const {
RNBO_UNUSED(outletId);
return 0;
}
DataRef* getDataRef(DataRefIndex index) {
switch (index) {
default:
return nullptr;
}
}
DataRefIndex getNumDataRefs() const {
return 0;
}
void fillDataRef(DataRefIndex , DataRef& ) {}
void processDataViewUpdate(DataRefIndex , MillisecondTime ) {}
void initialize() {
this->assign_defaults();
this->setState();
this->initializeObjects();
this->allocateDataRefs();
this->startup();
}
Index getIsMuted() {
return this->isMuted;
}
void setIsMuted(Index v) {
this->isMuted = v;
}
Index getPatcherSerial() const {
return 0;
}
void getState(PatcherStateInterface& ) {}
void setState() {}
void getPreset(PatcherStateInterface& preset) {
preset["__presetid"] = "rnbo";
}
void setPreset(MillisecondTime , PatcherStateInterface& ) {}
void processTempoEvent(MillisecondTime time, Tempo tempo) {
this->updateTime(time);
if (this->globaltransport_setTempo(tempo, false))
{}
}
void processTransportEvent(MillisecondTime time, TransportState state) {
this->updateTime(time);
if (this->globaltransport_setState(state, false))
{}
}
void processBeatTimeEvent(MillisecondTime time, BeatTime beattime) {
this->updateTime(time);
if (this->globaltransport_setBeatTime(beattime, false))
{}
}
void onSampleRateChanged(double ) {}
void processTimeSignatureEvent(MillisecondTime time, int numerator, int denominator) {
this->updateTime(time);
if (this->globaltransport_setTimeSignature(numerator, denominator, false))
{}
}
void setParameterValue(ParameterIndex index, ParameterValue v, MillisecondTime time) {
this->updateTime(time);
switch (index) {
case 0:
this->toggle_01_value_set(v);
break;
case 1:
this->toggle_02_value_set(v);
break;
case 2:
this->toggle_03_value_set(v);
break;
case 3:
this->toggle_04_value_set(v);
break;
case 4:
this->toggle_05_value_set(v);
break;
case 5:
this->toggle_06_value_set(v);
break;
case 6:
this->toggle_07_value_set(v);
break;
case 7:
this->toggle_08_value_set(v);
break;
case 8:
this->toggle_09_value_set(v);
break;
case 9:
this->toggle_10_value_set(v);
break;
}
}
void processParameterEvent(ParameterIndex index, ParameterValue value, MillisecondTime time) {
this->setParameterValue(index, value, time);
}
void processNormalizedParameterEvent(ParameterIndex index, ParameterValue value, MillisecondTime time) {
this->setParameterValueNormalized(index, value, time);
}
ParameterValue getParameterValue(ParameterIndex index) {
switch (index) {
case 0:
return this->toggle_01_value;
case 1:
return this->toggle_02_value;
case 2:
return this->toggle_03_value;
case 3:
return this->toggle_04_value;
case 4:
return this->toggle_05_value;
case 5:
return this->toggle_06_value;
case 6:
return this->toggle_07_value;
case 7:
return this->toggle_08_value;
case 8:
return this->toggle_09_value;
case 9:
return this->toggle_10_value;
default:
return 0;
}
}
ParameterIndex getNumSignalInParameters() const {
return 0;
}
ParameterIndex getNumSignalOutParameters() const {
return 0;
}
ParameterIndex getNumParameters() const {
return 10;
}
ConstCharPointer getParameterName(ParameterIndex index) const {
switch (index) {
case 0:
return "toggle_01_value";
case 1:
return "toggle_02_value";
case 2:
return "toggle_03_value";
case 3:
return "toggle_04_value";
case 4:
return "toggle_05_value";
case 5:
return "toggle_06_value";
case 6:
return "toggle_07_value";
case 7:
return "toggle_08_value";
case 8:
return "toggle_09_value";
case 9:
return "toggle_10_value";
default:
return "bogus";
}
}
ConstCharPointer getParameterId(ParameterIndex index) const {
switch (index) {
case 0:
return "toggle_obj-10/value";
case 1:
return "toggle_obj-3/value";
case 2:
return "toggle_obj-4/value";
case 3:
return "toggle_obj-6/value";
case 4:
return "toggle_obj-8/value";
case 5:
return "toggle_obj-12/value";
case 6:
return "toggle_obj-20/value";
case 7:
return "toggle_obj-18/value";
case 8:
return "toggle_obj-16/value";
case 9:
return "toggle_obj-14/value";
default:
return "bogus";
}
}
void getParameterInfo(ParameterIndex index, ParameterInfo * info) const {
{
switch (index) {
case 0:
info->type = ParameterTypeNumber;
info->initialValue = 0;
info->min = 0;
info->max = 1;
info->exponent = 1;
info->steps = 0;
info->debug = false;
info->saveable = true;
info->transmittable = true;
info->initialized = true;
info->visible = false;
info->displayName = "";
info->unit = "";
info->ioType = IOTypeUndefined;
info->signalIndex = INVALID_INDEX;
break;
case 1:
info->type = ParameterTypeNumber;
info->initialValue = 0;
info->min = 0;
info->max = 1;
info->exponent = 1;
info->steps = 0;
info->debug = false;
info->saveable = true;
info->transmittable = true;
info->initialized = true;
info->visible = false;
info->displayName = "";
info->unit = "";
info->ioType = IOTypeUndefined;
info->signalIndex = INVALID_INDEX;
break;
case 2:
info->type = ParameterTypeNumber;
info->initialValue = 0;
info->min = 0;
info->max = 1;
info->exponent = 1;
info->steps = 0;
info->debug = false;
info->saveable = true;
info->transmittable = true;
info->initialized = true;
info->visible = false;
info->displayName = "";
info->unit = "";
info->ioType = IOTypeUndefined;
info->signalIndex = INVALID_INDEX;
break;
case 3:
info->type = ParameterTypeNumber;
info->initialValue = 0;
info->min = 0;
info->max = 1;
info->exponent = 1;
info->steps = 0;
info->debug = false;
info->saveable = true;
info->transmittable = true;
info->initialized = true;
info->visible = false;
info->displayName = "";
info->unit = "";
info->ioType = IOTypeUndefined;
info->signalIndex = INVALID_INDEX;
break;
case 4:
info->type = ParameterTypeNumber;
info->initialValue = 0;
info->min = 0;
info->max = 1;
info->exponent = 1;
info->steps = 0;
info->debug = false;
info->saveable = true;
info->transmittable = true;
info->initialized = true;
info->visible = false;
info->displayName = "";
info->unit = "";
info->ioType = IOTypeUndefined;
info->signalIndex = INVALID_INDEX;
break;
case 5:
info->type = ParameterTypeNumber;
info->initialValue = 0;
info->min = 0;
info->max = 1;
info->exponent = 1;
info->steps = 0;
info->debug = false;
info->saveable = true;
info->transmittable = true;
info->initialized = true;
info->visible = false;
info->displayName = "";
info->unit = "";
info->ioType = IOTypeUndefined;
info->signalIndex = INVALID_INDEX;
break;
case 6:
info->type = ParameterTypeNumber;
info->initialValue = 0;
info->min = 0;
info->max = 1;
info->exponent = 1;
info->steps = 0;
info->debug = false;
info->saveable = true;
info->transmittable = true;
info->initialized = true;
info->visible = false;
info->displayName = "";
info->unit = "";
info->ioType = IOTypeUndefined;
info->signalIndex = INVALID_INDEX;
break;
case 7:
info->type = ParameterTypeNumber;
info->initialValue = 0;
info->min = 0;
info->max = 1;
info->exponent = 1;
info->steps = 0;
info->debug = false;
info->saveable = true;
info->transmittable = true;
info->initialized = true;
info->visible = false;
info->displayName = "";
info->unit = "";
info->ioType = IOTypeUndefined;
info->signalIndex = INVALID_INDEX;
break;
case 8:
info->type = ParameterTypeNumber;
info->initialValue = 0;
info->min = 0;
info->max = 1;
info->exponent = 1;
info->steps = 0;
info->debug = false;
info->saveable = true;
info->transmittable = true;
info->initialized = true;
info->visible = false;
info->displayName = "";
info->unit = "";
info->ioType = IOTypeUndefined;
info->signalIndex = INVALID_INDEX;
break;
case 9:
info->type = ParameterTypeNumber;
info->initialValue = 0;
info->min = 0;
info->max = 1;
info->exponent = 1;
info->steps = 0;
info->debug = false;
info->saveable = true;
info->transmittable = true;
info->initialized = true;
info->visible = false;
info->displayName = "";
info->unit = "";
info->ioType = IOTypeUndefined;
info->signalIndex = INVALID_INDEX;
break;
}
}
}
void sendParameter(ParameterIndex index, bool ignoreValue) {
this->getEngine()->notifyParameterValueChanged(index, (ignoreValue ? 0 : this->getParameterValue(index)), ignoreValue);
}
ParameterValue applyStepsToNormalizedParameterValue(ParameterValue normalizedValue, int steps) const {
if (steps == 1) {
if (normalizedValue > 0) {
normalizedValue = 1.;
}
} else {
ParameterValue oneStep = (number)1. / (steps - 1);
ParameterValue numberOfSteps = rnbo_fround(normalizedValue / oneStep * 1 / (number)1) * (number)1;
normalizedValue = numberOfSteps * oneStep;
}
return normalizedValue;
}
ParameterValue convertToNormalizedParameterValue(ParameterIndex index, ParameterValue value) const {
switch (index) {
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
{
value = (value < 0 ? 0 : (value > 1 ? 1 : value));
ParameterValue normalizedValue = (value - 0) / (1 - 0);
return normalizedValue;
}
default:
return value;
}
}
ParameterValue convertFromNormalizedParameterValue(ParameterIndex index, ParameterValue value) const {
value = (value < 0 ? 0 : (value > 1 ? 1 : value));
switch (index) {
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
{
value = (value < 0 ? 0 : (value > 1 ? 1 : value));
{
return 0 + value * (1 - 0);
}
}
default:
return value;
}
}
ParameterValue constrainParameterValue(ParameterIndex index, ParameterValue value) const {
switch (index) {
default:
return value;
}
}
void scheduleParamInit(ParameterIndex index, Index order) {
this->paramInitIndices->push(index);
this->paramInitOrder->push(order);
}
void processParamInitEvents() {
this->listquicksort(
this->paramInitOrder,
this->paramInitIndices,
0,
(int)(this->paramInitOrder->length - 1),
true
);
for (Index i = 0; i < this->paramInitOrder->length; i++) {
this->getEngine()->scheduleParameterChange(
this->paramInitIndices[i],
this->getParameterValue(this->paramInitIndices[i]),
0
);
}
}
void processClockEvent(MillisecondTime time, ClockId index, bool hasValue, ParameterValue value) {
RNBO_UNUSED(hasValue);
this->updateTime(time);
switch (index) {
case -1688633604:
this->peakamp_01_output_set(value);
break;
}
}
void processOutletAtCurrentTime(EngineLink* , OutletIndex , ParameterValue ) {}
void processOutletEvent(
EngineLink* sender,
OutletIndex index,
ParameterValue value,
MillisecondTime time
) {
this->updateTime(time);
this->processOutletAtCurrentTime(sender, index, value);
}
void processNumMessage(MessageTag , MessageTag , MillisecondTime , number ) {}
void processListMessage(MessageTag , MessageTag , MillisecondTime , const list& ) {}
void processBangMessage(MessageTag , MessageTag , MillisecondTime ) {}
MessageTagInfo resolveTag(MessageTag tag) const {
switch (tag) {
}
return "";
}
MessageIndex getNumMessages() const {
return 0;
}
const MessageInfo& getMessageInfo(MessageIndex index) const {
switch (index) {
}
return NullMessageInfo;
}
protected:
void toggle_01_value_set(number v) {
this->toggle_01_value = v;
this->sendParameter(0, false);
}
void toggle_02_value_set(number v) {
this->toggle_02_value = v;
this->sendParameter(1, false);
}
void toggle_03_value_set(number v) {
this->toggle_03_value = v;
this->sendParameter(2, false);
}
void toggle_04_value_set(number v) {
this->toggle_04_value = v;
this->sendParameter(3, false);
}
void toggle_05_value_set(number v) {
this->toggle_05_value = v;
this->sendParameter(4, false);
}
void toggle_06_value_set(number v) {
this->toggle_06_value = v;
this->sendParameter(5, false);
}
void toggle_07_value_set(number v) {
this->toggle_07_value = v;
this->sendParameter(6, false);
}
void toggle_08_value_set(number v) {
this->toggle_08_value = v;
this->sendParameter(7, false);
}
void toggle_09_value_set(number v) {
this->toggle_09_value = v;
this->sendParameter(8, false);
}
void toggle_10_value_set(number v) {
this->toggle_10_value = v;
this->sendParameter(9, false);
}
void peakamp_01_output_set(number v) {
this->peakamp_01_output = v;
this->expr_10_in1_set(v);
this->expr_09_in1_set(v);
this->expr_08_in1_set(v);
this->expr_07_in1_set(v);
this->expr_06_in1_set(v);
this->expr_05_in1_set(v);
this->expr_04_in1_set(v);
this->expr_03_in1_set(v);
this->expr_02_in1_set(v);
this->expr_01_in1_set(v);
}
number msToSamps(MillisecondTime ms, number sampleRate) {
return ms * sampleRate * 0.001;
}
MillisecondTime sampsToMs(SampleIndex samps) {
return samps * (this->invsr * 1000);
}
Index getMaxBlockSize() const {
return this->maxvs;
}
number getSampleRate() const {
return this->sr;
}
bool hasFixedVectorSize() const {
return false;
}
Index getNumInputChannels() const {
return 1;
}
Index getNumOutputChannels() const {
return 0;
}
void allocateDataRefs() {}
void initializeObjects() {}
void sendOutlet(OutletIndex index, ParameterValue value) {
this->getEngine()->sendOutlet(this, index, value);
}
void startup() {
this->updateTime(this->getEngine()->getCurrentTime());
this->processParamInitEvents();
}
void expr_10_out1_set(number v) {
this->expr_10_out1 = v;
this->toggle_10_value_set(this->expr_10_out1);
}
void expr_10_in1_set(number in1) {
this->expr_10_in1 = in1;
this->expr_10_out1_set(this->expr_10_in1 > this->expr_10_in2);//#map:>_obj-15:1
}
void expr_09_out1_set(number v) {
this->expr_09_out1 = v;
this->toggle_09_value_set(this->expr_09_out1);
}
void expr_09_in1_set(number in1) {
this->expr_09_in1 = in1;
this->expr_09_out1_set(this->expr_09_in1 > this->expr_09_in2);//#map:>_obj-17:1
}
void expr_08_out1_set(number v) {
this->expr_08_out1 = v;
this->toggle_08_value_set(this->expr_08_out1);
}
void expr_08_in1_set(number in1) {
this->expr_08_in1 = in1;
this->expr_08_out1_set(this->expr_08_in1 > this->expr_08_in2);//#map:>_obj-19:1
}
void expr_07_out1_set(number v) {
this->expr_07_out1 = v;
this->toggle_07_value_set(this->expr_07_out1);
}
void expr_07_in1_set(number in1) {
this->expr_07_in1 = in1;
this->expr_07_out1_set(this->expr_07_in1 > this->expr_07_in2);//#map:>_obj-21:1
}
void expr_06_out1_set(number v) {
this->expr_06_out1 = v;
this->toggle_06_value_set(this->expr_06_out1);
}
void expr_06_in1_set(number in1) {
this->expr_06_in1 = in1;
this->expr_06_out1_set(this->expr_06_in1 > this->expr_06_in2);//#map:>_obj-13:1
}
void expr_05_out1_set(number v) {
this->expr_05_out1 = v;
this->toggle_05_value_set(this->expr_05_out1);
}
void expr_05_in1_set(number in1) {
this->expr_05_in1 = in1;
this->expr_05_out1_set(this->expr_05_in1 > this->expr_05_in2);//#map:>_obj-9:1
}
void expr_04_out1_set(number v) {
this->expr_04_out1 = v;
this->toggle_04_value_set(this->expr_04_out1);
}
void expr_04_in1_set(number in1) {
this->expr_04_in1 = in1;
this->expr_04_out1_set(this->expr_04_in1 > this->expr_04_in2);//#map:>_obj-7:1
}
void expr_03_out1_set(number v) {
this->expr_03_out1 = v;
this->toggle_03_value_set(this->expr_03_out1);
}
void expr_03_in1_set(number in1) {
this->expr_03_in1 = in1;
this->expr_03_out1_set(this->expr_03_in1 > this->expr_03_in2);//#map:>_obj-5:1
}
void expr_02_out1_set(number v) {
this->expr_02_out1 = v;
this->toggle_02_value_set(this->expr_02_out1);
}
void expr_02_in1_set(number in1) {
this->expr_02_in1 = in1;
this->expr_02_out1_set(this->expr_02_in1 > this->expr_02_in2);//#map:>_obj-1:1
}
void expr_01_out1_set(number v) {
this->expr_01_out1 = v;
this->toggle_01_value_set(this->expr_01_out1);
}
void expr_01_in1_set(number in1) {
this->expr_01_in1 = in1;
this->expr_01_out1_set(this->expr_01_in1 > this->expr_01_in2);//#map:>_obj-11:1
}
void peakamp_01_perform(const Sample * input_signal, Index n) {
auto __peakamp_01_index = this->peakamp_01_index;
auto __peakamp_01_lastMaximum = this->peakamp_01_lastMaximum;
auto __peakamp_01_maxIndex = this->peakamp_01_maxIndex;
auto __peakamp_01_interval = this->peakamp_01_interval;
for (Index i = 0; i < n; i++) {
if ((bool)(this->peakamp_01_d_next(__peakamp_01_interval))) {
__peakamp_01_maxIndex = this->mstosamps(__peakamp_01_interval);
}
number temp = rnbo_abs(input_signal[(Index)i]);
if (temp > __peakamp_01_lastMaximum) {
__peakamp_01_lastMaximum = temp;
}
__peakamp_01_index++;
if (__peakamp_01_maxIndex > 0 && __peakamp_01_index >= __peakamp_01_maxIndex) {
this->getEngine()->scheduleClockEventWithValue(
this,
-1688633604,
this->sampsToMs((SampleIndex)(this->vs)) + this->_currentTime,
__peakamp_01_lastMaximum
);;
__peakamp_01_lastMaximum = 0;
}
if (__peakamp_01_maxIndex == 0 || __peakamp_01_index >= __peakamp_01_maxIndex) {
__peakamp_01_index = 0;
}
}
this->peakamp_01_maxIndex = __peakamp_01_maxIndex;
this->peakamp_01_lastMaximum = __peakamp_01_lastMaximum;
this->peakamp_01_index = __peakamp_01_index;
}
void stackprotect_perform(Index n) {
RNBO_UNUSED(n);
auto __stackprotect_count = this->stackprotect_count;
__stackprotect_count = 0;
this->stackprotect_count = __stackprotect_count;
}
number peakamp_01_d_next(number x) {
number temp = (number)(x - this->peakamp_01_d_prev);
this->peakamp_01_d_prev = x;
return temp;
}
void peakamp_01_d_dspsetup() {
this->peakamp_01_d_reset();
}
void peakamp_01_d_reset() {
this->peakamp_01_d_prev = 0;
}
void peakamp_01_dspsetup(bool force) {
if ((bool)(this->peakamp_01_setupDone) && (bool)(!(bool)(force)))
return;
this->peakamp_01_index = 0;
this->peakamp_01_lastMaximum = 0;
this->peakamp_01_lastOutput = 0;
this->peakamp_01_setupDone = true;
this->peakamp_01_d_dspsetup();
}
void toggle_01_getPresetValue(PatcherStateInterface& preset) {
preset["value"] = this->toggle_01_value;
}
void toggle_01_setPresetValue(PatcherStateInterface& preset) {
if ((bool)(stateIsEmpty(preset)))
return;
this->toggle_01_value_set(preset["value"]);
}
void toggle_02_getPresetValue(PatcherStateInterface& preset) {
preset["value"] = this->toggle_02_value;
}
void toggle_02_setPresetValue(PatcherStateInterface& preset) {
if ((bool)(stateIsEmpty(preset)))
return;
this->toggle_02_value_set(preset["value"]);
}
void toggle_03_getPresetValue(PatcherStateInterface& preset) {
preset["value"] = this->toggle_03_value;
}
void toggle_03_setPresetValue(PatcherStateInterface& preset) {
if ((bool)(stateIsEmpty(preset)))
return;
this->toggle_03_value_set(preset["value"]);
}
void toggle_04_getPresetValue(PatcherStateInterface& preset) {
preset["value"] = this->toggle_04_value;
}
void toggle_04_setPresetValue(PatcherStateInterface& preset) {
if ((bool)(stateIsEmpty(preset)))
return;
this->toggle_04_value_set(preset["value"]);
}
void toggle_05_getPresetValue(PatcherStateInterface& preset) {
preset["value"] = this->toggle_05_value;
}
void toggle_05_setPresetValue(PatcherStateInterface& preset) {
if ((bool)(stateIsEmpty(preset)))
return;
this->toggle_05_value_set(preset["value"]);
}
void toggle_06_getPresetValue(PatcherStateInterface& preset) {
preset["value"] = this->toggle_06_value;
}
void toggle_06_setPresetValue(PatcherStateInterface& preset) {
if ((bool)(stateIsEmpty(preset)))
return;
this->toggle_06_value_set(preset["value"]);
}
void toggle_07_getPresetValue(PatcherStateInterface& preset) {
preset["value"] = this->toggle_07_value;
}
void toggle_07_setPresetValue(PatcherStateInterface& preset) {
if ((bool)(stateIsEmpty(preset)))
return;
this->toggle_07_value_set(preset["value"]);
}
void toggle_08_getPresetValue(PatcherStateInterface& preset) {
preset["value"] = this->toggle_08_value;
}
void toggle_08_setPresetValue(PatcherStateInterface& preset) {
if ((bool)(stateIsEmpty(preset)))
return;
this->toggle_08_value_set(preset["value"]);
}
void toggle_09_getPresetValue(PatcherStateInterface& preset) {
preset["value"] = this->toggle_09_value;
}
void toggle_09_setPresetValue(PatcherStateInterface& preset) {
if ((bool)(stateIsEmpty(preset)))
return;
this->toggle_09_value_set(preset["value"]);
}
void toggle_10_getPresetValue(PatcherStateInterface& preset) {
preset["value"] = this->toggle_10_value;
}
void toggle_10_setPresetValue(PatcherStateInterface& preset) {
if ((bool)(stateIsEmpty(preset)))
return;
this->toggle_10_value_set(preset["value"]);
}
number globaltransport_getTempoAtSample(SampleIndex sampleOffset) {
RNBO_UNUSED(sampleOffset);
return (this->vs > 0 ? this->globaltransport_tempo[(Index)sampleOffset] : this->globaltransport_lastTempo);
}
number globaltransport_getTempo() {
return this->globaltransport_getTempoAtSample(this->sampleOffsetIntoNextAudioBuffer);
}
number globaltransport_getStateAtSample(SampleIndex sampleOffset) {
RNBO_UNUSED(sampleOffset);
return (this->vs > 0 ? this->globaltransport_state[(Index)sampleOffset] : this->globaltransport_lastState);
}
number globaltransport_getState() {
return this->globaltransport_getStateAtSample(this->sampleOffsetIntoNextAudioBuffer);
}
number globaltransport_getBeatTimeAtMsTime(MillisecondTime time) {
number i = 2;
while (i < this->globaltransport_beatTimeChanges->length && this->globaltransport_beatTimeChanges[(Index)(i + 1)] <= time) {
i += 2;
}
i -= 2;
number beatTimeBase = this->globaltransport_beatTimeChanges[(Index)i];
if (this->globaltransport_getState() == 0)
return beatTimeBase;
number beatTimeBaseMsTime = this->globaltransport_beatTimeChanges[(Index)(i + 1)];
number diff = time - beatTimeBaseMsTime;
return beatTimeBase + this->mstobeats(diff);
}
bool globaltransport_setTempo(number tempo, bool notify) {
if ((bool)(notify)) {
this->processTempoEvent(this->currenttime(), tempo);
this->globaltransport_notify = true;
} else if (this->globaltransport_getTempo() != tempo) {
MillisecondTime ct = this->currenttime();
this->globaltransport_beatTimeChanges->push(this->globaltransport_getBeatTimeAtMsTime(ct));
this->globaltransport_beatTimeChanges->push(ct);
fillSignal(
this->globaltransport_tempo,
this->vs,
tempo,
(Index)(this->sampleOffsetIntoNextAudioBuffer)
);
this->globaltransport_lastTempo = tempo;
this->globaltransport_tempoNeedsReset = true;
return true;
}
return false;
}
number globaltransport_getBeatTime() {
return this->globaltransport_getBeatTimeAtMsTime(this->currenttime());
}
bool globaltransport_setState(number state, bool notify) {
if ((bool)(notify)) {
this->processTransportEvent(this->currenttime(), TransportState(state));
this->globaltransport_notify = true;
} else if (this->globaltransport_getState() != state) {
fillSignal(
this->globaltransport_state,
this->vs,
state,
(Index)(this->sampleOffsetIntoNextAudioBuffer)
);
this->globaltransport_lastState = TransportState(state);
this->globaltransport_stateNeedsReset = true;
if (state == 0) {
this->globaltransport_beatTimeChanges->push(this->globaltransport_getBeatTime());
this->globaltransport_beatTimeChanges->push(this->currenttime());
}
return true;
}
return false;
}
bool globaltransport_setBeatTime(number beattime, bool notify) {
if ((bool)(notify)) {
this->processBeatTimeEvent(this->currenttime(), beattime);
this->globaltransport_notify = true;
return false;
} else {
bool beatTimeHasChanged = false;
float oldBeatTime = (float)(this->globaltransport_getBeatTime());
float newBeatTime = (float)(beattime);
if (oldBeatTime != newBeatTime) {
beatTimeHasChanged = true;
}
this->globaltransport_beatTimeChanges->push(beattime);
this->globaltransport_beatTimeChanges->push(this->currenttime());
return beatTimeHasChanged;
}
}
number globaltransport_getBeatTimeAtSample(SampleIndex sampleOffset) {
MillisecondTime msOffset = this->sampstoms(sampleOffset);
return this->globaltransport_getBeatTimeAtMsTime(this->currenttime() + msOffset);
}
array<number, 2> globaltransport_getTimeSignatureAtMsTime(MillisecondTime time) {
number i = 3;
while (i < this->globaltransport_timeSignatureChanges->length && this->globaltransport_timeSignatureChanges[(Index)(i + 2)] <= time) {
i += 3;
}
i -= 3;
return {
this->globaltransport_timeSignatureChanges[(Index)i],
this->globaltransport_timeSignatureChanges[(Index)(i + 1)]
};
}
array<number, 2> globaltransport_getTimeSignature() {
return this->globaltransport_getTimeSignatureAtMsTime(this->currenttime());
}
array<number, 2> globaltransport_getTimeSignatureAtSample(SampleIndex sampleOffset) {
MillisecondTime msOffset = this->sampstoms(sampleOffset);
return this->globaltransport_getTimeSignatureAtMsTime(this->currenttime() + msOffset);
}
bool globaltransport_setTimeSignature(number numerator, number denominator, bool notify) {
if ((bool)(notify)) {
this->processTimeSignatureEvent(this->currenttime(), (int)(numerator), (int)(denominator));
this->globaltransport_notify = true;
} else {
array<number, 2> currentSig = this->globaltransport_getTimeSignature();
if (currentSig[0] != numerator || currentSig[1] != denominator) {
this->globaltransport_timeSignatureChanges->push(numerator);
this->globaltransport_timeSignatureChanges->push(denominator);
this->globaltransport_timeSignatureChanges->push(this->currenttime());
return true;
}
}
return false;
}
void globaltransport_advance() {
if ((bool)(this->globaltransport_tempoNeedsReset)) {
fillSignal(this->globaltransport_tempo, this->vs, this->globaltransport_lastTempo);
this->globaltransport_tempoNeedsReset = false;
if ((bool)(this->globaltransport_notify)) {
this->getEngine()->sendTempoEvent(this->globaltransport_lastTempo);
}
}
if ((bool)(this->globaltransport_stateNeedsReset)) {
fillSignal(this->globaltransport_state, this->vs, this->globaltransport_lastState);
this->globaltransport_stateNeedsReset = false;
if ((bool)(this->globaltransport_notify)) {
this->getEngine()->sendTransportEvent(TransportState(this->globaltransport_lastState));
}
}
if (this->globaltransport_beatTimeChanges->length > 2) {
this->globaltransport_beatTimeChanges[0] = this->globaltransport_beatTimeChanges[(Index)(this->globaltransport_beatTimeChanges->length - 2)];
this->globaltransport_beatTimeChanges[1] = this->globaltransport_beatTimeChanges[(Index)(this->globaltransport_beatTimeChanges->length - 1)];
this->globaltransport_beatTimeChanges->length = 2;
if ((bool)(this->globaltransport_notify)) {
this->getEngine()->sendBeatTimeEvent(this->globaltransport_beatTimeChanges[0]);
}
}
if (this->globaltransport_timeSignatureChanges->length > 3) {
this->globaltransport_timeSignatureChanges[0] = this->globaltransport_timeSignatureChanges[(Index)(this->globaltransport_timeSignatureChanges->length - 3)];
this->globaltransport_timeSignatureChanges[1] = this->globaltransport_timeSignatureChanges[(Index)(this->globaltransport_timeSignatureChanges->length - 2)];
this->globaltransport_timeSignatureChanges[2] = this->globaltransport_timeSignatureChanges[(Index)(this->globaltransport_timeSignatureChanges->length - 1)];
this->globaltransport_timeSignatureChanges->length = 3;
if ((bool)(this->globaltransport_notify)) {
this->getEngine()->sendTimeSignatureEvent(
(int)(this->globaltransport_timeSignatureChanges[0]),
(int)(this->globaltransport_timeSignatureChanges[1])
);
}
}
this->globaltransport_notify = false;
}
void globaltransport_dspsetup(bool force) {
if ((bool)(this->globaltransport_setupDone) && (bool)(!(bool)(force)))
return;
fillSignal(this->globaltransport_tempo, this->vs, this->globaltransport_lastTempo);
this->globaltransport_tempoNeedsReset = false;
fillSignal(this->globaltransport_state, this->vs, this->globaltransport_lastState);
this->globaltransport_stateNeedsReset = false;
this->globaltransport_setupDone = true;
}
bool stackprotect_check() {
this->stackprotect_count++;
if (this->stackprotect_count > 128) {
console->log("STACK OVERFLOW DETECTED - stopped processing branch !");
return true;
}
return false;
}
void updateTime(MillisecondTime time) {
this->_currentTime = time;
this->sampleOffsetIntoNextAudioBuffer = (SampleIndex)(rnbo_fround(this->msToSamps(time - this->getEngine()->getCurrentTime(), this->sr)));
if (this->sampleOffsetIntoNextAudioBuffer >= (SampleIndex)(this->vs))
this->sampleOffsetIntoNextAudioBuffer = (SampleIndex)(this->vs) - 1;
if (this->sampleOffsetIntoNextAudioBuffer < 0)
this->sampleOffsetIntoNextAudioBuffer = 0;
}
void assign_defaults()
{
peakamp_01_interval = 10;
peakamp_01_output = 0;
toggle_01_value = 0;
expr_01_in1 = 0;
expr_01_in2 = 0;
expr_01_out1 = 0;
toggle_02_value = 0;
expr_02_in1 = 0;
expr_02_in2 = 0.1;
expr_02_out1 = 0;
toggle_03_value = 0;
expr_03_in1 = 0;
expr_03_in2 = 0.2;
expr_03_out1 = 0;
toggle_04_value = 0;
expr_04_in1 = 0;
expr_04_in2 = 0.3;
expr_04_out1 = 0;
toggle_05_value = 0;
expr_05_in1 = 0;
expr_05_in2 = 0.4;
expr_05_out1 = 0;
toggle_06_value = 0;
expr_06_in1 = 0;
expr_06_in2 = 0.5;
expr_06_out1 = 0;
toggle_07_value = 0;
expr_07_in1 = 0;
expr_07_in2 = 0.6;
expr_07_out1 = 0;
toggle_08_value = 0;
expr_08_in1 = 0;
expr_08_in2 = 0.7;
expr_08_out1 = 0;
toggle_09_value = 0;
expr_09_in1 = 0;
expr_09_in2 = 0.8;
expr_09_out1 = 0;
toggle_10_value = 0;
expr_10_in1 = 0;
expr_10_in2 = 0.9;
expr_10_out1 = 0;
_currentTime = 0;
audioProcessSampleCount = 0;
sampleOffsetIntoNextAudioBuffer = 0;
zeroBuffer = nullptr;
dummyBuffer = nullptr;
didAllocateSignals = 0;
vs = 0;
maxvs = 0;
sr = 44100;
invsr = 0.00002267573696;
peakamp_01_index = 0;
peakamp_01_maxIndex = 0;
peakamp_01_lastMaximum = 0;
peakamp_01_lastOutput = 0;
peakamp_01_d_prev = 0;
peakamp_01_setupDone = false;
globaltransport_tempo = nullptr;
globaltransport_tempoNeedsReset = false;
globaltransport_lastTempo = 120;
globaltransport_state = nullptr;
globaltransport_stateNeedsReset = false;
globaltransport_lastState = 0;
globaltransport_beatTimeChanges = { 0, 0 };
globaltransport_timeSignatureChanges = { 4, 4, 0 };
globaltransport_notify = false;
globaltransport_setupDone = false;
stackprotect_count = 0;
_voiceIndex = 0;
_noteNumber = 0;
isMuted = 1;
}
// member variables
number peakamp_01_interval;
number peakamp_01_output;
number toggle_01_value;
number expr_01_in1;
number expr_01_in2;
number expr_01_out1;
number toggle_02_value;
number expr_02_in1;
number expr_02_in2;
number expr_02_out1;
number toggle_03_value;
number expr_03_in1;
number expr_03_in2;
number expr_03_out1;
number toggle_04_value;
number expr_04_in1;
number expr_04_in2;
number expr_04_out1;
number toggle_05_value;
number expr_05_in1;
number expr_05_in2;
number expr_05_out1;
number toggle_06_value;
number expr_06_in1;
number expr_06_in2;
number expr_06_out1;
number toggle_07_value;
number expr_07_in1;
number expr_07_in2;
number expr_07_out1;
number toggle_08_value;
number expr_08_in1;
number expr_08_in2;
number expr_08_out1;
number toggle_09_value;
number expr_09_in1;
number expr_09_in2;
number expr_09_out1;
number toggle_10_value;
number expr_10_in1;
number expr_10_in2;
number expr_10_out1;
MillisecondTime _currentTime;
SampleIndex audioProcessSampleCount;
SampleIndex sampleOffsetIntoNextAudioBuffer;
signal zeroBuffer;
signal dummyBuffer;
bool didAllocateSignals;
Index vs;
Index maxvs;
number sr;
number invsr;
int peakamp_01_index;
int peakamp_01_maxIndex;
number peakamp_01_lastMaximum;
number peakamp_01_lastOutput;
number peakamp_01_d_prev;
bool peakamp_01_setupDone;
signal globaltransport_tempo;
bool globaltransport_tempoNeedsReset;
number globaltransport_lastTempo;
signal globaltransport_state;
bool globaltransport_stateNeedsReset;
number globaltransport_lastState;
list globaltransport_beatTimeChanges;
list globaltransport_timeSignatureChanges;
bool globaltransport_notify;
bool globaltransport_setupDone;
number stackprotect_count;
Index _voiceIndex;
Int _noteNumber;
Index isMuted;
indexlist paramInitIndices;
indexlist paramInitOrder;
};
PatcherInterface* creaternbomatic()
{
return new rnbomatic();
}
#ifndef RNBO_NO_PATCHERFACTORY
extern "C" PatcherFactoryFunctionPtr GetPatcherFactoryFunction(PlatformInterface* platformInterface)
#else
extern "C" PatcherFactoryFunctionPtr rnbomaticFactoryFunction(PlatformInterface* platformInterface)
#endif
{
Platform::set(platformInterface);
return creaternbomatic;
}
} // end RNBO namespace
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment