commit 128056ee1420134a5b30de31b40556932a4dab23
parent 7403972b7cb42df722ddbf2efb418f96239579f5
Author: Matt Demanett <matt@demanett.net>
Date: Thu, 29 Nov 2018 22:14:15 -0500
ANALYZER* fixes.
Diffstat:
6 files changed, 22 insertions(+), 13 deletions(-)
diff --git a/res-src/AnalyzerXL-src.svg b/res-src/AnalyzerXL-src.svg
@@ -29,7 +29,7 @@
</symbol>
</defs>
- <rect width="100%" height="100%" fill="#222" />
+ <rect width="100%" height="100%" fill="#000" />
<g transform="translate(0 375) rotate(-90)">
<text transform="translate(0 12.5)">ANALYZER-XL</text>
<text transform="translate(0 25.5)">BOGAUDIO</text>
diff --git a/res/AnalyzerXL.svg b/res/AnalyzerXL.svg
Binary files differ.
diff --git a/src/Analyzer.cpp b/src/Analyzer.cpp
@@ -82,7 +82,7 @@ struct AnalyzerWidget : ModuleWidget {
{
auto inset = Vec(10, 25);
auto size = Vec(box.size.x - 2*inset.x, 230);
- auto display = new AnalyzerDisplay(module, size);
+ auto display = new AnalyzerDisplay(module, size, true);
display->box.pos = inset;
display->box.size = size;
addChild(display);
diff --git a/src/AnalyzerXL.cpp b/src/AnalyzerXL.cpp
@@ -226,9 +226,9 @@ struct AnalyzerXLWidget : ModuleWidget {
}
{
- auto inset = Vec(30, 0);
- auto size = Vec(box.size.x - inset.x, 380);
- auto display = new AnalyzerDisplay(module, size);
+ auto inset = Vec(30, 1);
+ auto size = Vec(box.size.x - inset.x - 1, 378);
+ auto display = new AnalyzerDisplay(module, size, false);
display->box.pos = inset;
display->box.size = size;
addChild(display);
@@ -260,7 +260,6 @@ struct AnalyzerXLWidget : ModuleWidget {
assert(a);
menu->addChild(new MenuLabel());
- menu->addChild(new RangeMenuItem(a, "Range: lower 10%", -0.90f));
menu->addChild(new RangeMenuItem(a, "Range: lower 25%", -0.75f));
menu->addChild(new RangeMenuItem(a, "Range: lower 50%", -0.5f));
menu->addChild(new RangeMenuItem(a, "Range: Full", 0.0f));
diff --git a/src/analyzer_base.cpp b/src/analyzer_base.cpp
@@ -205,9 +205,9 @@ void AnalyzerDisplay::draw(NVGcontext* vg) {
drawBackground(vg);
float strokeWidth = std::max(1.0f, 3 - gRackScene->zoomWidget->zoom);
- // _xAxisLogFactor = (_module->_rangeMaxHz - _module->_rangeMinHz) / (0.5f * engineGetSampleRate());
- // _xAxisLogFactor *= 1.0f - baseXAxisLogFactor;
- // _xAxisLogFactor = 1.0f - _xAxisLogFactor;
+ _xAxisLogFactor = (_module->_rangeMaxHz - _module->_rangeMinHz) / _module->_rangeMaxHz;
+ _xAxisLogFactor *= 1.0f - baseXAxisLogFactor;
+ _xAxisLogFactor = 1.0f - _xAxisLogFactor;
nvgSave(vg);
nvgScissor(vg, _insetAround, _insetAround, _size.x - _insetAround, _size.y - _insetAround);
@@ -229,8 +229,10 @@ void AnalyzerDisplay::drawBackground(NVGcontext* vg) {
nvgRect(vg, 0, 0, _size.x, _size.y);
nvgFillColor(vg, nvgRGBA(0x00, 0x00, 0x00, 0xff));
nvgFill(vg);
- nvgStrokeColor(vg, nvgRGBA(0xc0, 0xc0, 0xc0, 0xff));
- nvgStroke(vg);
+ if (_drawInset) {
+ nvgStrokeColor(vg, nvgRGBA(0xc0, 0xc0, 0xc0, 0xff));
+ nvgStroke(vg);
+ }
nvgRestore(vg);
}
@@ -247,13 +249,18 @@ void AnalyzerDisplay::drawHeader(NVGcontext* vg) {
drawText(vg, s, x, _insetTop + textY);
x += n * charPx - 0;
+ int spacing = 3;
+ if (_size.x > 300) {
+ x += 5;
+ spacing = 20;
+ }
for (int i = 0; i < _module->_core._nChannels; ++i) {
ChannelAnalyzer* channel = _module->_core._channels[i];
if (channel) {
snprintf(s, sLen, "%c:%7.1f", 'A' + i, channel->getPeak());
drawText(vg, s, x, _insetTop + textY, 0.0, &_channelColors[i % channelColorsN]);
}
- x += 9 * charPx + 3;
+ x += 9 * charPx + spacing;
}
nvgRestore(vg);
diff --git a/src/analyzer_base.hpp b/src/analyzer_base.hpp
@@ -137,16 +137,19 @@ struct AnalyzerDisplay : TransparentWidget {
AnalyzerBase* _module;
const Vec _size;
const Vec _graphSize;
+ bool _drawInset;
std::shared_ptr<Font> _font;
float _xAxisLogFactor = baseXAxisLogFactor;
AnalyzerDisplay(
AnalyzerBase* module,
- Vec size
+ Vec size,
+ bool drawInset
)
: _module(module)
, _size(size)
, _graphSize(_size.x - _insetLeft - _insetRight, _size.y - _insetTop - _insetBottom)
+ , _drawInset(drawInset)
, _font(Font::load(assetPlugin(plugin, "res/fonts/inconsolata.ttf")))
{
}