Skip to content

Commit

Permalink
sync v1 changes to v2
Browse files Browse the repository at this point in the history
  • Loading branch information
Stubs42 committed Nov 21, 2021
1 parent 385cf03 commit 56e10b3
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 63 deletions.
97 changes: 66 additions & 31 deletions src/Dejavu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,8 @@ struct Dejavu : Module {
setStateJson (DUR_COUNTER_JSON + 1, 0.f);
setStateJson (DUR_COUNTER_JSON + 2, 0.f);
setStateJson (DUR_COUNTER_JSON + 3, 0.f);
setStateJson (GATE_JSON, TRIGGER_MODE);
setStateJson (SH_JSON, 0.f);
setStateJson (GATE_JSON, GATE_OFF);
setStateJson (SH_JSON, SH_OFF);
setStateJson (DIVCOUNTER_JSON, 0.f);
setStateJson (POLY_CHANNELS_JSON, 1.f);
setStateJson (MODULE_STATE_JSON, STATE_ACTIVE);
Expand Down Expand Up @@ -400,12 +400,9 @@ void processOutputChannels() {
if (heat >= gateRandom) {
OL_statePoly[ (NUM_INPUTS + GATE_OUTPUT) * POLY_CHANNELS + channel] = 10.f;
OL_outStateChangePoly[GATE_OUTPUT * POLY_CHANNELS + channel] = true;
if (isGate (GATE_OUTPUT) || OL_isGatePoly[GATE_OUTPUT * POLY_CHANNELS + channel] >= 5.f) {
if (gateActive[channel] == false)
fired = true;
}
else
if (gateActive[channel] == false) {
fired = true;
}
gateActive[channel] = true;
}
else {
Expand All @@ -415,16 +412,28 @@ void processOutputChannels() {
outputs[GATE_OUTPUT].setVoltage (0.f, channel);
gateActive[channel] = false;
}
bool sh = (getStateJson(SH_JSON) == 1.f);
bool sh = false;
if (getStateJson(SH_JSON) == SH_OFF)
sh = true;
if (getStateJson(SH_JSON) == SH_ON && gateActive[channel])
sh = true;
if (getStateJson(SH_JSON) == SH_CONT && fired)
sh = true;
if (getInputConnected(SH_INPUT)) {
float value = lastShValue;
if (channel <= inputs[SH_INPUT].getChannels()) {
value = OL_statePoly[SH_INPUT * POLY_CHANNELS + channel];
}
lastShValue = value;
sh = (value > 5.f);
sh = false;
if (value < SH_ON)
sh = true;
else if (value >= SH_CONT)
sh = fired;
else
sh = gateActive[channel];
}
if (!sh || fired) {
if (sh) {
float scl = getStateParam (SCL_PARAM) / 100.f;
if (getInputConnected (SCL_INPUT)) {
float sclInput = 0.f;
Expand Down Expand Up @@ -622,7 +631,9 @@ void processOutputChannels() {
Module specific process method called from process () in OrangeLineCommon.hpp
*/
inline void moduleProcess (const ProcessArgs &args) {
if (!widgetReady) return; // do not strt processing before the widget is ready
if (!widgetReady) {
return; // do not strt processing before the widget is ready
}
if (styleChanged) {
switch (int(getStateJson(STYLE_JSON))) {
case STYLE_ORANGE:
Expand Down Expand Up @@ -878,11 +889,7 @@ void processOutputChannels() {
*/
inline void moduleProcessState () {
if (inChangeParam (GATE_PARAM)) { // User clicked on tr/gt button
if (getStateJson (GATE_JSON) == 0.f)
setStateJson (GATE_JSON, 1.f);
else {
setStateJson (GATE_JSON, 0.f);
}
setStateJson (GATE_JSON, float((int(getStateJson (GATE_JSON)) + 1) % 3));
}

if (getStateJson (GATE_JSON) > 0.f && !getInputConnected(GATE_INPUT))
Expand All @@ -896,7 +903,7 @@ void processOutputChannels() {
}

if (inChangeParam (SH_PARAM)) {
setStateJson (SH_JSON, float((int(getStateJson (SH_JSON)) + 1) % 2));
setStateJson (SH_JSON, float((int(getStateJson (SH_JSON)) + 1) % 3));
}
}

Expand All @@ -907,20 +914,43 @@ void processOutputChannels() {

if (getInputConnected (GATE_INPUT)) {
int channels = inputs[GATE_INPUT].getChannels();
float lastValue = 0;
int lastValue = 0;
for (int channel = 0; channel < POLY_CHANNELS; channel ++) {
float value;
int value;
if (channel > channels)
value = lastValue;
else {
value = OL_statePoly[GATE_INPUT * POLY_CHANNELS + channel];
value = int(OL_statePoly[GATE_INPUT * POLY_CHANNELS + channel]);
}
if (value < GATE_ON) {
OL_isGatePoly[GATE_OUTPUT * POLY_CHANNELS + channel] = false;
OL_isSteadyGate[GATE_OUTPUT * POLY_CHANNELS + channel] = false;
}
else if (value >= GATE_CONT) {
OL_isGatePoly[GATE_OUTPUT * POLY_CHANNELS + channel] = true;
OL_isSteadyGate[GATE_OUTPUT * POLY_CHANNELS + channel]= true;
}
else {
OL_isGatePoly[GATE_OUTPUT * POLY_CHANNELS + channel] = true;
OL_isSteadyGate[GATE_OUTPUT * POLY_CHANNELS + channel]= false;
}
OL_isGatePoly[GATE_OUTPUT * POLY_CHANNELS + channel] = value;
lastValue = value;
}
} else {
for (int channel = 0; channel < POLY_CHANNELS; channel ++)
OL_isGatePoly[GATE_OUTPUT * POLY_CHANNELS + channel] = 0.f;
for (int channel = 0; channel < POLY_CHANNELS; channel ++) {
if (getStateJson(GATE_JSON) == GATE_OFF) {
OL_isGatePoly[GATE_OUTPUT * POLY_CHANNELS + channel] = false;
OL_isSteadyGate[GATE_OUTPUT * POLY_CHANNELS + channel] = false;
}
else if (getStateJson(GATE_JSON) == GATE_ON) {
OL_isGatePoly[GATE_OUTPUT * POLY_CHANNELS + channel] = true;
OL_isSteadyGate[GATE_OUTPUT * POLY_CHANNELS + channel]= false;
}
else {
OL_isGatePoly[GATE_OUTPUT * POLY_CHANNELS + channel] = true;
OL_isSteadyGate[GATE_OUTPUT * POLY_CHANNELS + channel]= true;
}
}
}

for (int row = 0; row < NUM_ROWS; row++) {
Expand All @@ -935,15 +965,19 @@ void processOutputChannels() {
setRgbLight (REP_LIGHT_RGB + (3 * row), ONOFF_COLOR_OFF);
}

if (getStateJson (GATE_JSON) == 1.)
setRgbLight (GATE_LIGHT_RGB, GATE_COLOR_ON);
else
if (getStateJson (GATE_JSON) == GATE_OFF)
setRgbLight (GATE_LIGHT_RGB, GATE_COLOR_OFF);
if (getStateJson (GATE_JSON) == GATE_ON)
setRgbLight (GATE_LIGHT_RGB, GATE_COLOR_ON);
if (getStateJson (GATE_JSON) == GATE_CONT)
setRgbLight (GATE_LIGHT_RGB, GATE_COLOR_CONT);

if (getStateJson (SH_JSON) == 1.)
setRgbLight (SH_LIGHT_RGB, SH_COLOR_ON);
else
if (getStateJson (SH_JSON) == SH_OFF)
setRgbLight (SH_LIGHT_RGB, SH_COLOR_OFF);
if (getStateJson (SH_JSON) == SH_ON)
setRgbLight (SH_LIGHT_RGB, SH_COLOR_ON);
if (getStateJson (SH_JSON) == SH_CONT)
setRgbLight (SH_LIGHT_RGB, SH_COLOR_CONT);
}
};

Expand Down Expand Up @@ -1020,7 +1054,6 @@ struct LeftWidget : TransparentWidget {
if (paramDisplayCycles > 0) {
module->greetingCycles = 0;
ParamQuantity *pq = module->paramQuantities[param];
// const char *label = pq->label.data();
const char *label = pq->getLabel().c_str();
const char *unit = pq->unit.data();

Expand Down Expand Up @@ -1385,7 +1418,9 @@ struct DejavuWidget : ModuleWidget {
addOutput (createOutputCentered<PJ301MPort> (calculateCoordinates (0, 0, OFFSET_PJ301MPort), module, DEBUG_OUTPUT));
#endif

if (module) module->widgetReady = true;
if (module) {
module->widgetReady = true;
}
}

struct PolyChannelsItem : MenuItem {
Expand Down
15 changes: 11 additions & 4 deletions src/Dejavu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,23 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
#define HEAT_LOW 0.f
#define HEAT_HIGH 10.f

#define GATE_COLOR_ON 0xffff00
#define GATE_COLOR_OFF 0x000000
#define SH_COLOR_ON 0xffff00
#define GATE_COLOR_ON 0xffff00
#define GATE_COLOR_CONT 0xff0000
#define SH_COLOR_OFF 0x000000
#define SH_COLOR_ON 0xffff00
#define SH_COLOR_CONT 0xff0000
#define ONOFF_COLOR_ON 0x00ff00
#define ONOFF_COLOR_OFF 0x000000
#define ONOFF_COLOR_ON_INACTIVE 0x001100

#define GATE_MODE 1
#define TRIGGER_MODE 0
#define GATE_OFF 0
#define GATE_ON 1
#define GATE_CONT 2

#define SH_OFF 0
#define SH_ON 1
#define SH_CONT 2

// DO NOT CHANGE LEN or DUR because they are used in integer calculations !
#define LEN 0
Expand Down
18 changes: 9 additions & 9 deletions src/OrangeLineCommon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ dsp::PulseGenerator *OL_outStateTrigger [NUM_OUTPUTS]; // pulse generator object
bool OL_isGate [NUM_OUTPUTS];
bool OL_wasTriggered [NUM_OUTPUTS]; // remember whether we triggered once at all only set when triggerd but never reset
bool OL_isPoly [NUM_INPUTS + NUM_OUTPUTS];
float OL_isGatePoly [NUM_OUTPUTS * POLY_CHANNELS];
bool OL_isSteadyGate[NUM_OUTPUTS];
bool OL_isGatePoly [NUM_OUTPUTS * POLY_CHANNELS];
bool OL_isSteadyGate[NUM_OUTPUTS * POLY_CHANNELS];
int OL_polyChannels[NUM_OUTPUTS];

/*
Expand Down Expand Up @@ -556,12 +556,12 @@ inline void processActiveOutputTriggers () {
OL_statePoly[NUM_INPUTS * POLY_CHANNELS + cvOutPolyIdx] = 0.f;

bool isGate = OL_isGate[outputIdx];
if (OL_isGatePoly[outputIdx * POLY_CHANNELS + channel] > 5.f)
if (OL_isGatePoly[outputIdx * POLY_CHANNELS + channel])
isGate = true;

if (isGate && OL_wasTriggeredPoly[cvOutPolyIdx]) {
OL_statePoly[NUM_INPUTS * POLY_CHANNELS + cvOutPolyIdx] = 10.f;
if (OL_isSteadyGate[outputIdx])
if (OL_isSteadyGate[outputIdx * POLY_CHANNELS + channel])
trgActive = true;
else
trgActive = !trgActive;
Expand All @@ -583,7 +583,7 @@ inline void processActiveOutputTriggers () {
else
setStateOutput (outputIdx, 0.f);
if (OL_isGate[outputIdx] && OL_wasTriggered[outputIdx]) {
if (OL_isSteadyGate[outputIdx])
if (OL_isSteadyGate[outputIdx * POLY_CHANNELS])
trgActive = true;
else
trgActive = !trgActive;
Expand Down Expand Up @@ -640,10 +640,10 @@ inline void reflectChanges () {
OL_statePoly[NUM_INPUTS * POLY_CHANNELS + cvOutPolyIdx] = 0.f;
}
bool isGate = OL_isGate[outputIdx];
if (OL_isGatePoly[outputIdx * POLY_CHANNELS + channel] > 5.f)
if (OL_isGatePoly[outputIdx * POLY_CHANNELS + channel])
isGate = true;
if (isGate && OL_wasTriggeredPoly[cvOutPolyIdx]) {
if (OL_isSteadyGate[outputIdx])
if (OL_isSteadyGate[outputIdx * POLY_CHANNELS + channel])
trgActive = true;
else
trgActive = !trgActive;
Expand Down Expand Up @@ -671,7 +671,7 @@ inline void reflectChanges () {
else
setStateOutput (outputIdx, 0.f);
if (OL_isGate[outputIdx] && OL_wasTriggered[outputIdx]) {
if (OL_isSteadyGate[outputIdx])
if (OL_isSteadyGate[outputIdx * POLY_CHANNELS])
trgActive = true;
else
trgActive = !trgActive;
Expand Down Expand Up @@ -726,4 +726,4 @@ void onReset () override {
moduleReset ();
styleChanged = true;
OL_initialized = false; // Request initialize
}
}
37 changes: 18 additions & 19 deletions src/Swing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,42 +265,41 @@ struct SwingWidget : ModuleWidget {
addInput (createInputCentered<PJ301MPort> (mm2px (Vec ( 3.89 + 4.2 , 128.5 - 10.559 - 4.2)), module, CLK_INPUT));
addInput (createInputCentered<PJ301MPort> (mm2px (Vec ( 3.89 + 4.2 , 128.5 - 20.242 - 4.2)), module, BPM_INPUT));
addInput (createInputCentered<PJ301MPort> (mm2px (Vec ( 3.89 + 4.2 , 128.5 - 29.926 - 4.2)), module, RST_INPUT));
addParam (createParamCentered<LEDButton> (mm2px (Vec ( 5.712 + 2.38, 128.5 - 41.423 - 2.38)), module, RST_PARAM));
addParam (createParamCentered<LEDButton> (mm2px (Vec ( 5.712 + 2.38, 128.5 - 41.423 - 2.38)), module, RST_PARAM));

addOutput (createOutputCentered<PJ301MPort> (mm2px (Vec (33.419 + 4.2 , 128.5 - 39.61 - 4.2)), module, PHS_OUTPUT));
addOutput (createOutputCentered<PJ301MPort> (mm2px (Vec (33.419 + 4.2 , 128.5 - 29.926 - 4.2)), module, CMP_OUTPUT));
addOutput (createOutputCentered<PJ301MPort> (mm2px (Vec (33.419 + 4.2 , 128.5 - 20.24 - 4.2)), module, ECLK_OUTPUT));
addOutput (createOutputCentered<PJ301MPort> (mm2px (Vec (33.419 + 4.2 , 128.5 - 10.559 - 4.2)), module, TCLK_OUTPUT));

RoundSmallBlackKnob *knob = createParamCentered<RoundSmallBlackKnob> (mm2px (Vec ( 3.141 + 4, 128.5 - 99.019 - 4)), module, DIV_PARAM);
knob->snap = true;
RoundSmallBlackKnob *knob = createParamCentered<RoundSmallBlackKnob> (mm2px (Vec ( 3.141 + 4, 128.5 - 99.019 - 4)), module, DIV_PARAM);
knob->snap = true;
addParam (knob);

pValue = (module != nullptr ? &(module->getStateParam (DIV_PARAM)) : nullptr);
numberWidget = NumberWidget::create (mm2px (Vec(3.65, 128.5 - 110.35)), module, pValue, 0.f, "%2.0f", divBuffer, 2);
pValue = (module != nullptr ? &(module->getStateParam (DIV_PARAM)) : nullptr);
numberWidget = NumberWidget::create (mm2px (Vec(3.65, 128.5 - 110.35)), module, pValue, 0.f, "%2.0f", divBuffer, 2);
numberWidget->pStyle = (module == nullptr ? nullptr : &(module->OL_state[STYLE_JSON]));
addChild (numberWidget);
addChild (numberWidget);

knob = createParamCentered<RoundSmallBlackKnob> (mm2px (Vec (34.576 + 4, 128.5 - 99.019 - 4)), module, LEN_PARAM);
knob->snap = true;
knob = createParamCentered<RoundSmallBlackKnob> (mm2px (Vec (34.576 + 4, 128.5 - 99.019 - 4)), module, LEN_PARAM);
knob->snap = true;
addParam (knob);

pValue = (module != nullptr ? &(module->getStateParam (LEN_PARAM)) : nullptr);
numberWidget = NumberWidget::create (mm2px (Vec(35.2, 128.5 - 110.35)), module, pValue, 0.f, "%2.0f", lenBuffer, 2);
pValue = (module != nullptr ? &(module->getStateParam (LEN_PARAM)) : nullptr);
numberWidget = NumberWidget::create (mm2px (Vec(35.2, 128.5 - 110.35)), module, pValue, 0.f, "%2.0f", lenBuffer, 2);
numberWidget->pStyle = (module == nullptr ? nullptr : &(module->OL_state[STYLE_JSON]));
addChild (numberWidget);
addChild (numberWidget);

addParam (createParamCentered<RoundLargeBlackKnob> (mm2px (Vec (16.51 + 6.35, 128.5 - 102.553 - 6.35)), module, AMT_PARAM));
addParam (createParamCentered<RoundLargeBlackKnob> (mm2px (Vec (16.51 + 6.35, 128.5 - 102.553 - 6.35)), module, AMT_PARAM));

for (int i = 0; i < 16; i ++) {
int x = i % 4;
int y = i / 4;
Vec pos = Vec (3.169 + 4 + x * (13.621 - 3.169), 128.5 - 85.535 - 4 + y * (13.621 - 3.169));
addParam (createParamCentered<RoundSmallBlackKnob> (mm2px (pos), module, TIM_PARAM_01 + i));
for (int i = 0; i < 16; i ++) {
int x = i % 4;
int y = i / 4;
Vec pos = Vec (3.169 + 4 + x * (13.621 - 3.169), 128.5 - 85.535 - 4 + y * (13.621 - 3.169));
addParam (createParamCentered<RoundSmallBlackKnob> (mm2px (pos), module, TIM_PARAM_01 + i));
}

if (module) module->widgetReady = true;
}
}

struct SwingStyleItem : MenuItem {
Swing *module;
Expand Down

0 comments on commit 56e10b3

Please sign in to comment.