-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6719460
commit d69f8bc
Showing
7 changed files
with
28,174 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
SLUG = DrumKit | ||
VERSION = 0.5.0 | ||
VERSION = 0.5.1 | ||
|
||
# FLAGS will be passed to both the C and C++ compiler | ||
FLAGS += | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
#include <stdint.h> | ||
|
||
#include "DrumKit.hpp" | ||
#include "dmx.h" | ||
|
||
struct DMXContainer { | ||
float *sample; | ||
unsigned int length; | ||
int current; | ||
}; | ||
|
||
struct DMXContainer dmxsamples[ 12 ] = { | ||
{ (float *)dmx1, dmx1_len, 0 }, | ||
{ (float *)dmx2, dmx2_len, 1 }, | ||
{ (float *)dmx3, dmx3_len, 2 }, | ||
{ (float *)dmx4, dmx4_len, 3 }, | ||
{ (float *)dmx5, dmx5_len, 4 }, | ||
{ (float *)dmx6, dmx6_len, 5 }, | ||
{ (float *)dmx7, dmx7_len, 6 }, | ||
{ (float *)dmx8, dmx8_len, 7 }, | ||
{ (float *)dmx9, dmx9_len, 8 }, | ||
{ (float *)dmx10, dmx10_len, 9 }, | ||
{ (float *)dmx11, dmx11_len, 10 }, | ||
{ (float *)dmx12, dmx12_len, 11 }, | ||
}; | ||
|
||
float dmxnotes[12] = { 0.08, 0.17, 0.25, 0.33, 0.42, 0.5, 0.58, 0.67, 0.75, 0.83, 0.92, 1.0 }; | ||
|
||
|
||
struct DMXContainer *getNote(float current) { | ||
for (int i = 0; i < 12; i++) { | ||
if ((dmxnotes[i] - 0.02) <= current && (dmxnotes[i] + 0.02) >= current) { | ||
return &dmxsamples[i]; | ||
} | ||
} | ||
|
||
return NULL; | ||
} | ||
|
||
struct DMXModule : Module { | ||
enum ParamIds { NUM_PARAMS }; | ||
enum InputIds { NOTE1_INPUT, NUM_INPUTS }; | ||
enum OutputIds { AUDIO1_OUTPUT, NUM_OUTPUTS }; | ||
enum LightIds { NUM_LIGHTS }; | ||
|
||
DMXModule( ) : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) { | ||
currentStep = 0; | ||
last = -1; | ||
} | ||
|
||
void step( ) override; | ||
|
||
uint32_t currentStep; | ||
int last; | ||
}; | ||
|
||
void DMXModule::step( ) { | ||
float in1 = inputs[ NOTE1_INPUT ].value; | ||
struct DMXContainer *note; | ||
|
||
// check the first note | ||
note = getNote(in1); | ||
|
||
if (note == NULL) { | ||
currentStep = 0; | ||
outputs[ AUDIO1_OUTPUT ].value = 0; | ||
last = -1; | ||
} else { | ||
if (last != note->current) { | ||
last = note->current; | ||
currentStep = 0; | ||
} | ||
|
||
if (currentStep >= note->length) { | ||
outputs[ AUDIO1_OUTPUT ].value = 0; | ||
} else { | ||
outputs[ AUDIO1_OUTPUT ].value = note->sample[currentStep]; | ||
currentStep++; | ||
} | ||
} | ||
} | ||
|
||
DMXWidget::DMXWidget( ) { | ||
DMXModule *module = new DMXModule( ); | ||
setModule(module); | ||
box.size = Vec(3 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT); | ||
|
||
{ | ||
SVGPanel *panel = new SVGPanel( ); | ||
panel->box.size = box.size; | ||
panel->setBackground(SVG::load(assetPlugin(plugin, "res/DMX.svg"))); | ||
addChild(panel); | ||
} | ||
|
||
addChild(createScrew<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0))); | ||
addChild(createScrew<ScrewSilver>( | ||
Vec(RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH))); | ||
|
||
addInput(createInput<PJ301MPort>(Vec(10, 45), module, | ||
DMXModule::NOTE1_INPUT)); | ||
addOutput(createOutput<PJ301MPort>(Vec(10, 92), module, | ||
DMXModule::AUDIO1_OUTPUT)); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.