| @@ -32,7 +32,7 @@ struct ADSR : Module { | |||
| ADSR() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS) { | |||
| trigger.setThresholds(0.0, 1.0); | |||
| } | |||
| void step(); | |||
| void step() override; | |||
| }; | |||
| @@ -62,7 +62,7 @@ void ADSR::step() { | |||
| env = sustain; | |||
| } | |||
| else { | |||
| env += powf(base, 1 - decay) / maxTime * (sustain - env) / gSampleRate; | |||
| env += powf(base, 1 - decay) / maxTime * (sustain - env) / engineGetSampleRate(); | |||
| } | |||
| } | |||
| else { | |||
| @@ -72,7 +72,7 @@ void ADSR::step() { | |||
| env = 1.0; | |||
| } | |||
| else { | |||
| env += powf(base, 1 - attack) / maxTime * (1.01 - env) / gSampleRate; | |||
| env += powf(base, 1 - attack) / maxTime * (1.01 - env) / engineGetSampleRate(); | |||
| } | |||
| if (env >= 1.0) { | |||
| env = 1.0; | |||
| @@ -86,7 +86,7 @@ void ADSR::step() { | |||
| env = 0.0; | |||
| } | |||
| else { | |||
| env += powf(base, 1 - release) / maxTime * (0.0 - env) / gSampleRate; | |||
| env += powf(base, 1 - release) / maxTime * (0.0 - env) / engineGetSampleRate(); | |||
| } | |||
| decaying = false; | |||
| } | |||
| @@ -36,7 +36,7 @@ struct Delay : Module { | |||
| Delay() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS) {} | |||
| void step(); | |||
| void step() override; | |||
| }; | |||
| @@ -49,7 +49,7 @@ void Delay::step() { | |||
| // Compute delay time in seconds | |||
| float delay = 1e-3 * powf(10.0 / 1e-3, clampf(params[TIME_PARAM].value + inputs[TIME_INPUT].value / 10.0, 0.0, 1.0)); | |||
| // Number of delay samples | |||
| float index = delay * gSampleRate; | |||
| float index = delay * engineGetSampleRate(); | |||
| // TODO This is a horrible digital delay algorithm. Rewrite later. | |||
| @@ -92,11 +92,11 @@ void Delay::step() { | |||
| // TODO Make it sound better | |||
| float color = clampf(params[COLOR_PARAM].value + inputs[COLOR_INPUT].value / 10.0, 0.0, 1.0); | |||
| float lowpassFreq = 10000.0 * powf(10.0, clampf(2.0*color, 0.0, 1.0)); | |||
| lowpassFilter.setCutoff(lowpassFreq / gSampleRate); | |||
| lowpassFilter.setCutoff(lowpassFreq / engineGetSampleRate()); | |||
| lowpassFilter.process(wet); | |||
| wet = lowpassFilter.lowpass(); | |||
| float highpassFreq = 10.0 * powf(100.0, clampf(2.0*color - 1.0, 0.0, 1.0)); | |||
| highpassFilter.setCutoff(highpassFreq / gSampleRate); | |||
| highpassFilter.setCutoff(highpassFreq / engineGetSampleRate()); | |||
| highpassFilter.process(wet); | |||
| wet = highpassFilter.highpass(); | |||
| @@ -52,5 +52,5 @@ struct ScopeWidget : ModuleWidget { | |||
| struct SEQ3Widget : ModuleWidget { | |||
| SEQ3Widget(); | |||
| Menu *createContextMenu(); | |||
| Menu *createContextMenu() override; | |||
| }; | |||
| @@ -95,7 +95,7 @@ struct LFO : Module { | |||
| float lights[1] = {}; | |||
| LFO() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS) {} | |||
| void step(); | |||
| void step() override; | |||
| }; | |||
| @@ -104,7 +104,7 @@ void LFO::step() { | |||
| generator.setPulseWidth(params[PW_PARAM].value + params[PWM_PARAM].value * inputs[PW_INPUT].value / 10.0); | |||
| generator.offset = (params[OFFSET_PARAM].value > 0.0); | |||
| generator.invert = (params[INVERT_PARAM].value <= 0.0); | |||
| generator.step(1.0 / gSampleRate); | |||
| generator.step(1.0 / engineGetSampleRate()); | |||
| generator.setReset(inputs[RESET_INPUT].value); | |||
| outputs[SIN_OUTPUT].value = 5.0 * generator.sin(); | |||
| @@ -189,7 +189,7 @@ void LFO2::step() { | |||
| generator.setPitch(params[FREQ_PARAM].value + params[FM_PARAM].value * inputs[FM_INPUT].value); | |||
| generator.offset = (params[OFFSET_PARAM].value > 0.0); | |||
| generator.invert = (params[INVERT_PARAM].value <= 0.0); | |||
| generator.step(1.0 / gSampleRate); | |||
| generator.step(1.0 / engineGetSampleRate()); | |||
| generator.setReset(inputs[RESET_INPUT].value); | |||
| float wave = params[WAVE_PARAM].value + inputs[WAVE_INPUT].value; | |||
| @@ -57,9 +57,9 @@ struct SEQ3 : Module { | |||
| float gateLights[8] = {}; | |||
| SEQ3() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS) {} | |||
| void step(); | |||
| void step() override; | |||
| json_t *toJson() { | |||
| json_t *toJson() override { | |||
| json_t *rootJ = json_object(); | |||
| // running | |||
| @@ -80,7 +80,7 @@ struct SEQ3 : Module { | |||
| return rootJ; | |||
| } | |||
| void fromJson(json_t *rootJ) { | |||
| void fromJson(json_t *rootJ) override { | |||
| // running | |||
| json_t *runningJ = json_object_get(rootJ, "running"); | |||
| if (runningJ) | |||
| @@ -102,13 +102,13 @@ struct SEQ3 : Module { | |||
| gateMode = (GateMode)json_integer_value(gateModeJ); | |||
| } | |||
| void initialize() { | |||
| void initialize() override { | |||
| for (int i = 0; i < 8; i++) { | |||
| gateState[i] = false; | |||
| } | |||
| } | |||
| void randomize() { | |||
| void randomize() override { | |||
| for (int i = 0; i < 8; i++) { | |||
| gateState[i] = (randomf() > 0.5); | |||
| } | |||
| @@ -137,7 +137,7 @@ void SEQ3::step() { | |||
| else { | |||
| // Internal clock | |||
| float clockTime = powf(2.0, params[CLOCK_PARAM].value + inputs[CLOCK_INPUT].value); | |||
| phase += clockTime / gSampleRate; | |||
| phase += clockTime / engineGetSampleRate(); | |||
| if (phase >= 1.0) { | |||
| phase -= 1.0; | |||
| nextStep = true; | |||
| @@ -164,9 +164,9 @@ void SEQ3::step() { | |||
| gatePulse.trigger(1e-3); | |||
| } | |||
| resetLight -= resetLight / lightLambda / gSampleRate; | |||
| resetLight -= resetLight / lightLambda / engineGetSampleRate(); | |||
| bool pulse = gatePulse.process(1.0 / gSampleRate); | |||
| bool pulse = gatePulse.process(1.0 / engineGetSampleRate()); | |||
| // Gate buttons | |||
| for (int i = 0; i < 8; i++) { | |||
| @@ -180,7 +180,7 @@ void SEQ3::step() { | |||
| gateOn = gateOn && !pulse; | |||
| outputs[GATE_OUTPUT + i].value = gateOn ? 10.0 : 0.0; | |||
| stepLights[i] -= stepLights[i] / lightLambda / gSampleRate; | |||
| stepLights[i] -= stepLights[i] / lightLambda / engineGetSampleRate(); | |||
| gateLights[i] = gateState[i] ? 1.0 - stepLights[i] : stepLights[i]; | |||
| } | |||
| @@ -257,10 +257,10 @@ SEQ3Widget::SEQ3Widget() { | |||
| struct SEQ3GateModeItem : MenuItem { | |||
| SEQ3 *seq3; | |||
| SEQ3::GateMode gateMode; | |||
| void onAction() { | |||
| void onAction() override { | |||
| seq3->gateMode = gateMode; | |||
| } | |||
| void step() { | |||
| void step() override { | |||
| rightText = (seq3->gateMode == gateMode) ? "âś”" : ""; | |||
| } | |||
| }; | |||
| @@ -40,16 +40,16 @@ struct Scope : Module { | |||
| SchmittTrigger resetTrigger; | |||
| Scope() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS) {} | |||
| void step(); | |||
| void step() override; | |||
| json_t *toJson() { | |||
| json_t *toJson() override { | |||
| json_t *rootJ = json_object(); | |||
| json_object_set_new(rootJ, "lissajous", json_integer((int) lissajous)); | |||
| json_object_set_new(rootJ, "external", json_integer((int) external)); | |||
| return rootJ; | |||
| } | |||
| void fromJson(json_t *rootJ) { | |||
| void fromJson(json_t *rootJ) override { | |||
| json_t *sumJ = json_object_get(rootJ, "lissajous"); | |||
| if (sumJ) | |||
| lissajous = json_integer_value(sumJ); | |||
| @@ -59,7 +59,7 @@ struct Scope : Module { | |||
| external = json_integer_value(extJ); | |||
| } | |||
| void initialize() { | |||
| void initialize() override { | |||
| lissajous = false; | |||
| external = false; | |||
| } | |||
| @@ -82,7 +82,7 @@ void Scope::step() { | |||
| // Compute time | |||
| float deltaTime = powf(2.0, params[TIME_PARAM].value); | |||
| int frameCount = (int)ceilf(deltaTime * gSampleRate); | |||
| int frameCount = (int)ceilf(deltaTime * engineGetSampleRate()); | |||
| // Add frame to buffer | |||
| if (bufferIndex < BUFFER_SIZE) { | |||
| @@ -115,12 +115,12 @@ void Scope::step() { | |||
| // Reset if triggered | |||
| float holdTime = 0.1; | |||
| if (resetTrigger.process(gate) || (frameIndex >= gSampleRate * holdTime)) { | |||
| if (resetTrigger.process(gate) || (frameIndex >= engineGetSampleRate() * holdTime)) { | |||
| bufferIndex = 0; frameIndex = 0; return; | |||
| } | |||
| // Reset if we've waited too long | |||
| if (frameIndex >= gSampleRate * holdTime) { | |||
| if (frameIndex >= engineGetSampleRate() * holdTime) { | |||
| bufferIndex = 0; frameIndex = 0; return; | |||
| } | |||
| } | |||
| @@ -240,7 +240,7 @@ struct ScopeDisplay : TransparentWidget { | |||
| nvgText(vg, pos.x + 22, pos.y + 11, text, NULL); | |||
| } | |||
| void draw(NVGcontext *vg) { | |||
| void draw(NVGcontext *vg) override { | |||
| float gainX = powf(2.0, roundf(module->params[Scope::X_SCALE_PARAM].value)); | |||
| float gainY = powf(2.0, roundf(module->params[Scope::Y_SCALE_PARAM].value)); | |||
| float offsetX = module->params[Scope::X_POS_PARAM].value; | |||
| @@ -23,7 +23,7 @@ struct VCA : Module { | |||
| }; | |||
| VCA() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS) {} | |||
| void step(); | |||
| void step() override; | |||
| }; | |||
| @@ -128,7 +128,7 @@ void VCF::step() { | |||
| filter.cutoff = minCutoff * powf(maxCutoff / minCutoff, cutoffExp); | |||
| // Push a sample to the state filter | |||
| filter.process(input, 1.0/gSampleRate); | |||
| filter.process(input, 1.0/engineGetSampleRate()); | |||
| // Set outputs | |||
| outputs[LPF_OUTPUT].value = 5.0 * filter.state[3]; | |||
| @@ -28,7 +28,7 @@ struct VCMixer : Module { | |||
| }; | |||
| VCMixer() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS) {} | |||
| void step(); | |||
| void step() override; | |||
| }; | |||
| @@ -60,7 +60,7 @@ struct VoltageControlledOscillator { | |||
| // Adjust pitch slew | |||
| if (++pitchSlewIndex > 32) { | |||
| const float pitchSlewTau = 100.0; // Time constant for leaky integrator in seconds | |||
| pitchSlew += (randomNormal() - pitchSlew / pitchSlewTau) / gSampleRate; | |||
| pitchSlew += (randomNormal() - pitchSlew / pitchSlewTau) / engineGetSampleRate(); | |||
| pitchSlewIndex = 0; | |||
| } | |||
| } | |||
| @@ -192,7 +192,7 @@ struct VCO : Module { | |||
| VoltageControlledOscillator<16, 16> oscillator; | |||
| VCO() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS) {} | |||
| void step(); | |||
| void step() override; | |||
| }; | |||
| @@ -209,7 +209,7 @@ void VCO::step() { | |||
| oscillator.setPulseWidth(params[PW_PARAM].value + params[PWM_PARAM].value * inputs[PW_INPUT].value / 10.0); | |||
| oscillator.syncEnabled = inputs[SYNC_INPUT].active; | |||
| oscillator.process(1.0 / gSampleRate, inputs[SYNC_INPUT].value); | |||
| oscillator.process(1.0 / engineGetSampleRate(), inputs[SYNC_INPUT].value); | |||
| // Set output | |||
| if (outputs[SIN_OUTPUT].active) | |||
| @@ -289,7 +289,7 @@ struct VCO2 : Module { | |||
| VoltageControlledOscillator<8, 8> oscillator; | |||
| VCO2() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS) {} | |||
| void step(); | |||
| void step() override; | |||
| }; | |||
| @@ -301,7 +301,7 @@ void VCO2::step() { | |||
| oscillator.setPitch(0.0, pitchCv); | |||
| oscillator.syncEnabled = inputs[SYNC_INPUT].active; | |||
| oscillator.process(1.0 / gSampleRate, inputs[SYNC_INPUT].value); | |||
| oscillator.process(1.0 / engineGetSampleRate(), inputs[SYNC_INPUT].value); | |||
| // Set output | |||
| float wave = clampf(params[WAVE_PARAM].value + inputs[WAVE_INPUT].value, 0.0, 3.0); | |||