Skip to content

Commit

Permalink
Merge pull request #48 from jeremymuller/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
jeremymuller authored Dec 15, 2021
2 parents b94c226 + a58da0e commit 1007c70
Show file tree
Hide file tree
Showing 9 changed files with 110 additions and 73 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
v2.0.2 (12-14-2021)
- Added MCLK override in StochSeq4
- Fixed clock resets in StochSeq and StochSeq4
- Fixed bug in RandRoute multinoulli mode when it's polyphonic
- Updated StochSeq interface

v2.0.1 (12-08-2021)
- Neutrinode node speeds can be extremely slow now
- RandRoute has a multi-bernoulli mode now
Expand Down
Binary file modified docs/StochSeq.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/StochSeq4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"slug": "Sha-Bang-Modules",
"name": "Sha#Bang! Modules",
"version": "2.0.1",
"version": "2.0.2",
"license": "GPL-3.0-only",
"author": "Jeremy Muller",
"authorEmail": "[email protected]",
Expand Down
2 changes: 1 addition & 1 deletion res/StochSeq.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion res/StochSeq4.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 15 additions & 13 deletions src/RandRoute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct RandRoute : Module {

dsp::SchmittTrigger mainTrig;
dsp::BooleanTrigger gateTriggers[16];
int currentGate;
int currentGate[16];
float weightProb = 0.5;
bool outcomes[NUM_OF_OUTPUTS][16] = {};
bool toggle = false;
Expand All @@ -47,53 +47,55 @@ struct RandRoute : Module {

configLight(PURPLE_LIGHT, "Output indicator");

setCurrentGate();
for (int i = 0; i < 16; i++) {
setCurrentGate(i);
}
}

void setCurrentGate() {
void setCurrentGate(int channel) {
int weight = (int)params[WEIGHTING_PARAM].getValue();
weightProb = params[PERCENTAGE_PARAM].getValue();
if (weight < 4) {
if (random::uniform() < weightProb) {
currentGate = weight;
currentGate[channel] = weight;
} else {
int r = static_cast<int>(floor(random::uniform() * 4));
while (r == weight) {
r = static_cast<int>(floor(random::uniform() * 4));
}
currentGate = r;
currentGate[channel] = r;
}
} else {
currentGate = static_cast<int>(floor(random::uniform() * NUM_OF_OUTPUTS));
currentGate[channel] = static_cast<int>(floor(random::uniform() * NUM_OF_OUTPUTS));
}
}

void process(const ProcessArgs &args) override {
int channels = std::max(inputs[GATE_INPUT].getChannels(), 1);
if (inputs[TRIGGER_INPUT].isConnected()) {
if (mainTrig.process(inputs[TRIGGER_INPUT].getVoltage())) {
setCurrentGate();
setCurrentGate(0);
}
for (int i = 0; i < NUM_LIGHTS; i++) {
lights[i].setBrightness((i==currentGate) ? 1.0 : 0.0);
lights[i].setBrightness((i==currentGate[0]) ? 1.0 : 0.0);
}

for (int c = 0; c < channels; c++) {
float in = inputs[GATE_INPUT].getVoltage(c);
outputs[GATES_OUTPUT + currentGate].setVoltage(in, c);
outputs[GATES_OUTPUT + currentGate[c]].setVoltage(in, c);
for (int i = 0; i < 4; i++) {
if (i != currentGate) outputs[GATES_OUTPUT + i].setVoltage(0.0, c);
if (i != currentGate[c]) outputs[GATES_OUTPUT + i].setVoltage(0.0, c);
}
}
} else { // multinoulli gates (1 in -> 4 outs)
for (int c = 0; c < channels; c++) {
bool gate = inputs[GATE_INPUT].getVoltage(c) >= 2.0;
if (gateTriggers[c].process(gate)) {
setCurrentGate();
setCurrentGate(c);
}

for (int i = 0; i < 4; i++) {
bool rollDice = (i == currentGate);
bool rollDice = (i == currentGate[c]);
if (!toggle) {
outcomes[i][c] = rollDice;
} else {
Expand All @@ -104,7 +106,7 @@ struct RandRoute : Module {

outputs[GATES_OUTPUT + i].setVoltage(gateOut ? 10.0 : 0.0, c);

lights[i].setBrightness((i == currentGate) ? 1.0 : 0.0);
lights[i].setBrightness((i == currentGate[c]) ? 1.0 : 0.0);
}
}
}
Expand Down
76 changes: 39 additions & 37 deletions src/StochSeq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ struct StochSeq : Module, Quantize {
if (clockTrig.process(inputs[CLOCK_INPUT].getVoltage())) {
if (resetMode) {
resetMode = false;
resetSeqToEnd();
resetSeq();
}
clockStep();
}
Expand Down Expand Up @@ -245,8 +245,9 @@ struct StochSeq : Module, Quantize {
// pitchVoltage = prob * (2 * spread) - spread;
}

void resetSeqToEnd() {
gateIndex = seqLength-1;
void resetSeq() {
// gateIndex = seqLength-1;
gateIndex = -1;
}

void invert() {
Expand Down Expand Up @@ -605,12 +606,13 @@ struct StochSeqDisplay : Widget {
if (layer == 1) {

// seq position
if (module->gateIndex >= 0) {
if (module->gateIndex >= -1) {
nvgStrokeWidth(args.vg, 2.0);
// nvgStrokeColor(args.vg, nvgRGB(128, 0, 219));
nvgStrokeColor(args.vg, nvgRGB(0, 238, 255));
nvgBeginPath(args.vg);
float x = clamp(module->gateIndex * sliderWidth, 0.0, box.size.x - sliderWidth);
int pos = module->resetMode ? 0 : clamp(module->gateIndex, 0, NUM_OF_SLIDERS);
float x = clamp(pos * sliderWidth, 0.0, box.size.x - sliderWidth);
nvgRect(args.vg, x, 1, sliderWidth, box.size.y - 1);
nvgStroke(args.vg);
}
Expand All @@ -628,8 +630,8 @@ struct StochSeqWidget : ModuleWidget {

StochSeqDisplay *display = new StochSeqDisplay();
display->module = module;
display->box.pos = Vec(7.4, 86.7);
display->box.size = Vec(480, 102.9);
display->box.pos = Vec(7.4, 47.7);
display->box.size = Vec(480, 141.9);
addChild(display);

addChild(createWidget<JeremyScrew>(Vec(25.9, 2)));
Expand Down Expand Up @@ -674,37 +676,37 @@ struct StochSeqWidget : ModuleWidget {

// addChild(createLight<SmallLight<JeremyBlueLight>>(Vec(84, 50), module, StochSeq::BLUE_LIGHT));

for (int i = 0; i < NUM_OF_LIGHTS; i++) {
float x = 196 * i / NUM_OF_LIGHTS + 5;
// for (int i = 0; i < NUM_OF_LIGHTS; i++) {
// float x = 196 * i / NUM_OF_LIGHTS + 5;

float y = ((-std::sin(2.0 * M_PI * i / NUM_OF_LIGHTS) * 0.5 + 0.5) * 50 + 15);
// float x = random::uniform() * 260 + 1;
// float y = random::uniform() * 50 + 15;
// int light = int(random::uniform() * 4);

int light = int(i / (NUM_OF_LIGHTS/4.0));

switch(light) {
case 0:
addChild(createLight<SmallLight<JeremyPurpleLight>>(Vec(x, y), module, StochSeq::LIGHTS + i));
break;
case 1:
addChild(createLight<SmallLight<JeremyBlueLight>>(Vec(x, y), module, StochSeq::LIGHTS + i));
break;
case 2:
addChild(createLight<SmallLight<JeremyAquaLight>>(Vec(x, y), module, StochSeq::LIGHTS + i));
break;
case 3:
addChild(createLight<SmallLight<JeremyRedLight>>(Vec(x, y), module, StochSeq::LIGHTS + i));
break;
}

// if (random::uniform() < 0.5)
// addChild(createLight<SmallLight<JeremyBlueLight>>(Vec(x, y), module, StochSeq::LIGHTS + i));

// addChild(createLight<SmallLight<JeremyBlueLight>>(Vec(84, 50), module, StochSeq::BLUE_LIGHT));

}
// float y = ((-std::sin(2.0 * M_PI * i / NUM_OF_LIGHTS) * 0.5 + 0.5) * 50 + 15);
// // float x = random::uniform() * 260 + 1;
// // float y = random::uniform() * 50 + 15;
// // int light = int(random::uniform() * 4);

// int light = int(i / (NUM_OF_LIGHTS/4.0));

// switch(light) {
// case 0:
// addChild(createLight<SmallLight<JeremyPurpleLight>>(Vec(x, y), module, StochSeq::LIGHTS + i));
// break;
// case 1:
// addChild(createLight<SmallLight<JeremyBlueLight>>(Vec(x, y), module, StochSeq::LIGHTS + i));
// break;
// case 2:
// addChild(createLight<SmallLight<JeremyAquaLight>>(Vec(x, y), module, StochSeq::LIGHTS + i));
// break;
// case 3:
// addChild(createLight<SmallLight<JeremyRedLight>>(Vec(x, y), module, StochSeq::LIGHTS + i));
// break;
// }

// // if (random::uniform() < 0.5)
// // addChild(createLight<SmallLight<JeremyBlueLight>>(Vec(x, y), module, StochSeq::LIGHTS + i));

// // addChild(createLight<SmallLight<JeremyBlueLight>>(Vec(84, 50), module, StochSeq::BLUE_LIGHT));

// }

addChild(createLight<SmallLight<JeremyPurpleLight> >(Vec(241.1 - 3, 343.2 - 3), module, StochSeq::BANG_LIGHTS + 0));
addChild(createLight<SmallLight<JeremyBlueLight> >(Vec(253.7 - 3, 343.2 - 3), module, StochSeq::BANG_LIGHTS + 1));
Expand Down
Loading

0 comments on commit 1007c70

Please sign in to comment.