Skip to content

Commit

Permalink
Migrate to v1, fix the build.
Browse files Browse the repository at this point in the history
  • Loading branch information
eres-j committed Oct 18, 2019
1 parent 994f50a commit 5bb543a
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 133 deletions.
10 changes: 4 additions & 6 deletions src/JE.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
#include "JE.hpp"

rack::Plugin* plugin;
rack::Plugin* pluginInstance;

void init(rack::Plugin *p)
{
plugin = p;
plugin->website = "https://github.com/eres-j/VCVRack-plugin-JE";
plugin->manual = "https://github.com/eres-j/VCVRack-plugin-JE";
pluginInstance = p;

p->addModel(rack::createModel<RingModulatorWidget>("Ring Modulator"));
p->addModel(rack::createModel<WaveFolderWidget>("Wave Folder"));
p->addModel(modelRM);
p->addModel(modelWF);
}
16 changes: 4 additions & 12 deletions src/JE.hpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
#pragma once

#include "rack0.hpp"
#include "rack.hpp"

extern rack::Plugin *plugin;
extern rack::Plugin *pluginInstance;

struct RingModulatorWidget : rack::ModuleWidget
{
RingModulatorWidget();
};


struct WaveFolderWidget : rack::ModuleWidget
{
WaveFolderWidget();
};
extern rack::Model* modelRM;
extern rack::Model* modelWF;
140 changes: 73 additions & 67 deletions src/RingModulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,17 @@ struct RingModulator : rack::Module
};

RingModulator()
: Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS)
{}
{
config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS);
configParam(INPUT_LEVEL_PARAM, 0.f, 1.f, 1.f, "Input level");
configParam(CARRIER_LEVEL_PARAM, 0.f, 1.f, 1.f, "Carrier level");
configParam(CARRIER_OFFSET_PARAM, -g_controlPeakVoltage, g_controlPeakVoltage, 0.f, "Carrier offset");
configParam(INPUT_POLARITY_PARAM, 0.f, 2.f, 1.f, "Input polarity");
configParam(CARRIER_POLARITY_PARAM, 0.f, 2.f, 1.f, "Carrier polarity");
configParam(DIODE_VB_PARAM, std::numeric_limits<float>::epsilon(), g_controlPeakVoltage, 0.2f, "Diode forward-bias voltage (Vb)");
configParam(DIODE_VL_MINUS_VB_PARAM, std::numeric_limits<float>::epsilon(), g_controlPeakVoltage, 0.5f, "Diode voltage beyond which the function is linear - Vb");
configParam(DIODE_H_PARAM, 0.f, 1.f, 0.9f, "Diode slope of the linear section");
}

inline bool needToStep()
{
Expand Down Expand Up @@ -111,7 +120,7 @@ struct RingModulator : rack::Module
return inputValue;
}

inline void step() override
inline void process(const ProcessArgs& args) override
{
if (!needToStep())
return;
Expand Down Expand Up @@ -142,71 +151,68 @@ struct RingModulator : rack::Module
Diode m_diode;
};

RingModulatorWidget::RingModulatorWidget()
struct RingModulatorWidget : rack::ModuleWidget
{
RingModulator* module = new RingModulator();
setModule(module);
box.size = rack::Vec(15*10, 380);

RingModulatorWidget(RingModulator* module)
{
rack::SVGPanel *panel = new rack::SVGPanel();
panel->box.size = box.size;
panel->setBackground(rack::SVG::load(assetPlugin(plugin, "res/CleanRingModulator.svg")));
addChild(panel);
setModule(module);
setPanel(APP->window->loadSvg(rack::asset::plugin(pluginInstance, "res/CleanRingModulator.svg")));

addChild(rack::createWidget<rack::ScrewBlack>(rack::Vec(15, 0)));
addChild(rack::createWidget<rack::ScrewBlack>(rack::Vec(box.size.x-30, 0)));
addChild(rack::createWidget<rack::ScrewBlack>(rack::Vec(15, 365)));
addChild(rack::createWidget<rack::ScrewBlack>(rack::Vec(box.size.x-30, 365)));

const float switchX = box.size.x - 40.f;

float yOffset = 67.f;

float portY = 63.f;
float knobY = 57.f;
float switchY = 54.f;
addInput(rack::createInput<rack::PJ301MPort>(rack::Vec(9, portY), module, RingModulator::INPUT_INPUT));
addParam(rack::createParam<rack::RoundBlackKnob>(rack::Vec(54, knobY), module, RingModulator::INPUT_LEVEL_PARAM));
addParam(rack::createParam<rack::NKK>(rack::Vec(switchX, switchY), module, RingModulator::INPUT_POLARITY_PARAM));

portY += yOffset;
knobY += yOffset;
switchY += yOffset;
addInput(rack::createInput<rack::PJ301MPort>(rack::Vec(9, portY), module, RingModulator::CARRIER_INPUT));
addParam(rack::createParam<rack::RoundBlackKnob>(rack::Vec(54, knobY), module, RingModulator::CARRIER_LEVEL_PARAM));
addParam(rack::createParam<rack::NKK>(rack::Vec(switchX, switchY), module, RingModulator::CARRIER_POLARITY_PARAM));

portY += yOffset;
knobY += yOffset;
switchY += yOffset;
addInput(rack::createInput<rack::PJ301MPort>(rack::Vec(9, portY), module, RingModulator::CARRIER_OFFSET_INPUT));
addParam(rack::createParam<rack::RoundBlackKnob>(rack::Vec(54, knobY), module, RingModulator::CARRIER_OFFSET_PARAM));
addOutput(rack::createOutput<rack::PJ301MPort>(rack::Vec(box.size.x-34, portY), module, RingModulator::RING_OUTPUT));

portY += yOffset;
knobY += yOffset;
switchY += yOffset;
float xOffset = 35.f;
float x = 9.f;
addOutput(rack::createOutput<rack::PJ301MPort>(rack::Vec(x, portY), module, RingModulator::SUM_OUTPUT));
x += xOffset;
addOutput(rack::createOutput<rack::PJ301MPort>(rack::Vec(x, portY), module, RingModulator::DIFF_OUTPUT));
x += xOffset;
addOutput(rack::createOutput<rack::PJ301MPort>(rack::Vec(x, portY), module, RingModulator::MIN_OUTPUT));
x += xOffset;
addOutput(rack::createOutput<rack::PJ301MPort>(rack::Vec(x, portY), module, RingModulator::MAX_OUTPUT));

portY += yOffset;
knobY += yOffset;
switchY += yOffset;
const float y = knobY - 6.f;
xOffset = 52.f;
x = 9.f;
addParam(rack::createParam<rack::RoundSmallBlackKnob>(rack::Vec(x, y), module, RingModulator::DIODE_VB_PARAM));
x += xOffset;
addParam(rack::createParam<rack::RoundSmallBlackKnob>(rack::Vec(x, y), module, RingModulator::DIODE_VL_MINUS_VB_PARAM));
x += xOffset;
addParam(rack::createParam<rack::RoundSmallBlackKnob>(rack::Vec(x, y), module, RingModulator::DIODE_H_PARAM));
}
};

addChild(rack::createScrew<rack::ScrewBlack>(rack::Vec(15, 0)));
addChild(rack::createScrew<rack::ScrewBlack>(rack::Vec(box.size.x-30, 0)));
addChild(rack::createScrew<rack::ScrewBlack>(rack::Vec(15, 365)));
addChild(rack::createScrew<rack::ScrewBlack>(rack::Vec(box.size.x-30, 365)));

const float switchX = box.size.x - 40.f;

float yOffset = 67.f;

float portY = 63.f;
float knobY = 57.f;
float switchY = 54.f;
addInput(rack::createInput<rack::PJ301MPort>(rack::Vec(9, portY), module, RingModulator::INPUT_INPUT));
addParam(rack::createParam<rack::RoundBlackKnob>(rack::Vec(54, knobY), module, RingModulator::INPUT_LEVEL_PARAM, 0.0, 1.0, 1.0));
addParam(rack::createParam<rack::NKK>(rack::Vec(switchX, switchY), module, RingModulator::INPUT_POLARITY_PARAM, 0.0, 2.0, 1.0));

portY += yOffset;
knobY += yOffset;
switchY += yOffset;
addInput(rack::createInput<rack::PJ301MPort>(rack::Vec(9, portY), module, RingModulator::CARRIER_INPUT));
addParam(rack::createParam<rack::RoundBlackKnob>(rack::Vec(54, knobY), module, RingModulator::CARRIER_LEVEL_PARAM, 0.0, 1.0, 1.0));
addParam(rack::createParam<rack::NKK>(rack::Vec(switchX, switchY), module, RingModulator::CARRIER_POLARITY_PARAM, 0.0, 2.0, 1.0));

portY += yOffset;
knobY += yOffset;
switchY += yOffset;
addInput(rack::createInput<rack::PJ301MPort>(rack::Vec(9, portY), module, RingModulator::CARRIER_OFFSET_INPUT));
addParam(rack::createParam<rack::RoundBlackKnob>(rack::Vec(54, knobY), module, RingModulator::CARRIER_OFFSET_PARAM, -g_controlPeakVoltage, g_controlPeakVoltage, 0.0));
addOutput(rack::createOutput<rack::PJ301MPort>(rack::Vec(box.size.x-34, portY), module, RingModulator::RING_OUTPUT));

portY += yOffset;
knobY += yOffset;
switchY += yOffset;
float xOffset = 35.f;
float x = 9.f;
addOutput(rack::createOutput<rack::PJ301MPort>(rack::Vec(x, portY), module, RingModulator::SUM_OUTPUT));
x += xOffset;
addOutput(rack::createOutput<rack::PJ301MPort>(rack::Vec(x, portY), module, RingModulator::DIFF_OUTPUT));
x += xOffset;
addOutput(rack::createOutput<rack::PJ301MPort>(rack::Vec(x, portY), module, RingModulator::MIN_OUTPUT));
x += xOffset;
addOutput(rack::createOutput<rack::PJ301MPort>(rack::Vec(x, portY), module, RingModulator::MAX_OUTPUT));

portY += yOffset;
knobY += yOffset;
switchY += yOffset;
const float y = knobY - 6.f;
xOffset = 52.f;
x = 9.f;
addParam(rack::createParam<rack::RoundSmallBlackKnob>(rack::Vec(x, y), module, RingModulator::DIODE_VB_PARAM, std::numeric_limits<float>::epsilon(), g_controlPeakVoltage, 0.2));
x += xOffset;
addParam(rack::createParam<rack::RoundSmallBlackKnob>(rack::Vec(x, y), module, RingModulator::DIODE_VL_MINUS_VB_PARAM, std::numeric_limits<float>::epsilon(), g_controlPeakVoltage, 0.5));
x += xOffset;
addParam(rack::createParam<rack::RoundSmallBlackKnob>(rack::Vec(x, y), module, RingModulator::DIODE_H_PARAM, 0.0, 1.0, 0.9));
}
rack::Model* modelRM = rack::createModel<RingModulator, RingModulatorWidget>("RM");
99 changes: 51 additions & 48 deletions src/WaveFolder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,14 @@ struct WaveFolder : rack::Module
};

WaveFolder()
: Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS)
{}
{
config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS);
configParam(INPUT_GAIN_PARAM, 0.f, 1.f, 0.1f, "Input gain");
configParam(DC_OFFSET_PARAM, -5.f, 5.f, 0.f, "Input offset");
configParam(OUTPUT_GAIN_PARAM, 0.f, 10.f, 1.f, "Output gain");
configParam(RESISTOR_PARAM, 10000.f, 100000.f, 15000.f, "Resistor (ohm)");
configParam(LOAD_RESISTOR_PARAM, 1000.f, 10000.f, 7500.f, "Load resistor (ohm)");
}

inline float getParameterValue(const ParamIds id) const
{
Expand Down Expand Up @@ -117,7 +123,7 @@ struct WaveFolder : rack::Module
return theta * m_thermalVoltage * utl::LambertW<0>(m_delta * meta::exp(theta * m_beta * in)) - m_alpha * in;
}

inline void step() override
inline void process(const ProcessArgs& args) override
{
if (!needToStep())
return;
Expand All @@ -140,52 +146,49 @@ struct WaveFolder : rack::Module
float m_delta = (m_loadResistor * m_saturationCurrent) / m_thermalVoltage;
};

WaveFolderWidget::WaveFolderWidget()
struct WaveFolderWidget : rack::ModuleWidget
{
WaveFolder* module = new WaveFolder();
setModule(module);
box.size = rack::Vec(15*7, 380);

WaveFolderWidget(WaveFolder* module)
{
rack::SVGPanel *panel = new rack::SVGPanel();
panel->box.size = box.size;
panel->setBackground(rack::SVG::load(assetPlugin(plugin, "res/CleanWaveFolder.svg")));
addChild(panel);
setModule(module);
setPanel(APP->window->loadSvg(rack::asset::plugin(pluginInstance, "res/CleanWaveFolder.svg")));

addChild(rack::createWidget<rack::ScrewBlack>(rack::Vec(15, 0)));
addChild(rack::createWidget<rack::ScrewBlack>(rack::Vec(box.size.x-30, 0)));
addChild(rack::createWidget<rack::ScrewBlack>(rack::Vec(15, 365)));
addChild(rack::createWidget<rack::ScrewBlack>(rack::Vec(box.size.x-30, 365)));

float yOffset = 67.f;

float portY = 63.f;
float knobY = 57.f;
addInput(rack::createInput<rack::PJ301MPort>(rack::Vec(9, portY), module, WaveFolder::INPUT_GAIN_INPUT));
addParam(rack::createParam<rack::RoundBlackKnob>(rack::Vec(54, knobY), module, WaveFolder::INPUT_GAIN_PARAM));

portY += yOffset;
knobY += yOffset;
addInput(rack::createInput<rack::PJ301MPort>(rack::Vec(9, portY), module, WaveFolder::DC_OFFSET_INPUT));
addParam(rack::createParam<rack::RoundBlackKnob>(rack::Vec(54, knobY), module, WaveFolder::DC_OFFSET_PARAM));

portY += yOffset;
knobY += yOffset;
addInput(rack::createInput<rack::PJ301MPort>(rack::Vec(9, portY), module, WaveFolder::OUTPUT_GAIN_INPUT));
addParam(rack::createParam<rack::RoundBlackKnob>(rack::Vec(54, knobY), module, WaveFolder::OUTPUT_GAIN_PARAM));

portY += yOffset;
knobY += yOffset;
addInput(rack::createInput<rack::PJ301MPort>(rack::Vec(18, portY), module, WaveFolder::INPUT_INPUT));
addOutput(rack::createOutput<rack::PJ301MPort>(rack::Vec(box.size.x-43, portY), module, WaveFolder::OUTPUT_OUTPUT));

portY += yOffset;
knobY += yOffset;
const float y = knobY - 6.f;
float xOffset = 52.f;
float x = 9.f;
addParam(rack::createParam<rack::RoundSmallBlackKnob>(rack::Vec(x, y), module, WaveFolder::RESISTOR_PARAM));
x += xOffset;
addParam(rack::createParam<rack::RoundSmallBlackKnob>(rack::Vec(x, y), module, WaveFolder::LOAD_RESISTOR_PARAM));
}
};

addChild(rack::createScrew<rack::ScrewBlack>(rack::Vec(15, 0)));
addChild(rack::createScrew<rack::ScrewBlack>(rack::Vec(box.size.x-30, 0)));
addChild(rack::createScrew<rack::ScrewBlack>(rack::Vec(15, 365)));
addChild(rack::createScrew<rack::ScrewBlack>(rack::Vec(box.size.x-30, 365)));

float yOffset = 67.f;

float portY = 63.f;
float knobY = 57.f;
addInput(rack::createInput<rack::PJ301MPort>(rack::Vec(9, portY), module, WaveFolder::INPUT_GAIN_INPUT));
addParam(rack::createParam<rack::RoundBlackKnob>(rack::Vec(54, knobY), module, WaveFolder::INPUT_GAIN_PARAM, 0.0, 1.0, 0.1));

portY += yOffset;
knobY += yOffset;
addInput(rack::createInput<rack::PJ301MPort>(rack::Vec(9, portY), module, WaveFolder::DC_OFFSET_INPUT));
addParam(rack::createParam<rack::RoundBlackKnob>(rack::Vec(54, knobY), module, WaveFolder::DC_OFFSET_PARAM, -5.0, 5.0, 0.0));

portY += yOffset;
knobY += yOffset;
addInput(rack::createInput<rack::PJ301MPort>(rack::Vec(9, portY), module, WaveFolder::OUTPUT_GAIN_INPUT));
addParam(rack::createParam<rack::RoundBlackKnob>(rack::Vec(54, knobY), module, WaveFolder::OUTPUT_GAIN_PARAM, 0.0, 10.0, 1.0));

portY += yOffset;
knobY += yOffset;
addInput(rack::createInput<rack::PJ301MPort>(rack::Vec(18, portY), module, WaveFolder::INPUT_INPUT));
addOutput(rack::createOutput<rack::PJ301MPort>(rack::Vec(box.size.x-43, portY), module, WaveFolder::OUTPUT_OUTPUT));

portY += yOffset;
knobY += yOffset;
const float y = knobY - 6.f;
float xOffset = 52.f;
float x = 9.f;
addParam(rack::createParam<rack::RoundSmallBlackKnob>(rack::Vec(x, y), module, WaveFolder::RESISTOR_PARAM, 10000.f, 100000.f, 15000.f));
x += xOffset;
addParam(rack::createParam<rack::RoundSmallBlackKnob>(rack::Vec(x, y), module, WaveFolder::LOAD_RESISTOR_PARAM, 1000.f, 10000.f, 7500.f));
}
rack::Model* modelWF = rack::createModel<WaveFolder, WaveFolderWidget>("WF");

0 comments on commit 5bb543a

Please sign in to comment.