Browse Source

Update to Rack v1 API

tags/v1.0.1
Andrew Belt 4 years ago
parent
commit
fba42201f4
7 changed files with 17 additions and 17 deletions
  1. +3
    -3
      src/ADSR.cpp
  2. +3
    -3
      src/Delay.cpp
  3. +2
    -2
      src/LFO.cpp
  4. +1
    -1
      src/SEQ3.cpp
  5. +3
    -3
      src/Scope.cpp
  6. +2
    -2
      src/VCF.cpp
  7. +3
    -3
      src/VCO.cpp

+ 3
- 3
src/ADSR.cpp View File

@@ -62,7 +62,7 @@ struct ADSR : Module {
env = sustain;
}
else {
env += std::pow(base, 1 - decay) / maxTime * (sustain - env) * app()->engine->getSampleTime();
env += std::pow(base, 1 - decay) / maxTime * (sustain - env) * APP->engine->getSampleTime();
}
}
else {
@@ -72,7 +72,7 @@ struct ADSR : Module {
env = 1.f;
}
else {
env += std::pow(base, 1 - attack) / maxTime * (1.01f - env) * app()->engine->getSampleTime();
env += std::pow(base, 1 - attack) / maxTime * (1.01f - env) * APP->engine->getSampleTime();
}
if (env >= 1.f) {
env = 1.f;
@@ -86,7 +86,7 @@ struct ADSR : Module {
env = 0.f;
}
else {
env += std::pow(base, 1 - release) / maxTime * (0.f - env) * app()->engine->getSampleTime();
env += std::pow(base, 1 - release) / maxTime * (0.f - env) * APP->engine->getSampleTime();
}
decaying = false;
}


+ 3
- 3
src/Delay.cpp View File

@@ -56,7 +56,7 @@ struct Delay : Module {
// Compute delay time in seconds
float delay = 1e-3 * std::pow(10.0f / 1e-3, clamp(params[TIME_PARAM].value + inputs[TIME_INPUT].value / 10.0f, 0.0f, 1.0f));
// Number of delay samples
float index = delay * app()->engine->getSampleRate();
float index = delay * APP->engine->getSampleRate();

// Push dry sample into history buffer
if (!historyBuffer.full()) {
@@ -93,11 +93,11 @@ struct Delay : Module {
// TODO Make it sound better
float color = clamp(params[COLOR_PARAM].value + inputs[COLOR_INPUT].value / 10.0f, 0.0f, 1.0f);
float lowpassFreq = 10000.0f * std::pow(10.0f, clamp(2.0f*color, 0.0f, 1.0f));
lowpassFilter.setCutoff(lowpassFreq / app()->engine->getSampleRate());
lowpassFilter.setCutoff(lowpassFreq / APP->engine->getSampleRate());
lowpassFilter.process(wet);
wet = lowpassFilter.lowpass();
float highpassFreq = 10.0f * std::pow(100.0f, clamp(2.0f*color - 1.0f, 0.0f, 1.0f));
highpassFilter.setCutoff(highpassFreq / app()->engine->getSampleRate());
highpassFilter.setCutoff(highpassFreq / APP->engine->getSampleRate());
highpassFilter.process(wet);
wet = highpassFilter.highpass();



+ 2
- 2
src/LFO.cpp View File

@@ -112,7 +112,7 @@ struct LFO : Module {
oscillator.setPulseWidth(params[PW_PARAM].value + params[PWM_PARAM].value * inputs[PW_INPUT].value / 10.f);
oscillator.offset = (params[OFFSET_PARAM].value > 0.f);
oscillator.invert = (params[INVERT_PARAM].value <= 0.f);
oscillator.step(app()->engine->getSampleTime());
oscillator.step(APP->engine->getSampleTime());
oscillator.setReset(inputs[RESET_INPUT].value);

outputs[SIN_OUTPUT].value = 5.f * oscillator.sin();
@@ -205,7 +205,7 @@ struct LFO2 : Module {
oscillator.setPitch(params[FREQ_PARAM].value + params[FM_PARAM].value * inputs[FM_INPUT].value);
oscillator.offset = (params[OFFSET_PARAM].value > 0.f);
oscillator.invert = (params[INVERT_PARAM].value <= 0.f);
oscillator.step(app()->engine->getSampleTime());
oscillator.step(APP->engine->getSampleTime());
oscillator.setReset(inputs[RESET_INPUT].value);

float wave = params[WAVE_PARAM].value + inputs[WAVE_INPUT].value;


+ 1
- 1
src/SEQ3.cpp View File

@@ -135,7 +135,7 @@ struct SEQ3 : Module {
else {
// Internal clock
float clockTime = std::pow(2.0f, params[CLOCK_PARAM].value + inputs[CLOCK_INPUT].value);
phase += clockTime * app()->engine->getSampleTime();
phase += clockTime * APP->engine->getSampleTime();
if (phase >= 1.0f) {
setIndex(index + 1);
}


+ 3
- 3
src/Scope.cpp View File

@@ -73,7 +73,7 @@ struct Scope : Module {

// Compute time
float deltaTime = std::pow(2.0f, -params[TIME_PARAM].value);
int frameCount = (int) std::ceil(deltaTime * app()->engine->getSampleRate());
int frameCount = (int) std::ceil(deltaTime * APP->engine->getSampleRate());

// Add frame to buffer
if (bufferIndex < BUFFER_SIZE) {
@@ -105,12 +105,12 @@ struct Scope : Module {

// Reset if triggered
float holdTime = 0.1f;
if (resetTrigger.process(rescale(gate, params[TRIG_PARAM].value - 0.1f, params[TRIG_PARAM].value, 0.f, 1.f)) || (frameIndex >= app()->engine->getSampleRate() * holdTime)) {
if (resetTrigger.process(rescale(gate, params[TRIG_PARAM].value - 0.1f, params[TRIG_PARAM].value, 0.f, 1.f)) || (frameIndex >= APP->engine->getSampleRate() * holdTime)) {
bufferIndex = 0; frameIndex = 0; return;
}

// Reset if we've waited too long
if (frameIndex >= app()->engine->getSampleRate() * holdTime) {
if (frameIndex >= APP->engine->getSampleRate() * holdTime) {
bufferIndex = 0; frameIndex = 0; return;
}
}


+ 2
- 2
src/VCF.cpp View File

@@ -122,7 +122,7 @@ struct VCF : Module {

/*
// Process sample
float dt = app()->engine->getSampleTime() / UPSAMPLE;
float dt = APP->engine->getSampleTime() / UPSAMPLE;
float inputBuf[UPSAMPLE];
float lowpassBuf[UPSAMPLE];
float highpassBuf[UPSAMPLE];
@@ -142,7 +142,7 @@ struct VCF : Module {
outputs[HPF_OUTPUT].value = 5.f * highpassDecimator.process(highpassBuf);
}
*/
filter.process(input, app()->engine->getSampleTime());
filter.process(input, APP->engine->getSampleTime());
outputs[LPF_OUTPUT].value = 5.f * filter.lowpass;
outputs[HPF_OUTPUT].value = 5.f * filter.highpass;
}


+ 3
- 3
src/VCO.cpp View File

@@ -58,7 +58,7 @@ struct VoltageControlledOscillator {
// Adjust pitch slew
if (++pitchSlewIndex > 32) {
const float pitchSlewTau = 100.f; // Time constant for leaky integrator in seconds
pitchSlew += (random::normal() - pitchSlew / pitchSlewTau) * app()->engine->getSampleTime();
pitchSlew += (random::normal() - pitchSlew / pitchSlewTau) * APP->engine->getSampleTime();
pitchSlewIndex = 0;
}
}
@@ -217,7 +217,7 @@ struct VCO : Module {
oscillator.setPulseWidth(params[PW_PARAM].value + params[PWM_PARAM].value * inputs[PW_INPUT].value / 10.f);
oscillator.syncEnabled = inputs[SYNC_INPUT].active;

oscillator.process(app()->engine->getSampleTime(), inputs[SYNC_INPUT].value);
oscillator.process(APP->engine->getSampleTime(), inputs[SYNC_INPUT].value);

// Set output
if (outputs[SIN_OUTPUT].active)
@@ -316,7 +316,7 @@ struct VCO2 : Module {
oscillator.setPitch(0.f, pitchCv);
oscillator.syncEnabled = inputs[SYNC_INPUT].active;

oscillator.process(app()->engine->getSampleTime(), inputs[SYNC_INPUT].value);
oscillator.process(APP->engine->getSampleTime(), inputs[SYNC_INPUT].value);

// Set output
float wave = clamp(params[WAVE_PARAM].value + inputs[WAVE_INPUT].value, 0.f, 3.f);


Loading…
Cancel
Save