commit 0d9cf28daa45928c30da31398a64694fb4ee3c34
parent 13e4610314517bd19b7923c6b528f788ab03d17a
Author: Adam M <aemalone@gmail.com>
Date: Fri, 20 Jul 2018 15:56:35 +0300
randomizing only shuffles such that each output is assigned exactly one random input
Diffstat:
3 files changed, 82 insertions(+), 40 deletions(-)
diff --git a/build/src/ComputerscareRouter.cpp.o b/build/src/ComputerscareRouter.cpp.o
Binary files differ.
diff --git a/res/ComputerscareRouter.svg b/res/ComputerscareRouter.svg
@@ -34,9 +34,9 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
- inkscape:zoom="2.8284272"
- inkscape:cx="114.54926"
- inkscape:cy="361.60878"
+ inkscape:zoom="16"
+ inkscape:cx="265.35509"
+ inkscape:cy="355.45654"
inkscape:document-units="mm"
inkscape:current-layer="g1669"
showgrid="false"
@@ -151,7 +151,7 @@
aria-label="active"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52777767px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332"
id="text979"
- transform="matrix(1,-0.02561708,0,1,3.7041668,0.88038825)">
+ transform="matrix(1,-0.02561708,0,1,1.5875,0.88038825)">
<path
d="m 9.5436039,205.22317 q -0.3841282,0 -0.5322673,0.0879 -0.1481391,0.0878 -0.1481391,0.29972 0,0.16881 0.1102431,0.26872 0.1119656,0.0982 0.3031684,0.0982 0.2635498,0 0.4220242,-0.18603 0.1601969,-0.18776 0.1601969,-0.49782 v -0.0706 z m 0.6321751,-0.13092 v 1.10071 H 9.8588301 v -0.29283 q -0.1085205,0.1757 -0.27044,0.2601 -0.1619195,0.0827 -0.396186,0.0827 -0.2962782,0 -0.471978,-0.16537 -0.1739774,-0.16709 -0.1739774,-0.44614 0,-0.32556 0.2170411,-0.49092 0.2187635,-0.16537 0.651123,-0.16537 h 0.4444173 v -0.031 q 0,-0.21877 -0.144694,-0.33762 -0.1429715,-0.12058 -0.4030762,-0.12058 -0.1653646,0 -0.3221164,0.0396 -0.1567518,0.0396 -0.3014458,0.11885 v -0.29283 q 0.1739773,-0.0672 0.3376193,-0.0999 0.163642,-0.0345 0.3186713,-0.0345 0.4185791,0 0.6252848,0.21704 0.2067059,0.21704 0.2067059,0.65801 z"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52777767px;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;stroke-width:0.26458332"
@@ -270,7 +270,7 @@
</g>
<g
aria-label="father & son"
- transform="matrix(1.0190173,0,0,0.9813376,0,0.52916667)"
+ transform="matrix(1.0190173,0,0,0.9813376,-2.1166667,0.52916667)"
style="font-style:normal;font-weight:normal;font-size:8.01353455px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.20033836"
id="text1057">
<path
@@ -324,5 +324,32 @@
id="path1077"
inkscape:connector-curvature="0" />
</g>
+ <g
+ aria-label="shuf"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52777767px;line-height:1.25;font-family:'Lao MN';-inkscape-font-specification:'Lao MN, weight=250';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332"
+ id="text6801"
+ transform="matrix(1.0792241,0,0,1.1014641,-5.3126873,-20.134143)">
+ <path
+ d="m 65.661954,201.13564 q 0.07739,0.007 0.138247,-0.01 0.06067,-0.0182 0.0995,-0.0519 0.0406,-0.0335 0.05787,-0.081 0.0173,-0.0474 0.0079,-0.0989 -0.0153,-0.0841 -0.07055,-0.14971 -0.05377,-0.0672 -0.134937,-0.12337 -0.07971,-0.0577 -0.178649,-0.10699 -0.09894,-0.0493 -0.201702,-0.10061 -0.101327,-0.0529 -0.201814,-0.11071 -0.10081,-0.0596 -0.184791,-0.13118 -0.08254,-0.0732 -0.142131,-0.16282 -0.05817,-0.0913 -0.07976,-0.20961 -0.02034,-0.1115 0.0099,-0.20163 0.03203,-0.0899 0.103886,-0.15111 0.07363,-0.061 0.184553,-0.0882 0.112365,-0.0288 0.25302,-0.0163 0.0931,0.008 0.178334,0.0294 0.08484,0.0194 0.169058,0.0639 0.08571,0.0431 0.175256,0.11683 0.09132,0.0739 0.195432,0.1895 l -0.115229,0.1079 q -0.138541,-0.18107 -0.287502,-0.277 -0.147207,-0.0958 -0.298399,-0.1092 -0.0791,-0.007 -0.142071,0.008 -0.06337,0.0129 -0.104587,0.043 -0.04154,0.0283 -0.05977,0.0706 -0.01823,0.0423 -0.0092,0.092 0.01504,0.0824 0.07376,0.14832 0.05875,0.066 0.145171,0.12258 0.08645,0.0567 0.192714,0.10824 0.105967,0.0499 0.217834,0.10371 0.111549,0.0521 0.219087,0.11058 0.107529,0.0585 0.197098,0.13227 0.08924,0.072 0.152685,0.16376 0.06312,0.09 0.08409,0.20493 0.02129,0.11666 -0.0057,0.21552 -0.02549,0.0973 -0.101385,0.16482 -0.07621,0.0658 -0.205522,0.0965 -0.127547,0.0309 -0.308641,0.0148 -0.08255,-0.007 -0.173051,-0.0289 -0.08834,-0.0197 -0.184569,-0.0636 -0.09481,-0.0456 -0.196668,-0.12042 -0.10011,-0.0747 -0.204225,-0.19029 l 0.128236,-0.12193 q 0.08578,0.1004 0.161283,0.17297 0.07517,0.0708 0.146306,0.11932 0.07255,0.0469 0.144882,0.0736 0.07378,0.0252 0.154667,0.0324 z"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52777767px;font-family:'Lao MN';-inkscape-font-specification:'Lao MN, weight=250';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;stroke-width:0.26458332"
+ id="path6803"
+ inkscape:connector-curvature="0" />
+ <path
+ d="m 66.58839,199.72505 q 0.136427,-0.17184 0.304134,-0.24807 0.167405,-0.0779 0.359037,-0.0609 0.09852,0.009 0.192745,0.061 0.09574,0.0507 0.1728,0.13181 0.07883,0.0813 0.134519,0.18746 0.05539,0.10449 0.07635,0.21943 l 0.241302,1.32261 -0.374497,-0.0333 -0.230034,-1.26085 q -0.03317,-0.18184 -0.134775,-0.28368 -0.101595,-0.10181 -0.235221,-0.11368 -0.0597,-0.005 -0.123037,0.008 -0.06337,0.0129 -0.12538,0.0428 -0.06231,0.0282 -0.121795,0.0719 -0.05805,0.0421 -0.110391,0.0965 l 0.24913,1.36551 -0.374502,-0.0333 -0.489176,-2.68125 0.248151,-0.0809 0.107378,0.01 z"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52777767px;font-family:'Lao MN';-inkscape-font-specification:'Lao MN, weight=250';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;stroke-width:0.26458332"
+ id="path6805"
+ inkscape:connector-curvature="0" />
+ <path
+ d="m 68.33777,199.0417 0.115165,1.60394 q 0.006,0.084 0.03889,0.15955 0.03424,0.0735 0.08691,0.12807 0.05268,0.0546 0.120637,0.0883 0.06779,0.0315 0.142466,0.0315 0.04876,0 0.101669,-0.0273 0.05275,-0.0294 0.100941,-0.0799 0.04973,-0.0503 0.09077,-0.11547 0.04242,-0.0672 0.06747,-0.14275 l -0.118181,-1.64594 h 0.324604 l 0.161895,2.25476 h -0.324604 l -0.0303,-0.42197 q -0.03574,0.0965 -0.09509,0.18264 -0.05783,0.086 -0.129352,0.15115 -0.07015,0.063 -0.148358,0.0987 -0.07654,0.0377 -0.148164,0.0377 -0.106677,0 -0.205085,-0.0546 -0.09856,-0.0567 -0.175441,-0.15115 -0.07689,-0.0945 -0.127078,-0.22045 -0.04883,-0.12805 -0.05923,-0.27292 l -0.115165,-1.60394 z"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52777767px;font-family:'Lao MN';-inkscape-font-specification:'Lao MN, weight=250';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;stroke-width:0.27474275"
+ id="path6807"
+ inkscape:connector-curvature="0" />
+ <path
+ d="m 70.946885,199.62014 -0.03318,0.16962 -0.574464,0.003 -0.305491,1.73997 -0.417755,-0.65495 0.395026,-1.28211 -0.322851,0.044 -0.04936,-0.30039 0.405397,0.0868 0.167541,-0.21154 c 0.06884,-0.0869 -0.06055,-0.23614 -0.0044,-0.32493 0.05762,-0.0898 0.12586,-0.16353 0.204732,-0.22126 0.07912,-0.059 0.166582,-0.0998 0.262379,-0.12251 0.0958,-0.0227 0.193537,-0.0233 0.293236,-0.002 0.08527,0.0182 0.159029,0.0443 0.221498,0.0768 0.06383,0.0321 0.115478,0.0686 0.15498,0.10978 0.03976,0.0399 0.06747,0.0838 0.08312,0.13167 0.01591,0.0466 0.01921,0.0937 0.0098,0.14152 -0.0059,0.03 -0.01661,0.0559 -0.03207,0.0776 -0.01524,0.0203 -0.03346,0.0367 -0.05468,0.0491 -0.02121,0.0124 0.02055,0.14759 -0.0052,0.1512 -0.02574,0.003 -0.117087,-0.12434 -0.143516,-0.13 -0.04685,-0.0101 -0.08096,-0.0276 -0.102582,-0.0514 -0.02034,-0.024 -0.03429,-0.0518 -0.04183,-0.0836 -0.0076,-0.0317 -0.01236,-0.0648 -0.01437,-0.0993 -5.82e-4,-0.0354 -0.0052,-0.0691 -0.01401,-0.10118 -0.0088,-0.0319 -0.02512,-0.0603 -0.04904,-0.0852 -0.02275,-0.0245 -0.05934,-0.0421 -0.109789,-0.0529 -0.03844,-0.008 -0.07681,-0.004 -0.115107,0.0126 -0.03687,0.0157 -0.07098,0.0398 -0.102389,0.0724 -0.0302,0.0328 -0.0567,0.0724 -0.0795,0.11848 -0.02281,0.0462 -0.03924,0.095 -0.04932,0.14653 l -0.09403,0.48058 z"
+ style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52777767px;font-family:'Lao MN';-inkscape-font-specification:'Lao MN, weight=250';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;stroke-width:0.28891245"
+ id="path6809"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="cccccccccscccscccscscscccccscccscc" />
+ </g>
</g>
</svg>
diff --git a/src/ComputerscareRouter.cpp b/src/ComputerscareRouter.cpp
@@ -20,6 +20,7 @@ struct ComputerscareRouter : Module {
enum InputIds {
TRG_INPUT,
ENUMS(INPUT_JACKS, 10),
+ RANDOMIZE_INPUT,
NUM_INPUTS
};
enum OutputIds {
@@ -37,6 +38,7 @@ struct ComputerscareRouter : Module {
SchmittTrigger nextAddressEdit;
SchmittTrigger prevAddressEdit;
SchmittTrigger clockTrigger;
+ SchmittTrigger randomizeTrigger;
int address = 0;
int editAddress = 0;
@@ -239,19 +241,31 @@ ComputerscareRouter() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS)
}
}
}
- void randomize() override;
+ void onRandomize() override {
+ randomizePatchMatrix();
+ }
// For more advanced Module features, read Rack's engine.hpp header file
// - toJson, fromJson: serialization of internal data
// - onSampleRateChange: event triggered by a change of sample rate
// - onReset, onRandomize, onCreate, onDelete: implements special behavior when user clicks these from the context menu
- void makeFarties()
+ void randomizePatchMatrix()
{
+ int randomIndex;
for (int i = 0; i < 10; i++)
{
+ randomIndex = floor(randomUniform()*10);
+
for (int j = 0; j < 10; j++)
- {
- switch_states[editAddress][i][j] = (randomUniform() > 0.5f);
+ {
+ if(j==randomIndex)
+ switch_states[editAddress][j][i] = 1;
+
+ else
+ switch_states[editAddress][j][i]=0;
+
+ //fully randomize everything. a bit intense for its use in patching
+ //switch_states[editAddress][i][j] = (randomUniform() > 0.5f);
}
}
@@ -295,6 +309,9 @@ void ComputerscareRouter::step() {
}
}
+ if(randomizeTrigger.process(inputs[RANDOMIZE_INPUT].value / 2.f)) {
+ randomizePatchMatrix();
+ }
if(nextAddressEdit.process(params[EDIT_PARAM].value) ) {
editAddress = editAddress + 1;
editAddress = editAddress % 16;
@@ -313,7 +330,7 @@ void ComputerscareRouter::step() {
address = address + 1;
address = address % numAddresses;
}
- // get inputs
+
for (int i = 0 ; i < 10 ; i++)
{
input_values[i] = inputs[INPUT_JACKS + i].value;
@@ -351,11 +368,7 @@ struct NumberDisplayWidget3 : TransparentWidget {
{
// Background
NVGcolor backgroundColor = nvgRGB(0x00, 0x00, 0x00);
- // NVGcolor StrokeColor = nvgRGB(0x00, 0x47, 0x7e);
- // nvgBeginPath(vg);
- // nvgRoundedRect(vg, -1.0, -1.0, box.size.x+2, box.size.y+2, 4.0);
- // nvgFillColor(vg, StrokeColor);
- // nvgFill(vg);
+
nvgBeginPath(vg);
nvgRoundedRect(vg, 0.0, 0.0, box.size.x, box.size.y, 4.0);
nvgFillColor(vg, backgroundColor);
@@ -390,25 +403,31 @@ struct ComputerscareRouterWidget : ModuleWidget {
for (int i = 0 ; i < 10 ; i++)
{
addInput(Port::create<InPort>(Vec(3, i * row_spacing + top_row), Port::INPUT, module, ComputerscareRouter::INPUT_JACKS + i));
- addOutput(Port::create<InPort>(Vec(33 + i * column_spacing , top_row + 10 * row_spacing), Port::OUTPUT, module, ComputerscareRouter::OUTPUTS + i));
- for(int j = 0 ; j < 10 ; j++ )
- {
- addParam(ParamWidget::create<LEDButton>(Vec(35 + column_spacing * j, top_row + row_spacing * i), module, ComputerscareRouter::SWITCHES + i + j * 10, 0.0, 1.0, 0.0));
-
- addChild(ModuleLightWidget::create<LargeLight<GreenLight>>(Vec(35 + column_spacing * j +1.4, top_row + row_spacing * i +1.4 ), module, ComputerscareRouter::SWITCH_LIGHTS + i + j * 10));
- addChild(ModuleLightWidget::create<MediumLight<RedLight>>(Vec(35 + column_spacing * j + 4.3, top_row + row_spacing * i + 4.3), module, ComputerscareRouter::SWITCH_LIGHTS + i + j * 10+100));
+ addOutput(Port::create<InPort>(Vec(33 + i * column_spacing , top_row + 10 * row_spacing), Port::OUTPUT, module, ComputerscareRouter::OUTPUTS + i));
+ for(int j = 0 ; j < 10 ; j++ )
+ {
+ addParam(ParamWidget::create<LEDButton>(Vec(35 + column_spacing * j, top_row + row_spacing * i), module, ComputerscareRouter::SWITCHES + i + j * 10, 0.0, 1.0, 0.0));
+
+ addChild(ModuleLightWidget::create<LargeLight<GreenLight>>(Vec(35 + column_spacing * j +1.4, top_row + row_spacing * i +1.4 ), module, ComputerscareRouter::SWITCH_LIGHTS + i + j * 10));
+ addChild(ModuleLightWidget::create<MediumLight<RedLight>>(Vec(35 + column_spacing * j + 4.3, top_row + row_spacing * i + 4.3), module, ComputerscareRouter::SWITCH_LIGHTS + i + j * 10+100));
- }
- }
+ }
+ }
//clock input
- addInput(Port::create<InPort>(Vec(15, 12), Port::INPUT, module, ComputerscareRouter::TRG_INPUT));
- //address button
- addParam(ParamWidget::create<LEDButton>(Vec(19 , 41), module, ComputerscareRouter::MANUAL_CLOCK_PARAM, 0.0, 1.0, 0.0));
+ addInput(Port::create<InPort>(Vec(3, 12), Port::INPUT, module, ComputerscareRouter::TRG_INPUT));
+ //manual clock button
+ addParam(ParamWidget::create<LEDButton>(Vec(7 , 41), module, ComputerscareRouter::MANUAL_CLOCK_PARAM, 0.0, 1.0, 0.0));
+
+ //randomize input
+ addInput(Port::create<InPort>(Vec(270, 0), Port::INPUT, module, ComputerscareRouter::RANDOMIZE_INPUT));
+
+
+ //active step display
NumberDisplayWidget3 *display = new NumberDisplayWidget3();
- display->box.pos = Vec(40,40);
+ display->box.pos = Vec(30,40);
display->box.size = Vec(50, 20);
display->value = &module->address;
addChild(display);
@@ -419,33 +438,29 @@ struct ComputerscareRouterWidget : ModuleWidget {
stepsDisplay->box.size = Vec(50, 20);
stepsDisplay->value = &module->numAddresses;
addChild(stepsDisplay);
-//RoundBlackSnapKnob
+
+ //number-of-steps dial. Discrete - 16 positions
ParamWidget* stepsKnob = ParamWidget::create<LrgKnob>(Vec(108,30), module, ComputerscareRouter::STEPS_PARAM, 1.0f, 16.0f, 2.0f);
- //addParam(ParamWidget::create<RoundBlackSnapKnob>(Vec(128,36), module, ComputerscareRouter::STEPS_PARAM, 1.0f, 16.0f, 2.0f));
addParam(stepsKnob);
+
//editAddress button
addParam(ParamWidget::create<LEDButton>(Vec(227 , 41), module, ComputerscareRouter::EDIT_PARAM, 0.0, 1.0, 0.0));
-//editAddressPrevious button
+
+ //editAddressPrevious button
addParam(ParamWidget::create<LEDButton>(Vec(208 , 41), module, ComputerscareRouter::EDIT_PREV_PARAM, 0.0, 1.0, 0.0));
+
// currently editing step #:
NumberDisplayWidget3 *displayEdit = new NumberDisplayWidget3();
displayEdit->box.pos = Vec(245,40);
displayEdit->box.size = Vec(50, 20);
displayEdit->value = &module->editAddress;
addChild(displayEdit);
-
- //addParam(ParamWidget::create<Davies1900hBlackKnob>(Vec(28, 287), module, ComputerscareRouter::PITCH_PARAM, -3.0, 3.0, 0.0));
-
-
-
}
};
-void ComputerscareRouter::randomize() {
- return;
-}
+
// Specify the Module and ModuleWidget subclass, human-readable
// author name for categorization per plugin, module slug (should never
// change), human-readable module name, and any number of tags
// (found in `include/tags.hpp`) separated by commas.
-Model *modelComputerscareRouter = Model::create<ComputerscareRouter, ComputerscareRouterWidget>("computerscare", "ComputerscareRouter", "Father & Son Router", UTILITY_TAG);
+Model *modelComputerscareRouter = Model::create<ComputerscareRouter, ComputerscareRouterWidget>("computerscare", "computerscare-patch-sequencer", "Father & Son Patch Sequencer", UTILITY_TAG,SEQUENCER_TAG);