Skip to content

Commit

Permalink
Merge pull request #9 from netboy3/v1
Browse files Browse the repository at this point in the history
V1 Migration
  • Loading branch information
mtsch authored Mar 24, 2020
2 parents ac83963 + 8ae064c commit 9e00f5b
Show file tree
Hide file tree
Showing 8 changed files with 151 additions and 166 deletions.
3 changes: 0 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
SLUG = mtsch-plugins
VERSION = 0.6.0

RACK_DIR ?= ../..
# FLAGS will be passed to both the C and C++ compiler
FLAGS +=
Expand Down
17 changes: 0 additions & 17 deletions mtsch-plugins.json

This file was deleted.

41 changes: 41 additions & 0 deletions plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"slug": "mtsch-plugins",
"name": "mtsch",
"version": "1.0.0",
"license": "MIT",
"brand": "mtsch",
"author": "mtsch",
"authorEmail": "",
"authorUrl": "",
"pluginUrl": "https://github.com/mtsch/mtsch-vcvrack-plugins",
"manualUrl": "https://github.com/mtsch/mtsch-vcvrack-plugins",
"sourceUrl": "https://github.com/mtsch/mtsch-vcvrack-plugins",
"donateUrl": "https://www.paypal.me/matcuf",
"changelogUrl": "",
"modules": [
{
"slug": "Rationals",
"name": "Rationals",
"description": "",
"tags": [
"Utility"
]
},
{
"slug": "Sum",
"name": "Sum",
"description": "",
"tags": [
"Utility"
]
},
{
"slug": "TriggerPanic",
"name": "Trigger Panic!",
"description": "",
"tags": [
"Delay"
]
}
]
}
76 changes: 35 additions & 41 deletions src/Rationals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,25 @@ struct Rationals : Module {
NUM_LIGHTS
};

Rationals() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) {}
void step() override;
Rationals() {
config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS);
for (int i = 0; i < NUM_CHANNELS; i++) {
configParam(Rationals::PARAMS + 2*i, 1, MAX_VALUE, 1);
configParam(Rationals::PARAMS + 1 + 2*i, 1, MAX_VALUE, 1);
}
}
void process(const ProcessArgs& args) override;

char display[4*NUM_CHANNELS];
};

void Rationals::step() {
void Rationals::process(const ProcessArgs& args) {

for (int i = 0; i < NUM_CHANNELS; i++) {
float num_cv = std::round(inputs[INPUTS + 1 + 3*i].value);
float num_par = std::round(params[PARAMS + 2*i].value);
float den_cv = std::round(inputs[INPUTS + 2 + 3*i].value);
float den_par = std::round(params[PARAMS + 1 + 2*i].value);
float num_cv = std::round(inputs[INPUTS + 1 + 3*i].getVoltage());
float num_par = std::round(params[PARAMS + 2*i].getValue());
float den_cv = std::round(inputs[INPUTS + 2 + 3*i].getVoltage());
float den_par = std::round(params[PARAMS + 1 + 2*i].getValue());

float num = num_cv + num_par;
float den = den_cv + den_par;
Expand All @@ -82,7 +88,7 @@ void Rationals::step() {
}
display[3 + digit_offset] = dig2 + '0';

outputs[OUTPUTS + i].value = inputs[INPUTS + 3*i].value + log2f(num/den);
outputs[OUTPUTS + i].setVoltage(inputs[INPUTS + 3*i].getVoltage() + log2f(num/den));
}
}

Expand All @@ -91,58 +97,46 @@ struct RationalsWidget : ModuleWidget {
};


RationalsWidget::RationalsWidget(Rationals *module) : ModuleWidget(module) {
RationalsWidget::RationalsWidget(Rationals *module) {
setModule(module);

box.size = Vec(10 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT);

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

addChild(Widget::create<ScrewSilver>(Vec(0, 0)));
addChild(Widget::create<ScrewSilver>(Vec(0, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
addChild(createWidget<ScrewSilver>(Vec(0, 0)));
addChild(createWidget<ScrewSilver>(Vec(0, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));

for (int i = 0; i < NUM_CHANNELS; i++) {
int y_pos = Y_POS + i * CHANNEL_SPACING;

int offset = NUM_CHANNELS * i;
int digit_x = X_POS + KNOB_X_OFFSET + DIGIT_X_OFFSET;
// Numerator digits.
addChild(new DigitDisplay(Vec(digit_x, y_pos + DIGIT_Y_OFFSET),
5.f, &module->display[0+offset]));
addChild(new DigitDisplay(Vec(digit_x + DIGIT_SPACING, y_pos + DIGIT_Y_OFFSET),
5.f, &module->display[1+offset]));
// Denominator digits.
addChild(new DigitDisplay(Vec(digit_x, y_pos + DIGIT_Y_OFFSET + NUMDEN_SPACING),
5.f, &module->display[2+offset]));
addChild(new DigitDisplay(Vec(digit_x + DIGIT_SPACING, y_pos + DIGIT_Y_OFFSET + NUMDEN_SPACING),
5.f, &module->display[3+offset]));

if (module) {
// Numerator digits.
addChild(new DigitDisplay(Vec(digit_x, y_pos + DIGIT_Y_OFFSET), 5.f, &module->display[0+offset]));
addChild(new DigitDisplay(Vec(digit_x + DIGIT_SPACING, y_pos + DIGIT_Y_OFFSET), 5.f, &module->display[1+offset]));
// Denominator digits.
addChild(new DigitDisplay(Vec(digit_x, y_pos + DIGIT_Y_OFFSET + NUMDEN_SPACING), 5.f, &module->display[2+offset]));
addChild(new DigitDisplay(Vec(digit_x + DIGIT_SPACING, y_pos + DIGIT_Y_OFFSET + NUMDEN_SPACING), 5.f, &module->display[3+offset]));
}

// Numerator knob.
addParam(ParamWidget::create<RoundSmallBlackKnob>(Vec(X_POS + KNOB_X_OFFSET, y_pos),
module, Rationals::PARAMS + 2*i, 1, MAX_VALUE, 1));
addParam(createParam<RoundSmallBlackKnob>(Vec(X_POS + KNOB_X_OFFSET, y_pos), module, Rationals::PARAMS + 2*i));
// Denominator knob.
addParam(ParamWidget::create<RoundSmallBlackKnob>(Vec(X_POS + KNOB_X_OFFSET, y_pos + NUMDEN_SPACING),
module, Rationals::PARAMS + 1 + 2*i, 1, MAX_VALUE, 1));
addParam(createParam<RoundSmallBlackKnob>(Vec(X_POS + KNOB_X_OFFSET, y_pos + NUMDEN_SPACING), module, Rationals::PARAMS + 1 + 2*i));

// IO.
addInput(Port::create<PJ301MPort>(Vec(X_POS, y_pos + IO_Y_OFFSET),
Port::INPUT, module, Rationals::INPUTS + i*3));
addOutput(Port::create<PJ301MPort>(Vec(X_POS + OUT_X_OFFSET, y_pos + IO_Y_OFFSET),
Port::OUTPUT, module, Rationals::OUTPUTS + i));
addInput(createInput<PJ301MPort>(Vec(X_POS, y_pos + IO_Y_OFFSET), module, Rationals::INPUTS + i*3));
addOutput(createOutput<PJ301MPort>(Vec(X_POS + OUT_X_OFFSET, y_pos + IO_Y_OFFSET), module, Rationals::OUTPUTS + i));
}

// CV mod grid.
for (int i = 0; i < NUM_CHANNELS; i++) {
addInput(Port::create<PJ301MPort>(Vec(GRID_X_POS + i*GRID_SPACING, GRID_Y_POS),
Port::INPUT, module, Rationals::INPUTS + 1 + i*3));
addInput(Port::create<PJ301MPort>(Vec(GRID_X_POS + i*GRID_SPACING, GRID_Y_POS + GRID_SPACING),
Port::INPUT, module, Rationals::INPUTS + 2 + i*3));
addInput(createInput<PJ301MPort>(Vec(GRID_X_POS + i*GRID_SPACING, GRID_Y_POS), module, Rationals::INPUTS + 1 + i*3));
addInput(createInput<PJ301MPort>(Vec(GRID_X_POS + i*GRID_SPACING, GRID_Y_POS + GRID_SPACING), module, Rationals::INPUTS + 2 + i*3));
}
}

Model *modelRationals = Model::create<Rationals, RationalsWidget>(
"mtsch", "Rationals", "Rationals", UTILITY_TAG);
Model *modelRationals = createModel<Rationals, RationalsWidget>("Rationals");
40 changes: 19 additions & 21 deletions src/Sum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,47 +26,45 @@ struct Sum : Module {
NUM_LIGHTS
};

Sum() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) {}
void step() override;
Sum() {
config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS);
for (int i = 0; i < NUM_CHANNELS; i++) {
configParam(Sum::PARAMS + i, -1, 1, 1);
}
}
void process(const ProcessArgs& args) override;
};

void Sum::step() {
void Sum::process(const ProcessArgs& args) {
float acc = 0;

for (int i = 0; i < NUM_CHANNELS; i++) {
acc += inputs[INPUTS + i].value * params[PARAMS + i].value;
acc += inputs[INPUTS + i].getVoltage() * params[PARAMS + i].getValue();
}

outputs[OUTPUT].value = acc;
outputs[OUTPUT].setVoltage(acc);
}

struct SumWidget : ModuleWidget {
SumWidget(Sum *module);
};

SumWidget::SumWidget(Sum *module) : ModuleWidget(module) {
SumWidget::SumWidget(Sum *module) {
setModule(module);
box.size = Vec(4 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT);

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

addChild(Widget::create<ScrewSilver>(Vec(0, 0)));
addChild(Widget::create<ScrewSilver>(Vec(0, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
addChild(createWidget<ScrewSilver>(Vec(0, 0)));
addChild(createWidget<ScrewSilver>(Vec(0, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));

for (int i = 0; i < NUM_CHANNELS; i++) {
addInput(Port::create<PJ301MPort>(Vec(X_POSITION, Y_INPUT_POSITION + i * SPACING),
Port::INPUT, module, Sum::INPUTS + i));
addParam(ParamWidget::create<CKSSThree>(Vec(X_POSITION + 30, Y_INPUT_POSITION + i * SPACING),
module, Sum::PARAMS + i, -1, 1, 1));
addInput(createInput<PJ301MPort>(Vec(X_POSITION, Y_INPUT_POSITION + i * SPACING), module, Sum::INPUTS + i));
addParam(createParam<CKSSThree>(Vec(X_POSITION + 30, Y_INPUT_POSITION + i * SPACING), module, Sum::PARAMS + i));
}

addOutput(Port::create<PJ301MPort>(Vec(X_POSITION, Y_OUTPUT_POSITION), Port::OUTPUT, module, Sum::OUTPUT));
addOutput(createOutput<PJ301MPort>(Vec(X_POSITION, Y_OUTPUT_POSITION), module, Sum::OUTPUT));
}


Model *modelSum = Model::create<Sum, SumWidget>(
"mtsch", "Sum", "Sum", UTILITY_TAG);
Model *modelSum = createModel<Sum, SumWidget>("Sum");
Loading

0 comments on commit 9e00f5b

Please sign in to comment.