Skip to content

Commit 21220ec

Browse files
authored
v2 upgrade (#21)
* Update to work with v2 API * Update config options to include new right-click menus for modules - Also clean up some inconsistencies with indentation using astyle * Apply additional style autoformatting
1 parent 0f6b9e0 commit 21220ec

29 files changed

Lines changed: 2001 additions & 1915 deletions

plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"slug": "TinyTricks",
33
"name": "Tiny Tricks",
44
"brand": "Tiny Tricks",
5-
"version": "1.5.0",
5+
"version": "2.5.0",
66
"license": "GPL-3.0-only",
77
"author": "Thomas René Sidor",
88
"authorEmail": "mail@thomassidor.com",

src/arithmetic.cpp

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,29 +33,42 @@ struct TTA : TinyTricksModule {
3333

3434
TTA() {
3535
config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS);
36+
configInput(A_INPUT, "A");
37+
configInput(B_INPUT, "B");
38+
configOutput(APLUSB_OUTPUT, "A+B");
39+
configOutput(AVGAB_OUTPUT, "Average");
40+
configOutput(AMINUSB_OUTPUT, "A-B");
41+
configOutput(BMINUSA_OUTPUT, "B-A");
42+
configOutput(ADIVB_OUTPUT, "A/B");
43+
configOutput(BDIVA_OUTPUT, "B/A");
44+
configOutput(AMULB_OUTPUT, "A*B");
45+
configOutput(AEXPB_OUTPUT, "A^B");
46+
configOutput(ONEOVERA_OUTPUT, "1/A");
47+
configOutput(ONEOVERB_OUTPUT, "1/B");
48+
configOutput(MINUSA_OUTPUT, "-A");
49+
configOutput(MINUSB_OUTPUT, "-B");
3650
}
3751

3852
void process(const ProcessArgs &args) override {
3953
int nChan = std::max(1, inputs[A_INPUT].getChannels());
40-
for( int op=APLUSB_OUTPUT; op < NUM_OUTPUTS; op++ )
41-
outputs[op].setChannels(nChan);
54+
for (int op = APLUSB_OUTPUT; op < NUM_OUTPUTS; op++)
55+
outputs[op].setChannels(nChan);
4256

43-
for( auto c=0; c<nChan; ++c )
44-
{
57+
for (auto c = 0; c < nChan; ++c) {
4558
if (inputs[A_INPUT].isConnected() && inputs[B_INPUT].isConnected()) {
4659
float a = inputs[A_INPUT].getVoltage(c);
4760
float b = inputs[B_INPUT].getPolyVoltage(c);
4861

49-
outputs[APLUSB_OUTPUT].setVoltage(a+b, c);
50-
outputs[AVGAB_OUTPUT].setVoltage((a+b)/2, c);
51-
outputs[AMINUSB_OUTPUT].setVoltage(a-b, c);
52-
outputs[BMINUSA_OUTPUT].setVoltage(b-a, c);
53-
outputs[ADIVB_OUTPUT].setVoltage((b==0.f?0.f:a/b), c);
54-
outputs[BDIVA_OUTPUT].setVoltage((a==0.f?0.f:b/a), c);
55-
outputs[AMULB_OUTPUT].setVoltage(a*b, c);
56-
outputs[AEXPB_OUTPUT].setVoltage(pow(a,b), c);
57-
outputs[ONEOVERA_OUTPUT].setVoltage((a==0.f?0.f:1/a), c);
58-
outputs[ONEOVERB_OUTPUT].setVoltage((b==0.f?0.f:1/b), c);
62+
outputs[APLUSB_OUTPUT].setVoltage(a + b, c);
63+
outputs[AVGAB_OUTPUT].setVoltage((a + b) / 2, c);
64+
outputs[AMINUSB_OUTPUT].setVoltage(a - b, c);
65+
outputs[BMINUSA_OUTPUT].setVoltage(b - a, c);
66+
outputs[ADIVB_OUTPUT].setVoltage((b == 0.f ? 0.f : a / b), c);
67+
outputs[BDIVA_OUTPUT].setVoltage((a == 0.f ? 0.f : b / a), c);
68+
outputs[AMULB_OUTPUT].setVoltage(a * b, c);
69+
outputs[AEXPB_OUTPUT].setVoltage(pow(a, b), c);
70+
outputs[ONEOVERA_OUTPUT].setVoltage((a == 0.f ? 0.f : 1 / a), c);
71+
outputs[ONEOVERB_OUTPUT].setVoltage((b == 0.f ? 0.f : 1 / b), c);
5972
outputs[MINUSA_OUTPUT].setVoltage(-a, c);
6073
outputs[MINUSB_OUTPUT].setVoltage(-b, c);
6174
}

src/attenuator.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ struct A8 : TinyTricksModule {
2626
A8() {
2727
config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS);
2828
configParam(LEVEL_PARAM, 0.f, 1.f, 1.f, "Attenuation level");
29+
for (int i = 0; i < NUM_CHANNELS; i++) {
30+
configInput(ATT_INPUT + i, string::f("Channel %d", i + 1));
31+
configOutput(ATT_OUTPUT + i, string::f("Channel %d", i + 1));
32+
}
2933
}
3034

3135

@@ -35,7 +39,7 @@ struct A8 : TinyTricksModule {
3539
if (inputs[ATT_INPUT + i].isConnected() && outputs[ATT_OUTPUT + i].isConnected())
3640
outputs[ATT_OUTPUT + i].setVoltage(inputs[ATT_INPUT + i].getVoltage() * level);
3741
}
38-
}
42+
}
3943
};
4044

4145

@@ -47,7 +51,7 @@ struct A8Widget : TinyTricksModuleWidget {
4751
setModule(module);
4852

4953

50-
addParam(createParam<RoundBlackKnob>(mm2px(Vec(7.7f,11.055f)), module, A8::LEVEL_PARAM));
54+
addParam(createParam<RoundBlackKnob>(mm2px(Vec(7.7f, 11.055f)), module, A8::LEVEL_PARAM));
5155

5256
for (int i = 0; i < NUM_CHANNELS; i++)
5357
addInput(createInput<TinyTricksPort>(mm2px(Vec(3.131f, 29.859f + 11.5f * i)), module, A8::ATT_INPUT + i));

src/logic.cpp

Lines changed: 38 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -33,35 +33,48 @@ struct TTL : TinyTricksModule {
3333

3434
TTL() {
3535
config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS);
36+
configInput(A_INPUT, "A");
37+
configInput(B_INPUT, "B");
38+
configOutput(AND_OUTPUT, "AND");
39+
configOutput(OR_OUTPUT, "OR");
40+
configOutput(XOR_OUTPUT, "XOR");
41+
configOutput(NOR_OUTPUT, "NOR");
42+
configOutput(ALTB_OUTPUT, "A<B");
43+
configOutput(AGTB_OUTPUT, "A>B");
44+
configOutput(ALTEB_OUTPUT, "A<=B");
45+
configOutput(AGTEB_OUTPUT, "A>=B");
46+
configOutput(AISB_OUTPUT, "A=B");
47+
configOutput(AISNOTB_OUTPUT, "A!=B");
48+
configOutput(NOTA_OUTPUT, "¬A");
49+
configOutput(NOTB_OUTPUT, "¬B");
3650
}
3751

3852
void process(const ProcessArgs &args) override {
3953
int nChan = std::max(1, inputs[A_INPUT].getChannels());
40-
for( int op=AND_OUTPUT; op < NUM_OUTPUTS; op++ )
41-
outputs[op].setChannels(nChan);
42-
43-
for( auto c=0; c<nChan; ++c )
44-
{
45-
if (inputs[A_INPUT].isConnected() && inputs[B_INPUT].isConnected()) {
46-
float a = inputs[A_INPUT].getVoltage(c);
47-
float b = inputs[B_INPUT].getPolyVoltage(c);
48-
49-
bool isA = (a!=0.f);
50-
bool isB = (b!=0.f);
51-
52-
outputs[AND_OUTPUT].setVoltage((isA && isB?10.f:0.f), c);
53-
outputs[OR_OUTPUT].setVoltage((isA || isB?10.f:0.f), c);
54-
outputs[XOR_OUTPUT].setVoltage((isA != isB?10.f:0.f), c);
55-
outputs[NOR_OUTPUT].setVoltage((!(a || b)?10.f:0.f), c);
56-
outputs[ALTB_OUTPUT].setVoltage((a<b?10.f:0.f), c);
57-
outputs[AGTB_OUTPUT].setVoltage((a>b?10.f:0.f), c);
58-
outputs[ALTEB_OUTPUT].setVoltage((a<=b?10.f:0.f), c);
59-
outputs[AGTEB_OUTPUT].setVoltage((a>=b?10.f:0.f), c);
60-
outputs[AISB_OUTPUT].setVoltage((a==b?10.f:0.f), c);
61-
outputs[AISNOTB_OUTPUT].setVoltage((a!=b?10.f:0.f), c);
62-
outputs[NOTA_OUTPUT].setVoltage(!a, c);
63-
outputs[NOTB_OUTPUT].setVoltage(!b, c);
64-
}
54+
for (int op = AND_OUTPUT; op < NUM_OUTPUTS; op++)
55+
outputs[op].setChannels(nChan);
56+
57+
for (auto c = 0; c < nChan; ++c) {
58+
if (inputs[A_INPUT].isConnected() && inputs[B_INPUT].isConnected()) {
59+
float a = inputs[A_INPUT].getVoltage(c);
60+
float b = inputs[B_INPUT].getPolyVoltage(c);
61+
62+
bool isA = (a != 0.f);
63+
bool isB = (b != 0.f);
64+
65+
outputs[AND_OUTPUT].setVoltage((isA && isB ? 10.f : 0.f), c);
66+
outputs[OR_OUTPUT].setVoltage((isA || isB ? 10.f : 0.f), c);
67+
outputs[XOR_OUTPUT].setVoltage((isA != isB ? 10.f : 0.f), c);
68+
outputs[NOR_OUTPUT].setVoltage((!(a || b) ? 10.f : 0.f), c);
69+
outputs[ALTB_OUTPUT].setVoltage((a < b ? 10.f : 0.f), c);
70+
outputs[AGTB_OUTPUT].setVoltage((a > b ? 10.f : 0.f), c);
71+
outputs[ALTEB_OUTPUT].setVoltage((a <= b ? 10.f : 0.f), c);
72+
outputs[AGTEB_OUTPUT].setVoltage((a >= b ? 10.f : 0.f), c);
73+
outputs[AISB_OUTPUT].setVoltage((a == b ? 10.f : 0.f), c);
74+
outputs[AISNOTB_OUTPUT].setVoltage((a != b ? 10.f : 0.f), c);
75+
outputs[NOTA_OUTPUT].setVoltage(!a, c);
76+
outputs[NOTB_OUTPUT].setVoltage(!b, c);
77+
}
6578
}
6679
}
6780
};

0 commit comments

Comments
 (0)