Skip to content

Commit

Permalink
Randomize could create crash
Browse files Browse the repository at this point in the history
  • Loading branch information
kockie69 committed Dec 1, 2021
1 parent d0b6c8a commit b0a7384
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/ctrl/WaveformSwitch.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,19 @@ inline void WaveformSwitch::onButton(const event::Button& e) {
}

void WaveformSwitch::drawLayer(const DrawArgs& args,int layer) {
if (layer ==1)
::rack::ParamWidget::draw(args);
ParamWidget::drawLayer(args,layer);
}
if (layer ==1)
::rack::ParamWidget::draw(args);
ParamWidget::drawLayer(args,layer);
}

WaveCell* WaveformSwitch::getCell(int index) {
return cells[index];
}

void WaveformSwitch::step() {
float fval = SqHelper::getValue(this);
int val = int(std::round(fval));
//int val = int(std::round(fval));
int val = int(std::floor(fval));
if (val != currentValue) {
//DEBUG("step found new value %d old=%d\n", val, currentValue);
if (currentValue >= 0) {
Expand All @@ -104,9 +105,11 @@ void WaveformSwitch::step() {
}
}
auto cell = getCell(val);
cell->setState(true);
currentValue = val;
fw->dirty = true;
if (cell) {
cell->setState(true);
currentValue = val;
fw->dirty = true;
}
}
ParamWidget::step();
}
Expand Down

0 comments on commit b0a7384

Please sign in to comment.