Skip to content

Commit

Permalink
dTrOY copy/paste patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastien-bouffier committed May 1, 2018
1 parent f548eb3 commit 6001cc5
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
RACK_DIR ?= ../..
SLUG = Bidoo
VERSION = 0.6.2
VERSION = 0.6.3
DISTRIBUTABLES += $(wildcard LICENSE*) res

# Static libs
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Bidoo's plugins for [VCVRack](https://vcvrack.com)

<!-- Version and License Badges -->
![Version](https://img.shields.io/badge/version-0.6.2-green.svg?style=flat-square)
![Version](https://img.shields.io/badge/version-0.6.3-green.svg?style=flat-square)
![License](https://img.shields.io/badge/license-BSD3-blue.svg?style=flat-square)
![Language](https://img.shields.io/badge/language-C++-yellow.svg?style=flat-square)

Expand All @@ -13,6 +13,10 @@ You can find information on that plugins pack in the [wiki](https://github.com/s

## Last changes

01/05/2018 :

dTrOY pitch quantize has 2 modes i.e. full quantize (meaning root note added in quantization) or partial (pitch is quantized and root note added on top). You can Copy/Paste patterns via the menu.

16/04/2018 :

0.6.2
Expand Down
75 changes: 72 additions & 3 deletions src/DTROY.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,11 @@ struct DTROY : Module {
int selectedPattern = 0;
int playedPattern = 0;
bool pitchMode = false;
bool pitchQuantizeMode = true;
bool updateFlag = false;
bool first = true;
bool loadedFromJson = false;
int copyPattern = -1;

Pattern patterns[16];

Expand All @@ -355,6 +357,7 @@ struct DTROY : Module {
json_object_set_new(rootJ, "playMode", json_integer(playMode));
json_object_set_new(rootJ, "countMode", json_integer(countMode));
json_object_set_new(rootJ, "pitchMode", json_boolean(pitchMode));
json_object_set_new(rootJ, "pitchQuantizeMode", json_boolean(pitchQuantizeMode));
json_object_set_new(rootJ, "selectedPattern", json_integer(selectedPattern));
json_object_set_new(rootJ, "playedPattern", json_integer(playedPattern));

Expand Down Expand Up @@ -579,20 +582,22 @@ struct DTROY : Module {
float closestDist = 10.0f;
int octaveInVolts = int(voltsIn);
for (int i = 0; i < notesInScale; i++) {
float scaleNoteInVolts = octaveInVolts + ((rootNote + curScaleArr[i]) / 12.0f);
float scaleNoteInVolts = octaveInVolts + (((pitchQuantizeMode ? rootNote : 0.0f) + curScaleArr[i]) / 12.0f);
float distAway = fabs(voltsIn - scaleNoteInVolts);
if(distAway < closestDist){
if(distAway < closestDist) {
closestVal = scaleNoteInVolts;
closestDist = distAway;
}
}
closestVal += pitchQuantizeMode ? 0.0f : (rootNote / 12.0f);
return closestVal;
}
};


void DTROY::step() {
const float lightLambda = 0.075f;

// Run
if (runningTrigger.process(params[RUN_PARAM].value)) {
running = !running;
Expand Down Expand Up @@ -995,6 +1000,17 @@ struct DTROYPitchModeItem : MenuItem {
}
};

struct DTROYPitchQuantizeModeItem : MenuItem {
DTROY *dtroyModule;
void onAction(EventAction &e) override {
dtroyModule->pitchQuantizeMode = !dtroyModule->pitchQuantizeMode;
}
void step() override {
rightText = dtroyModule->pitchQuantizeMode ? "" : "";
MenuItem::step();
}
};

struct DisconnectMenuItem : MenuItem {
ModuleWidget *moduleWidget;
void onAction(EventAction &e) override {
Expand Down Expand Up @@ -1047,6 +1063,40 @@ struct DeleteMenuItem : MenuItem {
}
};

struct DTROYCopyItem : MenuItem {
DTROY *dtroyModule;
void onAction(EventAction &e) override {
dtroyModule->copyPattern = dtroyModule->selectedPattern;
}
};

struct DTROYPasteItem : MenuItem {
DTROY *dtroyModule;
DTROYWidget *dtroyWidget;
void onAction(EventAction &e) override {
if (dtroyModule && dtroyWidget && (dtroyModule->copyPattern != dtroyModule->selectedPattern) && dtroyModule->updateFlag)
{
dtroyModule->updateFlag = false;
dtroyWidget->stepsParam->setValue(dtroyModule->patterns[dtroyModule->copyPattern].numberOfStepsParam);
dtroyWidget->rootNoteParam->setValue(dtroyModule->patterns[dtroyModule->copyPattern].rootNote);
dtroyWidget->scaleParam->setValue(dtroyModule->patterns[dtroyModule->copyPattern].scale);
dtroyWidget->gateTimeParam->setValue(dtroyModule->patterns[dtroyModule->copyPattern].gateTime);
dtroyWidget->slideTimeParam->setValue(dtroyModule->patterns[dtroyModule->copyPattern].slideTime);
dtroyWidget->sensitivityParam->setValue(dtroyModule->patterns[dtroyModule->copyPattern].sensitivity);
dtroyModule->playMode = dtroyModule->patterns[dtroyModule->copyPattern].playMode;
dtroyModule->countMode = dtroyModule->patterns[dtroyModule->copyPattern].countMode;
for (int i = 0; i < 8; i++) {
dtroyWidget->pitchParams[i]->setValue(dtroyModule->patterns[dtroyModule->copyPattern].steps[i].pitch);
dtroyWidget->pulseParams[i]->setValue(dtroyModule->patterns[dtroyModule->copyPattern].steps[i].pulsesParam);
dtroyWidget->typeParams[i]->setValue(dtroyModule->patterns[dtroyModule->copyPattern].steps[i].type);
dtroyModule->skipState[i] = dtroyModule->patterns[dtroyModule->copyPattern].steps[i].skipParam ? 't' : 'f';
dtroyModule->slideState[i] = dtroyModule->patterns[dtroyModule->copyPattern].steps[i].slide ? 't' : 'f';
}
dtroyModule->updateFlag = true;
}
}
};

Menu *DTROYWidget::createContextMenu() {
DTROYWidget *dtroyWidget = dynamic_cast<DTROYWidget*>(this);
assert(dtroyWidget);
Expand Down Expand Up @@ -1105,11 +1155,30 @@ Menu *DTROYWidget::createContextMenu() {
MenuLabel *spacerLabel2 = new MenuLabel();
menu->addChild(spacerLabel2);

DTROYCopyItem *copyItem = new DTROYCopyItem();
copyItem->text = "Copy pattern";
copyItem->dtroyModule = dtroyModule;
menu->addChild(copyItem);

DTROYPasteItem *pasteItem = new DTROYPasteItem();
pasteItem->text = "Paste pattern";
pasteItem->dtroyModule = dtroyModule;
pasteItem->dtroyWidget = dtroyWidget;
menu->addChild(pasteItem);

MenuLabel *spacerLabel3 = new MenuLabel();
menu->addChild(spacerLabel3);

DTROYPitchModeItem *pitchModeItem = new DTROYPitchModeItem();
pitchModeItem->text = "Pitch mode continuous/triggered";
pitchModeItem->text = "Pitch mode continuous (vs. triggered)";
pitchModeItem->dtroyModule = dtroyModule;
menu->addChild(pitchModeItem);

DTROYPitchQuantizeModeItem *pitchQuantizeModeItem = new DTROYPitchQuantizeModeItem();
pitchQuantizeModeItem->text = "Pitch full quantize";
pitchQuantizeModeItem->dtroyModule = dtroyModule;
menu->addChild(pitchQuantizeModeItem);

return menu;
}

Expand Down

0 comments on commit 6001cc5

Please sign in to comment.