Browse Source

Change gSampleRate to engineGetSampleRate(), add override everywhere

tags/v0.5.0
Andrew Belt 7 years ago
parent
commit
b9da4c9d10
15 changed files with 61 additions and 62 deletions
  1. +3
    -3
      src/AudibleInstruments.hpp
  2. +1
    -1
      src/Blinds.cpp
  3. +7
    -7
      src/Braids.cpp
  4. +1
    -2
      src/Branches.cpp
  5. +3
    -3
      src/Clouds.cpp
  6. +7
    -7
      src/Elements.cpp
  7. +14
    -14
      src/Frames.cpp
  8. +1
    -1
      src/Kinks.cpp
  9. +1
    -1
      src/Links.cpp
  10. +7
    -7
      src/Rings.cpp
  11. +1
    -1
      src/Shades.cpp
  12. +1
    -1
      src/Streams.cpp
  13. +6
    -6
      src/Tides.cpp
  14. +1
    -1
      src/Veils.cpp
  15. +7
    -7
      src/Warps.cpp

+ 3
- 3
src/AudibleInstruments.hpp View File

@@ -12,12 +12,12 @@ extern Plugin *plugin;


struct BraidsWidget : ModuleWidget { struct BraidsWidget : ModuleWidget {
BraidsWidget(); BraidsWidget();
Menu *createContextMenu();
Menu *createContextMenu() override;
}; };


struct ElementsWidget : ModuleWidget { struct ElementsWidget : ModuleWidget {
ElementsWidget(); ElementsWidget();
Menu *createContextMenu();
Menu *createContextMenu() override;
}; };


struct TidesWidget : ModuleWidget { struct TidesWidget : ModuleWidget {
@@ -70,5 +70,5 @@ struct VeilsWidget : ModuleWidget {


struct FramesWidget : ModuleWidget { struct FramesWidget : ModuleWidget {
FramesWidget(); FramesWidget();
Menu *createContextMenu();
Menu *createContextMenu() override;
}; };

+ 1
- 1
src/Blinds.cpp View File

@@ -37,7 +37,7 @@ struct Blinds : Module {
float gainLights[4] = {}; float gainLights[4] = {};


Blinds() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS) {} Blinds() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS) {}
void step();
void step() override;
}; };






+ 7
- 7
src/Braids.cpp View File

@@ -41,10 +41,10 @@ struct Braids : Module {
bool lastTrig = false; bool lastTrig = false;


Braids(); Braids();
void step();
void step() override;
void setShape(int shape); void setShape(int shape);


json_t *toJson() {
json_t *toJson() override {
json_t *rootJ = json_object(); json_t *rootJ = json_object();
json_t *settingsJ = json_array(); json_t *settingsJ = json_array();
uint8_t *settingsArray = &settings.shape; uint8_t *settingsArray = &settings.shape;
@@ -56,7 +56,7 @@ struct Braids : Module {
return rootJ; return rootJ;
} }


void fromJson(json_t *rootJ) {
void fromJson(json_t *rootJ) override {
json_t *settingsJ = json_object_get(rootJ, "settings"); json_t *settingsJ = json_object_get(rootJ, "settings");
if (settingsJ) { if (settingsJ) {
uint8_t *settingsArray = &settings.shape; uint8_t *settingsArray = &settings.shape;
@@ -143,7 +143,7 @@ void Braids::step() {
for (int i = 0; i < 24; i++) { for (int i = 0; i < 24; i++) {
in[i].samples[0] = render_buffer[i] / 32768.0; in[i].samples[0] = render_buffer[i] / 32768.0;
} }
src.setRatio(gSampleRate / 96000.0);
src.setRatio(engineGetSampleRate() / 96000.0);


int inLen = 24; int inLen = 24;
int outLen = outputBuffer.capacity(); int outLen = outputBuffer.capacity();
@@ -218,7 +218,7 @@ struct BraidsDisplay : TransparentWidget {
font = Font::load(assetPlugin(plugin, "res/hdad-segment14-1.002/Segment14.ttf")); font = Font::load(assetPlugin(plugin, "res/hdad-segment14-1.002/Segment14.ttf"));
} }


void draw(NVGcontext *vg) {
void draw(NVGcontext *vg) override {
int shape = module->settings.shape; int shape = module->settings.shape;


// Background // Background
@@ -293,11 +293,11 @@ struct BraidsSettingItem : MenuItem {
uint8_t *setting = NULL; uint8_t *setting = NULL;
uint8_t offValue = 0; uint8_t offValue = 0;
uint8_t onValue = 1; uint8_t onValue = 1;
void onAction() {
void onAction() override {
// Toggle setting // Toggle setting
*setting = (*setting == onValue) ? offValue : onValue; *setting = (*setting == onValue) ? offValue : onValue;
} }
void step() {
void step() override {
rightText = (*setting == onValue) ? "âś”" : ""; rightText = (*setting == onValue) ? "âś”" : "";
} }
}; };


+ 1
- 2
src/Branches.cpp View File

@@ -29,8 +29,7 @@ struct Branches : Module {
float light[2] = {}; float light[2] = {};


Branches() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS) {} Branches() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS) {}
void step();
float getOutput(int outputId);
void step() override;
}; };






+ 3
- 3
src/Clouds.cpp View File

@@ -48,7 +48,7 @@ struct Clouds : Module {


Clouds(); Clouds();
~Clouds(); ~Clouds();
void step();
void step() override;
}; };




@@ -88,7 +88,7 @@ void Clouds::step() {
clouds::ShortFrame input[32] = {}; clouds::ShortFrame input[32] = {};
// Convert input buffer // Convert input buffer
{ {
inputSrc.setRatio(32000.0 / gSampleRate);
inputSrc.setRatio(32000.0 / engineGetSampleRate());
Frame<2> inputFrames[32]; Frame<2> inputFrames[32];
int inLen = inputBuffer.size(); int inLen = inputBuffer.size();
int outLen = 32; int outLen = 32;
@@ -135,7 +135,7 @@ void Clouds::step() {
outputFrames[i].samples[1] = output[i].r / 32768.0; outputFrames[i].samples[1] = output[i].r / 32768.0;
} }


outputSrc.setRatio(gSampleRate / 32000.0);
outputSrc.setRatio(engineGetSampleRate() / 32000.0);
int inLen = 32; int inLen = 32;
int outLen = outputBuffer.capacity(); int outLen = outputBuffer.capacity();
outputSrc.process(outputFrames, &inLen, outputBuffer.endData(), &outLen); outputSrc.process(outputFrames, &inLen, outputBuffer.endData(), &outLen);


+ 7
- 7
src/Elements.cpp View File

@@ -78,15 +78,15 @@ struct Elements : Module {


Elements(); Elements();
~Elements(); ~Elements();
void step();
void step() override;


json_t *toJson() {
json_t *toJson() override {
json_t *rootJ = json_object(); json_t *rootJ = json_object();
json_object_set_new(rootJ, "model", json_integer(getModel())); json_object_set_new(rootJ, "model", json_integer(getModel()));
return rootJ; return rootJ;
} }


void fromJson(json_t *rootJ) {
void fromJson(json_t *rootJ) override {
json_t *modelJ = json_object_get(rootJ, "model"); json_t *modelJ = json_object_get(rootJ, "model");
if (modelJ) { if (modelJ) {
setModel(json_integer_value(modelJ)); setModel(json_integer_value(modelJ));
@@ -135,7 +135,7 @@ void Elements::step() {


// Convert input buffer // Convert input buffer
{ {
inputSrc.setRatio(32000.0 / gSampleRate);
inputSrc.setRatio(32000.0 / engineGetSampleRate());
Frame<2> inputFrames[16]; Frame<2> inputFrames[16];
int inLen = inputBuffer.size(); int inLen = inputBuffer.size();
int outLen = 16; int outLen = 16;
@@ -186,7 +186,7 @@ void Elements::step() {
outputFrames[i].samples[1] = aux[i]; outputFrames[i].samples[1] = aux[i];
} }


outputSrc.setRatio(gSampleRate / 32000.0);
outputSrc.setRatio(engineGetSampleRate() / 32000.0);
int inLen = 16; int inLen = 16;
int outLen = outputBuffer.capacity(); int outLen = outputBuffer.capacity();
outputSrc.process(outputFrames, &inLen, outputBuffer.endData(), &outLen); outputSrc.process(outputFrames, &inLen, outputBuffer.endData(), &outLen);
@@ -287,10 +287,10 @@ ElementsWidget::ElementsWidget() {
struct ElementsModalItem : MenuItem { struct ElementsModalItem : MenuItem {
Elements *elements; Elements *elements;
int model; int model;
void onAction() {
void onAction() override {
elements->setModel(model); elements->setModel(model);
} }
void step() {
void step() override {
rightText = (elements->getModel() == model) ? "âś”" : ""; rightText = (elements->getModel() == model) ? "âś”" : "";
} }
}; };


+ 14
- 14
src/Frames.cpp View File

@@ -50,9 +50,9 @@ struct Frames : Module {
bool clearKeyframes = false; bool clearKeyframes = false;


Frames(); Frames();
void step();
void step() override;


json_t *toJson() {
json_t *toJson() override {
json_t *rootJ = json_object(); json_t *rootJ = json_object();
json_object_set_new(rootJ, "polyLfo", json_boolean(poly_lfo_mode)); json_object_set_new(rootJ, "polyLfo", json_boolean(poly_lfo_mode));


@@ -73,7 +73,7 @@ struct Frames : Module {
return rootJ; return rootJ;
} }


void fromJson(json_t *rootJ) {
void fromJson(json_t *rootJ) override {
json_t *polyLfoJ = json_object_get(rootJ, "polyLfo"); json_t *polyLfoJ = json_object_get(rootJ, "polyLfo");
if (polyLfoJ) if (polyLfoJ)
poly_lfo_mode = json_boolean_value(polyLfoJ); poly_lfo_mode = json_boolean_value(polyLfoJ);
@@ -95,11 +95,11 @@ struct Frames : Module {
// TODO Channel settings // TODO Channel settings
} }


void initialize() {
void initialize() override {
poly_lfo_mode = false; poly_lfo_mode = false;
keyframer.Clear(); keyframer.Clear();
} }
void randomize() {
void randomize() override {
// TODO // TODO
// Maybe something useful should go in here?? // Maybe something useful should go in here??
} }
@@ -249,7 +249,7 @@ struct FramesLight : Light {
FramesLight() { FramesLight() {
box.size = Vec(67, 67); box.size = Vec(67, 67);
} }
void step() {
void step() override {
const NVGcolor red = COLOR_RED; const NVGcolor red = COLOR_RED;
const NVGcolor green = COLOR_GREEN; const NVGcolor green = COLOR_GREEN;
const NVGcolor blue = COLOR_BLUE; const NVGcolor blue = COLOR_BLUE;
@@ -336,10 +336,10 @@ struct FramesCurveItem : MenuItem {
Frames *frames; Frames *frames;
uint8_t channel; uint8_t channel;
frames::EasingCurve curve; frames::EasingCurve curve;
void onAction() {
void onAction() override {
frames->keyframer.mutable_settings(channel)->easing_curve = curve; frames->keyframer.mutable_settings(channel)->easing_curve = curve;
} }
void step() {
void step() override {
rightText = (frames->keyframer.mutable_settings(channel)->easing_curve == curve) ? "âś”" : ""; rightText = (frames->keyframer.mutable_settings(channel)->easing_curve == curve) ? "âś”" : "";
} }
}; };
@@ -348,10 +348,10 @@ struct FramesResponseItem : MenuItem {
Frames *frames; Frames *frames;
uint8_t channel; uint8_t channel;
uint8_t response; uint8_t response;
void onAction() {
void onAction() override {
frames->keyframer.mutable_settings(channel)->response = response; frames->keyframer.mutable_settings(channel)->response = response;
} }
void step() {
void step() override {
rightText = (frames->keyframer.mutable_settings(channel)->response = response) ? "âś”" : ""; rightText = (frames->keyframer.mutable_settings(channel)->response = response) ? "âś”" : "";
} }
}; };
@@ -359,7 +359,7 @@ struct FramesResponseItem : MenuItem {
struct FramesChannelSettingsItem : MenuItem { struct FramesChannelSettingsItem : MenuItem {
Frames *frames; Frames *frames;
uint8_t channel; uint8_t channel;
Menu *createChildMenu() {
Menu *createChildMenu() override {
Menu *menu = new Menu(); Menu *menu = new Menu();


// TODO // TODO
@@ -381,7 +381,7 @@ struct FramesChannelSettingsItem : MenuItem {


struct FramesClearItem : MenuItem { struct FramesClearItem : MenuItem {
Frames *frames; Frames *frames;
void onAction() {
void onAction() override {
frames->keyframer.Clear(); frames->keyframer.Clear();
} }
}; };
@@ -389,10 +389,10 @@ struct FramesClearItem : MenuItem {
struct FramesModeItem : MenuItem { struct FramesModeItem : MenuItem {
Frames *frames; Frames *frames;
bool poly_lfo_mode; bool poly_lfo_mode;
void onAction() {
void onAction() override {
frames->poly_lfo_mode = poly_lfo_mode; frames->poly_lfo_mode = poly_lfo_mode;
} }
void step() {
void step() override {
rightText = (frames->poly_lfo_mode == poly_lfo_mode) ? "âś”" : ""; rightText = (frames->poly_lfo_mode == poly_lfo_mode) ? "âś”" : "";
} }
}; };


+ 1
- 1
src/Kinks.cpp View File

@@ -32,7 +32,7 @@ struct Kinks : Module {
Kinks() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS) { Kinks() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS) {
trigger.setThresholds(0.0, 0.7); trigger.setThresholds(0.0, 0.7);
} }
void step();
void step() override;
}; };






+ 1
- 1
src/Links.cpp View File

@@ -26,7 +26,7 @@ struct Links : Module {


float lights[3] = {}; float lights[3] = {};
Links() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS) {} Links() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS) {}
void step();
void step() override;
}; };






+ 7
- 7
src/Rings.cpp View File

@@ -62,9 +62,9 @@ struct Rings : Module {
int model = 0; int model = 0;


Rings(); Rings();
void step();
void step() override;


json_t *toJson() {
json_t *toJson() override {
json_t *rootJ = json_object(); json_t *rootJ = json_object();


json_object_set_new(rootJ, "polyphony", json_integer(polyphonyMode)); json_object_set_new(rootJ, "polyphony", json_integer(polyphonyMode));
@@ -73,7 +73,7 @@ struct Rings : Module {
return rootJ; return rootJ;
} }


void fromJson(json_t *rootJ) {
void fromJson(json_t *rootJ) override {
json_t *polyphonyJ = json_object_get(rootJ, "polyphony"); json_t *polyphonyJ = json_object_get(rootJ, "polyphony");
if (polyphonyJ) { if (polyphonyJ) {
polyphonyMode = json_integer_value(polyphonyJ); polyphonyMode = json_integer_value(polyphonyJ);
@@ -85,12 +85,12 @@ struct Rings : Module {
} }
} }


void initialize() {
void initialize() override {
polyphonyMode = 0; polyphonyMode = 0;
model = 0; model = 0;
} }


void randomize() {
void randomize() override {
polyphonyMode = randomu32() % 3; polyphonyMode = randomu32() % 3;
model = randomu32() % 3; model = randomu32() % 3;
} }
@@ -140,7 +140,7 @@ void Rings::step() {
float in[24] = {}; float in[24] = {};
// Convert input buffer // Convert input buffer
{ {
inputSrc.setRatio(48000.0 / gSampleRate);
inputSrc.setRatio(48000.0 / engineGetSampleRate());
int inLen = inputBuffer.size(); int inLen = inputBuffer.size();
int outLen = 24; int outLen = 24;
inputSrc.process(inputBuffer.startData(), &inLen, (Frame<1>*) in, &outLen); inputSrc.process(inputBuffer.startData(), &inLen, (Frame<1>*) in, &outLen);
@@ -204,7 +204,7 @@ void Rings::step() {
outputFrames[i].samples[1] = aux[i]; outputFrames[i].samples[1] = aux[i];
} }


outputSrc.setRatio(gSampleRate / 48000.0);
outputSrc.setRatio(engineGetSampleRate() / 48000.0);
int inLen = 24; int inLen = 24;
int outLen = outputBuffer.capacity(); int outLen = outputBuffer.capacity();
outputSrc.process(outputFrames, &inLen, outputBuffer.endData(), &outLen); outputSrc.process(outputFrames, &inLen, outputBuffer.endData(), &outLen);


+ 1
- 1
src/Shades.cpp View File

@@ -28,7 +28,7 @@ struct Shades : Module {
float lights[3] = {}; float lights[3] = {};


Shades() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS) {} Shades() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS) {}
void step();
void step() override;
}; };






+ 1
- 1
src/Streams.cpp View File

@@ -32,7 +32,7 @@ struct Streams : Module {
}; };


Streams() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS) {} Streams() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS) {}
void step();
void step() override;
}; };






+ 6
- 6
src/Tides.cpp View File

@@ -49,9 +49,9 @@ struct Tides : Module {
SchmittTrigger rangeTrigger; SchmittTrigger rangeTrigger;


Tides(); Tides();
void step();
void step() override;


json_t *toJson() {
json_t *toJson() override {
json_t *rootJ = json_object(); json_t *rootJ = json_object();


json_object_set_new(rootJ, "mode", json_integer((int) generator.mode())); json_object_set_new(rootJ, "mode", json_integer((int) generator.mode()));
@@ -60,7 +60,7 @@ struct Tides : Module {
return rootJ; return rootJ;
} }


void fromJson(json_t *rootJ) {
void fromJson(json_t *rootJ) override {
json_t *modeJ = json_object_get(rootJ, "mode"); json_t *modeJ = json_object_get(rootJ, "mode");
if (modeJ) { if (modeJ) {
generator.set_mode((tides::GeneratorMode) json_integer_value(modeJ)); generator.set_mode((tides::GeneratorMode) json_integer_value(modeJ));
@@ -72,12 +72,12 @@ struct Tides : Module {
} }
} }


void initialize() {
void initialize() override {
generator.set_range(tides::GENERATOR_RANGE_MEDIUM); generator.set_range(tides::GENERATOR_RANGE_MEDIUM);
generator.set_mode(tides::GENERATOR_MODE_LOOPING); generator.set_mode(tides::GENERATOR_MODE_LOOPING);
} }


void randomize() {
void randomize() override {
generator.set_range((tides::GeneratorRange) (randomu32() % 3)); generator.set_range((tides::GeneratorRange) (randomu32() % 3));
generator.set_mode((tides::GeneratorMode) (randomu32() % 3)); generator.set_mode((tides::GeneratorMode) (randomu32() % 3));
} }
@@ -116,7 +116,7 @@ void Tides::step() {
pitch += params[FM_PARAM].value * inputs[FM_INPUT].normalize(0.1) / 5.0; pitch += params[FM_PARAM].value * inputs[FM_INPUT].normalize(0.1) / 5.0;
pitch += 60.0; pitch += 60.0;
// Scale to the global sample rate // Scale to the global sample rate
pitch += log2f(48000.0 / gSampleRate) * 12.0;
pitch += log2f(48000.0 / engineGetSampleRate()) * 12.0;
generator.set_pitch(clampf(pitch * 0x80, -0x8000, 0x7fff)); generator.set_pitch(clampf(pitch * 0x80, -0x8000, 0x7fff));


// Slope, smoothness, pitch // Slope, smoothness, pitch


+ 1
- 1
src/Veils.cpp View File

@@ -36,7 +36,7 @@ struct Veils : Module {
float lights[4] = {}; float lights[4] = {};


Veils() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS) {} Veils() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS) {}
void step();
void step() override;
}; };






+ 7
- 7
src/Warps.cpp View File

@@ -36,16 +36,16 @@ struct Warps : Module {
SchmittTrigger stateTrigger; SchmittTrigger stateTrigger;


Warps(); Warps();
void step();
void step() override;


json_t *toJson() {
json_t *toJson() override {
json_t *rootJ = json_object(); json_t *rootJ = json_object();
warps::Parameters *p = modulator.mutable_parameters(); warps::Parameters *p = modulator.mutable_parameters();
json_object_set_new(rootJ, "shape", json_integer(p->carrier_shape)); json_object_set_new(rootJ, "shape", json_integer(p->carrier_shape));
return rootJ; return rootJ;
} }


void fromJson(json_t *rootJ) {
void fromJson(json_t *rootJ) override {
json_t *shapeJ = json_object_get(rootJ, "shape"); json_t *shapeJ = json_object_get(rootJ, "shape");
warps::Parameters *p = modulator.mutable_parameters(); warps::Parameters *p = modulator.mutable_parameters();
if (shapeJ) { if (shapeJ) {
@@ -53,12 +53,12 @@ struct Warps : Module {
} }
} }


void initialize() {
void initialize() override {
warps::Parameters *p = modulator.mutable_parameters(); warps::Parameters *p = modulator.mutable_parameters();
p->carrier_shape = 0; p->carrier_shape = 0;
} }


void randomize() {
void randomize() override {
warps::Parameters *p = modulator.mutable_parameters(); warps::Parameters *p = modulator.mutable_parameters();
p->carrier_shape = randomu32() % 4; p->carrier_shape = randomu32() % 4;
} }
@@ -94,7 +94,7 @@ void Warps::step() {
p->frequency_shift_cv = clampf(inputs[ALGORITHM_INPUT].value / 5.0, -1.0, 1.0); p->frequency_shift_cv = clampf(inputs[ALGORITHM_INPUT].value / 5.0, -1.0, 1.0);
p->phase_shift = p->modulation_algorithm; p->phase_shift = p->modulation_algorithm;
p->note = 60.0 * params[LEVEL1_PARAM].value + 12.0 * inputs[LEVEL1_INPUT].normalize(2.0) + 12.0; p->note = 60.0 * params[LEVEL1_PARAM].value + 12.0 * inputs[LEVEL1_INPUT].normalize(2.0) + 12.0;
p->note += log2f(96000.0 / gSampleRate) * 12.0;
p->note += log2f(96000.0 / engineGetSampleRate()) * 12.0;


modulator.Process(inputFrames, outputFrames, 60); modulator.Process(inputFrames, outputFrames, 60);
} }
@@ -120,7 +120,7 @@ struct WarpsAlgoLight : ValueLight {
box.size = Vec(67, 67); box.size = Vec(67, 67);
} }


void step() {
void step() override {
// TODO Set these to Warps' actual colors // TODO Set these to Warps' actual colors
static NVGcolor colors[9] = { static NVGcolor colors[9] = {
nvgHSL(0.5, 0.3, 0.85), nvgHSL(0.5, 0.3, 0.85),


Loading…
Cancel
Save