commit aee63f67723ad59006101bb11a62a27770dc099b
parent 4bfcf1158b878956c89bb8378c81c0db634ef5d0
Author: Matt Demanett <matt@demanett.net>
Date: Mon, 20 May 2019 00:56:09 -0400
v1: fix FIXMEs on displays, mostly around null _module, so for the module browser.
Diffstat:
10 files changed, 158 insertions(+), 127 deletions(-)
diff --git a/src/Blank3.cpp b/src/Blank3.cpp
@@ -30,9 +30,9 @@ struct Blank3Display : OpaqueWidget {
}
void draw(const DrawArgs& args) override {
- // FIXME.v1
- if (!_module) {
- return;
+ float level = -1.0f;
+ if (_module) {
+ level = _module->_level;
}
float offsetX = box.size.x / 2.0f;
@@ -44,15 +44,15 @@ struct Blank3Display : OpaqueWidget {
nvgFontSize(args.vg, 54.0f);
nvgFontFaceId(args.vg, _font->handle);
nvgTextLetterSpacing(args.vg, 9.0f);
- if (_module->_level < 0.0f) {
+ if (level < 0.0f) {
nvgFillColor(args.vg, textColor);
nvgText(args.vg, 0, 0, _text, NULL);
}
else {
nvgFillColor(args.vg, bgTextColor);
nvgText(args.vg, 0, 0, _text, NULL);
- if (_module->_level > 0.0001f) {
- nvgFillColor(args.vg, decibelsToColor(amplitudeToDecibels(_module->_level)));
+ if (level > 0.0001f) {
+ nvgFillColor(args.vg, decibelsToColor(amplitudeToDecibels(level)));
nvgText(args.vg, 0, 0, _text, NULL);
}
}
diff --git a/src/Blank6.cpp b/src/Blank6.cpp
@@ -30,9 +30,9 @@ struct Blank6Display : OpaqueWidget {
}
void draw(const DrawArgs& args) override {
- // FIXME.v1
- if (!_module) {
- return;
+ float level = -1.0f;
+ if (_module) {
+ level = _module->_level;
}
float offsetX = box.size.x / 2.0f;
@@ -44,15 +44,15 @@ struct Blank6Display : OpaqueWidget {
nvgFontSize(args.vg, 52.0f);
nvgFontFaceId(args.vg, _font->handle);
nvgTextLetterSpacing(args.vg, 9.0f);
- if (_module->_level < 0.0f) {
+ if (level < 0.0f) {
nvgFillColor(args.vg, textColor);
nvgText(args.vg, 0, 0, _text, NULL);
}
else {
nvgFillColor(args.vg, bgTextColor);
nvgText(args.vg, 0, 0, _text, NULL);
- if (_module->_level > 0.0001f) {
- nvgFillColor(args.vg, decibelsToColor(amplitudeToDecibels(_module->_level)));
+ if (level > 0.0001f) {
+ nvgFillColor(args.vg, decibelsToColor(amplitudeToDecibels(level)));
nvgText(args.vg, 0, 0, _text, NULL);
}
}
diff --git a/src/Pressor.cpp b/src/Pressor.cpp
@@ -147,9 +147,9 @@ struct CompressionDisplay : OpaqueWidget {
}
void draw(const DrawArgs& args) override {
- // FIXME.v1
- if (!_module) {
- return;
+ float compressionDb = 0.0f;
+ if (_module) {
+ compressionDb = _module->_compressionDb;
}
nvgSave(args.vg);
@@ -160,7 +160,7 @@ struct CompressionDisplay : OpaqueWidget {
nvgRect(args.vg, 3, i + 1, 5, 4);
nvgFillColor(args.vg, bgColor);
nvgFill(args.vg);
- if (_module->_compressionDb > l.db) {
+ if (compressionDb > l.db) {
nvgFillColor(args.vg, l.color);
nvgFill(args.vg);
}
diff --git a/src/Reftone.cpp b/src/Reftone.cpp
@@ -59,25 +59,31 @@ struct ReftoneDisplay : TransparentWidget {
};
void ReftoneDisplay::draw(const DrawArgs& args) {
- // FIXME.v1
- if (!_module) {
- return;
+ int mPitch = 9;
+ int mOctave = 4;
+ float mFine = 0.0f;
+ float mFrequency = 440.0f;
+ if (_module) {
+ mPitch = _module->_pitch;
+ mOctave = _module->_octave;
+ mFine = _module->_fine;
+ mFrequency = _module->_frequency;
}
const int n = 20;
char octave[n];
- snprintf(octave, n, "%d", _module->_octave);
+ snprintf(octave, n, "%d", mOctave);
char fine[n];
- fine[0] = _module->_fine < 0.0 ? '-' : '+';
- snprintf(fine + 1, n - 1, "%02d", abs((int)(_module->_fine * 100)));
+ fine[0] = mFine < 0.0 ? '-' : '+';
+ snprintf(fine + 1, n - 1, "%02d", abs((int)(mFine * 100)));
char frequency[20];
- snprintf(frequency, n, _module->_frequency >= 1000.0 ? "%0.0f" : "%0.1f", _module->_frequency);
+ snprintf(frequency, n, mFrequency >= 1000.0 ? "%0.0f" : "%0.1f", mFrequency);
const char* pitch = NULL;
const char* sharpFlat = NULL;
- switch (_module->_pitch) {
+ switch (mPitch) {
case 0: {
pitch = "C";
break;
diff --git a/src/VU.cpp b/src/VU.cpp
@@ -43,19 +43,20 @@ struct VUDisplay : OpaqueWidget {
}
void draw(const DrawArgs& args) override {
- // FIXME.v1
- if (!_module) {
- return;
+ float lDb = 0.0f;
+ float rDb = 0.0f;
+ if (_module) {
+ lDb = _module->_lLevel;
+ rDb = _module->_rLevel;
}
- float lDb = _module->_lLevel;
if (lDb > 0.0f) {
lDb = amplitudeToDecibels(lDb);
}
else {
lDb = -100.0f;
}
- float rDb = _module->_rLevel;
+
if (rDb > 0.0f) {
rDb = amplitudeToDecibels(rDb);
}
diff --git a/src/Walk2.cpp b/src/Walk2.cpp
@@ -165,48 +165,48 @@ struct Walk2Display : TransparentWidget {
}
void draw(const DrawArgs& args) override {
- // FIXME.v1
- if (!_module) {
- return;
- }
-
- switch (_module->_traceColor) {
- case Walk2::ORANGE_TRACE_COLOR: {
- _traceColor = nvgRGBA(0xff, 0x80, 0x00, 0xee);
- break;
- }
- case Walk2::RED_TRACE_COLOR: {
- _traceColor = nvgRGBA(0xff, 0x00, 0x00, 0xee);
- break;
- }
- case Walk2::BLUE_TRACE_COLOR: {
- _traceColor = nvgRGBA(0x00, 0xdd, 0xff, 0xee);
- break;
- }
- case Walk2::GREEN_TRACE_COLOR:
- default: {
- _traceColor = _defaultTraceColor;
- }
- }
-
- drawBackground(args);
float strokeWidth = 2.0f; // FIXME.v1 std::max(1.0f, 3 - gRackScene->zoomWidget->zoom);
+ drawBackground(args);
nvgSave(args.vg);
nvgScissor(args.vg, _insetAround, _insetAround, _drawSize.x / 2, _drawSize.y / 2);
- if (_module->_zoomOut) {
+ if (_module && _module->_zoomOut) {
nvgScale(args.vg, 0.5f, 0.5f);
strokeWidth *= 2.0f;
}
else {
- float tx = 1.0f + (clamp(_module->_offsetX, -5.0f, 5.0f) / 5.0f);
+ float offsetX = _module ? _module->_offsetX : 0.0f;
+ float offsetY = _module ? _module->_offsetY : 0.0f;
+ float tx = 1.0f + (clamp(offsetX, -5.0f, 5.0f) / 5.0f);
tx *= -_drawSize.x / 4;
- float ty = 1.0f - (clamp(_module->_offsetY, -5.0f, 5.0f) / 5.0f);
+ float ty = 1.0f - (clamp(offsetY, -5.0f, 5.0f) / 5.0f);
ty *= -_drawSize.y / 4;
nvgTranslate(args.vg, tx, ty);
}
drawAxes(args, strokeWidth);
- drawTrace(args, _traceColor, _module->_outsX, _module->_outsY);
+
+ if (_module) {
+ switch (_module->_traceColor) {
+ case Walk2::ORANGE_TRACE_COLOR: {
+ _traceColor = nvgRGBA(0xff, 0x80, 0x00, 0xee);
+ break;
+ }
+ case Walk2::RED_TRACE_COLOR: {
+ _traceColor = nvgRGBA(0xff, 0x00, 0x00, 0xee);
+ break;
+ }
+ case Walk2::BLUE_TRACE_COLOR: {
+ _traceColor = nvgRGBA(0x00, 0xdd, 0xff, 0xee);
+ break;
+ }
+ case Walk2::GREEN_TRACE_COLOR:
+ default: {
+ _traceColor = _defaultTraceColor;
+ }
+ }
+ drawTrace(args, _traceColor, _module->_outsX, _module->_outsY);
+ }
+
nvgRestore(args.vg);
}
@@ -265,7 +265,7 @@ struct Walk2Display : TransparentWidget {
nvgLineTo(args.vg, _midX + tick, _midY - y);
nvgStroke(args.vg);
- if (_module->_drawGrid) {
+ if (!_module || _module->_drawGrid) {
for (int j = 1; j <= 10; ++j) {
float y = (j * 0.1f) * 0.5f * _drawSize.y;
@@ -292,7 +292,7 @@ struct Walk2Display : TransparentWidget {
}
}
- if (_module->_drawGrid) {
+ if (!_module || _module->_drawGrid) {
const float tick = shortTick;
{
float x = _midX - _drawSize.x / 4;
diff --git a/src/analyzer_base.cpp b/src/analyzer_base.cpp
@@ -207,26 +207,38 @@ void AnalyzerCore::stepChannel(int channelIndex, Input& input) {
void AnalyzerDisplay::draw(const DrawArgs& args) {
- // FIXME.v1
- if (!_module) {
- return;
+ float rangeMinHz = 0.0f;
+ float rangeMaxHz = 0.0f;
+ float rangeDb = 80.0f;
+ if (_module) {
+ rangeMinHz = _module->_rangeMinHz;
+ rangeMaxHz = _module->_rangeMaxHz;
+ rangeDb = _module->_rangeDb;
+ }
+ else {
+ rangeMaxHz = 0.5f * APP->engine->getSampleRate();
}
drawBackground(args);
+
float strokeWidth = 2.0f; // FIXME.v1 std::max(1.0f, 3 - gRackScene->zoomWidget->zoom);
- _xAxisLogFactor = (_module->_rangeMaxHz - _module->_rangeMinHz) / _module->_rangeMaxHz;
+ _xAxisLogFactor = (rangeMaxHz - rangeMinHz) / rangeMaxHz;
_xAxisLogFactor *= 1.0f - baseXAxisLogFactor;
_xAxisLogFactor = 1.0f - _xAxisLogFactor;
nvgSave(args.vg);
nvgScissor(args.vg, _insetAround, _insetAround, _size.x - _insetAround, _size.y - _insetAround);
- drawHeader(args);
- drawYAxis(args, strokeWidth);
- drawXAxis(args, strokeWidth);
- for (int i = 0; i < _module->_core._nChannels; ++i) {
- ChannelAnalyzer* channel = _module->_core._channels[i];
- if (channel) {
- drawGraph(args, channel->getBins(), channel->_binsN, _channelColors[i % channelColorsN], strokeWidth);
+ if (_module) {
+ drawHeader(args);
+ }
+ drawYAxis(args, strokeWidth, rangeDb);
+ drawXAxis(args, strokeWidth, rangeMinHz, rangeMaxHz);
+ if (_module) {
+ for (int i = 0; i < _module->_core._nChannels; ++i) {
+ ChannelAnalyzer* channel = _module->_core._channels[i];
+ if (channel) {
+ drawGraph(args, channel->getBins(), channel->_binsN, _channelColors[i % channelColorsN], strokeWidth, rangeMinHz, rangeMaxHz, rangeDb);
+ }
}
}
nvgRestore(args.vg);
@@ -275,7 +287,7 @@ void AnalyzerDisplay::drawHeader(const DrawArgs& args) {
nvgRestore(args.vg);
}
-void AnalyzerDisplay::drawYAxis(const DrawArgs& args, float strokeWidth) {
+void AnalyzerDisplay::drawYAxis(const DrawArgs& args, float strokeWidth, float rangeDb) {
nvgSave(args.vg);
nvgStrokeColor(args.vg, _axisColor);
nvgStrokeWidth(args.vg, strokeWidth);
@@ -290,14 +302,14 @@ void AnalyzerDisplay::drawYAxis(const DrawArgs& args, float strokeWidth) {
nvgStroke(args.vg);
nvgBeginPath(args.vg);
- lineY = _insetTop + (_graphSize.y - _graphSize.y*(_module->_rangeDb - _positiveDisplayDB + 12.0)/_module->_rangeDb);
+ lineY = _insetTop + (_graphSize.y - _graphSize.y*(rangeDb - _positiveDisplayDB + 12.0)/rangeDb);
nvgMoveTo(args.vg, lineX, lineY);
nvgLineTo(args.vg, _size.x - _insetRight, lineY);
nvgStroke(args.vg);
drawText(args, "12", textX, lineY + 5.0, textR);
nvgBeginPath(args.vg);
- lineY = _insetTop + (_graphSize.y - _graphSize.y*(_module->_rangeDb - _positiveDisplayDB)/_module->_rangeDb);
+ lineY = _insetTop + (_graphSize.y - _graphSize.y*(rangeDb - _positiveDisplayDB)/rangeDb);
nvgMoveTo(args.vg, lineX, lineY);
nvgLineTo(args.vg, _size.x - _insetRight, lineY);
nvgStrokeWidth(args.vg, strokeWidth * 1.5);
@@ -306,29 +318,29 @@ void AnalyzerDisplay::drawYAxis(const DrawArgs& args, float strokeWidth) {
drawText(args, "0", textX, lineY + 2.3, textR);
nvgBeginPath(args.vg);
- lineY = _insetTop + (_graphSize.y - _graphSize.y*(_module->_rangeDb - _positiveDisplayDB - 12.0)/_module->_rangeDb);
+ lineY = _insetTop + (_graphSize.y - _graphSize.y*(rangeDb - _positiveDisplayDB - 12.0)/rangeDb);
nvgMoveTo(args.vg, lineX, lineY);
nvgLineTo(args.vg, _size.x - _insetRight, lineY);
nvgStroke(args.vg);
drawText(args, "-12", textX, lineY + 10, textR);
nvgBeginPath(args.vg);
- lineY = _insetTop + (_graphSize.y - _graphSize.y*(_module->_rangeDb - _positiveDisplayDB - 24.0)/_module->_rangeDb);
+ lineY = _insetTop + (_graphSize.y - _graphSize.y*(rangeDb - _positiveDisplayDB - 24.0)/rangeDb);
nvgMoveTo(args.vg, lineX, lineY);
nvgLineTo(args.vg, _size.x - _insetRight, lineY);
nvgStroke(args.vg);
drawText(args, "-24", textX, lineY + 10, textR);
nvgBeginPath(args.vg);
- lineY = _insetTop + (_graphSize.y - _graphSize.y*(_module->_rangeDb - _positiveDisplayDB - 48.0)/_module->_rangeDb);
+ lineY = _insetTop + (_graphSize.y - _graphSize.y*(rangeDb - _positiveDisplayDB - 48.0)/rangeDb);
nvgMoveTo(args.vg, lineX, lineY);
nvgLineTo(args.vg, _size.x - _insetRight, lineY);
nvgStroke(args.vg);
drawText(args, "-48", textX, lineY + 10, textR);
- if (_module->_rangeDb > 100.0) {
+ if (rangeDb > 100.0) {
nvgBeginPath(args.vg);
- lineY = _insetTop + (_graphSize.y - _graphSize.y*(_module->_rangeDb - _positiveDisplayDB - 96.0)/_module->_rangeDb);
+ lineY = _insetTop + (_graphSize.y - _graphSize.y*(rangeDb - _positiveDisplayDB - 96.0)/rangeDb);
nvgMoveTo(args.vg, lineX, lineY);
nvgLineTo(args.vg, _size.x - _insetRight, lineY);
nvgStroke(args.vg);
@@ -351,64 +363,64 @@ void AnalyzerDisplay::drawYAxis(const DrawArgs& args, float strokeWidth) {
nvgRestore(args.vg);
}
-void AnalyzerDisplay::drawXAxis(const DrawArgs& args, float strokeWidth) {
+void AnalyzerDisplay::drawXAxis(const DrawArgs& args, float strokeWidth, float rangeMinHz, float rangeMaxHz) {
nvgSave(args.vg);
nvgStrokeColor(args.vg, _axisColor);
nvgStrokeWidth(args.vg, strokeWidth);
float hz = 100.0f;
- while (hz < _module->_rangeMaxHz && hz < 1001.0) {
- if (hz >= _module->_rangeMinHz) {
- drawXAxisLine(args, hz);
+ while (hz < rangeMaxHz && hz < 1001.0) {
+ if (hz >= rangeMinHz) {
+ drawXAxisLine(args, hz, rangeMinHz, rangeMaxHz);
}
hz += 100.0;
}
hz = 2000.0;
- while (hz < _module->_rangeMaxHz && hz < 10001.0) {
- if (hz >= _module->_rangeMinHz) {
- drawXAxisLine(args, hz);
+ while (hz < rangeMaxHz && hz < 10001.0) {
+ if (hz >= rangeMinHz) {
+ drawXAxisLine(args, hz, rangeMinHz, rangeMaxHz);
}
hz += 1000.0;
}
hz = 20000.0;
- while (hz < _module->_rangeMaxHz && hz < 100001.0) {
- if (hz >= _module->_rangeMinHz) {
- drawXAxisLine(args, hz);
+ while (hz < rangeMaxHz && hz < 100001.0) {
+ if (hz >= rangeMinHz) {
+ drawXAxisLine(args, hz, rangeMinHz, rangeMaxHz);
}
hz += 10000.0;
}
drawText(args, "Hz", _insetLeft, _size.y - 2);
- if (_module->_rangeMinHz <= 100.0f) {
- float x = (100.0 - _module->_rangeMinHz) / (_module->_rangeMaxHz - _module->_rangeMinHz);
+ if (rangeMinHz <= 100.0f) {
+ float x = (100.0 - rangeMinHz) / (rangeMaxHz - rangeMinHz);
x = powf(x, _xAxisLogFactor);
if (x < 1.0) {
x *= _graphSize.x;
drawText(args, "100", _insetLeft + x - 8, _size.y - 2);
}
}
- if (_module->_rangeMinHz <= 1000.0f) {
- float x = (1000.0 - _module->_rangeMinHz) / (_module->_rangeMaxHz - _module->_rangeMinHz);
+ if (rangeMinHz <= 1000.0f) {
+ float x = (1000.0 - rangeMinHz) / (rangeMaxHz - rangeMinHz);
x = powf(x, _xAxisLogFactor);
if (x < 1.0) {
x *= _graphSize.x;
drawText(args, "1k", _insetLeft + x - 4, _size.y - 2);
}
}
- if (_module->_rangeMinHz <= 10000.0f) {
- float x = (10000.0 - _module->_rangeMinHz) / (_module->_rangeMaxHz - _module->_rangeMinHz);
+ if (rangeMinHz <= 10000.0f) {
+ float x = (10000.0 - rangeMinHz) / (rangeMaxHz - rangeMinHz);
x = powf(x, _xAxisLogFactor);
if (x < 1.0) {
x *= _graphSize.x;
drawText(args, "10k", _insetLeft + x - 4, _size.y - 2);
}
}
- if (_module->_rangeMinHz > 1000.0f) {
+ if (rangeMinHz > 1000.0f) {
hz = 20000.0f;
float lastX = 0.0f;
- while (hz < _module->_rangeMaxHz) {
- if (_module->_rangeMinHz <= hz) {
- float x = (hz - _module->_rangeMinHz) / (_module->_rangeMaxHz - _module->_rangeMinHz);
+ while (hz < rangeMaxHz) {
+ if (rangeMinHz <= hz) {
+ float x = (hz - rangeMinHz) / (rangeMaxHz - rangeMinHz);
x = powf(x, _xAxisLogFactor);
if (x > lastX + 0.075f && x < 1.0f) {
lastX = x;
@@ -426,8 +438,8 @@ void AnalyzerDisplay::drawXAxis(const DrawArgs& args, float strokeWidth) {
nvgRestore(args.vg);
}
-void AnalyzerDisplay::drawXAxisLine(const DrawArgs& args, float hz) {
- float x = (hz - _module->_rangeMinHz) / (_module->_rangeMaxHz - _module->_rangeMinHz);
+void AnalyzerDisplay::drawXAxisLine(const DrawArgs& args, float hz, float rangeMinHz, float rangeMaxHz) {
+ float x = (hz - rangeMinHz) / (rangeMaxHz - rangeMinHz);
x = powf(x, _xAxisLogFactor);
if (x < 1.0) {
x *= _graphSize.x;
@@ -438,10 +450,19 @@ void AnalyzerDisplay::drawXAxisLine(const DrawArgs& args, float hz) {
}
}
-void AnalyzerDisplay::drawGraph(const DrawArgs& args, const float* bins, int binsN, NVGcolor color, float strokeWidth) {
- float range = (_module->_rangeMaxHz - _module->_rangeMinHz) / (0.5f * APP->engine->getSampleRate());
+void AnalyzerDisplay::drawGraph(
+ const DrawArgs& args,
+ const float* bins,
+ int binsN,
+ NVGcolor color,
+ float strokeWidth,
+ float rangeMinHz,
+ float rangeMaxHz,
+ float rangeDb
+) {
+ float range = (rangeMaxHz - rangeMinHz) / (0.5f * APP->engine->getSampleRate());
int pointsN = roundf(range * (_module->_core.size() / 2));
- range = _module->_rangeMinHz / (0.5f * APP->engine->getSampleRate());
+ range = rangeMinHz / (0.5f * APP->engine->getSampleRate());
int pointsOffset = roundf(range * (_module->_core.size() / 2));
nvgSave(args.vg);
nvgScissor(args.vg, _insetLeft, _insetTop, _graphSize.x, _graphSize.y);
@@ -449,7 +470,7 @@ void AnalyzerDisplay::drawGraph(const DrawArgs& args, const float* bins, int bin
nvgStrokeWidth(args.vg, strokeWidth);
nvgBeginPath(args.vg);
for (int i = 0; i < pointsN; ++i) {
- int height = binValueToHeight(bins[pointsOffset + i]);
+ int height = binValueToHeight(bins[pointsOffset + i], rangeDb);
if (i == 0) {
nvgMoveTo(args.vg, _insetLeft, _insetTop + (_graphSize.y - height));
}
@@ -473,14 +494,14 @@ void AnalyzerDisplay::drawText(const DrawArgs& args, const char* s, float x, flo
nvgRestore(args.vg);
}
-int AnalyzerDisplay::binValueToHeight(float value) {
- const float minDB = -(_module->_rangeDb - _positiveDisplayDB);
+int AnalyzerDisplay::binValueToHeight(float value, float rangeDb) {
+ const float minDB = -(rangeDb - _positiveDisplayDB);
value /= 10.0f; // arbitrarily use 5.0f as reference "maximum" baseline signal (e.g. raw output of an oscillator)...but signals are +/-5, so 10 total.
value = powf(value, 0.5f); // undoing magnitude scaling of levels back from the FFT?
value = amplitudeToDecibels(value);
value = std::max(minDB, value);
value = std::min(_positiveDisplayDB, value);
value -= minDB;
- value /= _module->_rangeDb;
+ value /= rangeDb;
return roundf(_graphSize.y * value);
}
diff --git a/src/analyzer_base.hpp b/src/analyzer_base.hpp
@@ -163,12 +163,12 @@ struct AnalyzerDisplay : TransparentWidget {
void draw(const DrawArgs& args) override;
void drawBackground(const DrawArgs& args);
void drawHeader(const DrawArgs& args);
- void drawYAxis(const DrawArgs& args, float strokeWidth);
- void drawXAxis(const DrawArgs& args, float strokeWidth);
- void drawXAxisLine(const DrawArgs& args, float hz);
- void drawGraph(const DrawArgs& args, const float* bins, int binsN, NVGcolor color, float strokeWidth);
+ void drawYAxis(const DrawArgs& args, float strokeWidth, float rangeDb);
+ void drawXAxis(const DrawArgs& args, float strokeWidth, float rangeMinHz, float rangeMaxHz);
+ void drawXAxisLine(const DrawArgs& args, float hz, float rangeMinHz, float rangeMaxHz);
+ void drawGraph(const DrawArgs& args, const float* bins, int binsN, NVGcolor color, float strokeWidth, float rangeMinHz, float rangeMaxHz, float rangeDb);
void drawText(const DrawArgs& args, const char* s, float x, float y, float rotation = 0.0, const NVGcolor* color = NULL);
- int binValueToHeight(float value);
+ int binValueToHeight(float value, float rangeDb);
};
} // namespace bogaudio
diff --git a/src/lfo_base.hpp b/src/lfo_base.hpp
@@ -83,22 +83,19 @@ struct LFOBaseWidget : ModuleWidget, PitchModeListener {
}
void setSvg() {
- // FIXME.v1
if (_module && !_module->isCompliantPitchMode()) {
_panel->setBackground(APP->window->loadSvg(asset::plugin(pluginInstance, _classicSvgName)));
- // if (_frequencyKnob) {
- // _frequencyKnob->minValue = -8.0f;
- // _frequencyKnob->maxValue = 5.0f;
- // _frequencyKnob->dirty = true;
- // }
+ if (_frequencyKnob && _frequencyKnob->paramQuantity) {
+ _frequencyKnob->paramQuantity->minValue = -8.0f;
+ _frequencyKnob->paramQuantity->maxValue = 5.0f;
+ }
}
else {
_panel->setBackground(APP->window->loadSvg(asset::plugin(pluginInstance, _compliantSvgName)));
- // if (_frequencyKnob) {
- // _frequencyKnob->minValue = -5.0f;
- // _frequencyKnob->maxValue = 8.0f;
- // _frequencyKnob->dirty = true;
- // }
+ if (_frequencyKnob && _frequencyKnob->paramQuantity) {
+ _frequencyKnob->paramQuantity->minValue = -5.0f;
+ _frequencyKnob->paramQuantity->maxValue = 8.0f;
+ }
}
_panel->dirty = true;
}
diff --git a/src/widgets.cpp b/src/widgets.cpp
@@ -147,8 +147,14 @@ NVGcolor bogaudio::decibelsToColor(float db) {
void VUSlider::draw(const DrawArgs& args) {
- if (!paramQuantity) {
- return;
+ float level = 0.0f;
+ if (paramQuantity) {
+ level = paramQuantity->getValue();
+ }
+ else {
+ float minDb = -60.0f;
+ float maxDb = 6.0f;
+ level = fabsf(minDb) / (maxDb - minDb);
}
nvgSave(args.vg);
@@ -164,7 +170,7 @@ void VUSlider::draw(const DrawArgs& args) {
nvgSave(args.vg);
{
- nvgTranslate(args.vg, 0, (box.size.y - 13.0f) * (1.0f - paramQuantity->getValue()));
+ nvgTranslate(args.vg, 0, (box.size.y - 13.0f) * (1.0f - level));
nvgBeginPath(args.vg);
nvgRoundedRect(args.vg, 0, 0, 18, 13, 1.5);
nvgFillColor(args.vg, nvgRGBA(0x77, 0x77, 0x77, 0xff));