> [4.271 warn src/window.cpp:75] Failed to load SVG C:\Users\huile\DOCUME~1/Rack/plugins-v1/Test1/res/TestModule.svg
I followed the Plugin Development Tutorial
and I just finished the tutorial. I was hoping to see something from the Rack.
I can find my Brand, and there is definitely a bright white text(which means it is available) with 1. However, when I click my brand (My Plugin from the Tutorial, Test1 for mine) it doesn’t show anything. When I check the log through log.text and my MSYS2, it says it failed to load SVG.
I used SVG file from the tutorial, which was called MyModule.svg.
Below is my module.cpp codes.
#include "plugin.hpp"
float phase = 0.f;
float blinkPhase = 0.f;
struct TestModule : Module {
enum ParamIds {
PITCH_PARAM,
NUM_PARAMS
};
enum InputIds {
PITCH_INPUT,
NUM_INPUTS
};
enum OutputIds {
SINE_OUTPUT,
NUM_OUTPUTS
};
enum LightIds {
BLINK_LIGHT,
NUM_LIGHTS
};
TestModule() {
config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS);
configParam(PITCH_PARAM, 0.f, 1.f, 0.f, "");
}
void process(const ProcessArgs &args) override {
// Compute the frequency from the pitch parameter and input
float pitch = params[PITCH_PARAM].getValue();
pitch += inputs[PITCH_INPUT].getVoltage();
pitch = clamp(pitch, -4.f, 4.f);
// The default pitch is C4 = 261.6256f
float freq = dsp::FREQ_C4 * std::pow(2.f, pitch);
// Accumulate the phase
phase += freq * args.sampleTime;
if (phase >= 0.5f)
phase -= 1.f;
// Compute the sine output
float sine = std::sin(2.f * M_PI * phase);
// Audio signals are typically +/-5V
// https://vcvrack.com/manual/VoltageStandards.html
outputs[SINE_OUTPUT].setVoltage(5.f * sine);
// Blink light at 1Hz
blinkPhase += args.sampleTime;
if (blinkPhase >= 1.f)
blinkPhase -= 1.f;
lights[BLINK_LIGHT].setBrightness(blinkPhase < 0.5f ? 1.f : 0.f);
}
};
struct TestModuleWidget : ModuleWidget {
TestModuleWidget(TestModule* module) {
setModule(module);
setPanel(APP->window->loadSvg(asset::plugin(pluginInstance, "res/TestModule.svg")));
addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0)));
addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0)));
addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
addParam(createParamCentered<RoundBlackKnob>(mm2px(Vec(15.24, 46.063)), module, TestModule::PITCH_PARAM));
addInput(createInputCentered<PJ301MPort>(mm2px(Vec(15.24, 77.478)), module, TestModule::PITCH_INPUT));
addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(15.24, 108.713)), module, TestModule::SINE_OUTPUT));
addChild(createLightCentered<MediumLight<RedLight>>(mm2px(Vec(15.24, 25.81)), module, TestModule::BLINK_LIGHT));
}
};
Model* modelTestModule = createModel<TestModule, TestModuleWidget>("TestModule");
The Tutorial told me
Open the generated
src/MyModule.cpp
source file and add the following member variables to theModule
class.
> float phase = 0.f;
> float blinkPhase = 0.f;
so I added those two variables on the top of the file (Sorry, this was the one I got confused. I hope this is where I made a mistake. I’m still learning this language)
Please let me know if I did any miserable mistake!
I just joined this new wonderful world, and I want to create some unforgettable memories!