Deluge Firmware 1.3.0
Build date: 2025.09.14
Loading...
Searching...
No Matches
volume.h
1/*
2 * Copyright (c) 2014-2023 Synthstrom Audible Limited
3 *
4 * This file is part of The Synthstrom Audible Deluge Firmware.
5 *
6 * The Synthstrom Audible Deluge Firmware is free software: you can redistribute it and/or modify it under the
7 * terms of the GNU General Public License as published by the Free Software Foundation,
8 * either version 3 of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
11 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * See the GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along with this program.
15 * If not, see <https://www.gnu.org/licenses/>.
16 */
17#pragma once
18#include "gui/menu_item/patch_cable_strength/fixed.h"
19#include "processing/engines/audio_engine.h"
20
21namespace deluge::gui::menu_item::sidechain {
22
24public:
25 using Fixed::Fixed;
26 void writeCurrentValue() override {
27 Fixed::writeCurrentValue();
28 AudioEngine::mustUpdateReverbParamsBeforeNextRender = true;
29 }
30
31 bool showColumnLabel() const override { return false; }
32
33 void renderInHorizontalMenu(int32_t startX, int32_t width, int32_t startY, int32_t height) override {
34 oled_canvas::Canvas& image = OLED::main;
35
36 constexpr int32_t barWidth = 26;
37 constexpr int32_t dotsInterval = 4;
38 constexpr int32_t xOffset = 4;
39
40 const int32_t leftPadding = (width - barWidth) / 2;
41 const int32_t minX = startX + leftPadding;
42 const int32_t maxX = minX + barWidth;
43 const int32_t minY = startY + 3;
44 const int32_t maxY = startY + height - 4;
45
46 // Draw the dots at left and right sides
47 for (int32_t y = minY; y <= maxY; y += dotsInterval) {
48 if (y == minY + dotsInterval * 3) {
49 // small offset for better balance
50 y++;
51 }
52 image.drawPixel(minX + xOffset, y);
53 image.drawPixel(maxX - xOffset, y);
54 }
55
56 // Calculate shape height based on value
57 const float normalizedValue = std::abs(getValue()) / 5000.0f;
58 const int32_t barHeight = maxY - minY;
59 const int32_t fillHeight = static_cast<int32_t>(normalizedValue * barHeight);
60
61 const int32_t yOffset = (barHeight - fillHeight) / 2;
62 int32_t yStart, yEnd, y0, y1;
63 if (getValue() >= 0) {
64 // For positive values, draw from top down
65 yStart = minY + yOffset;
66 yEnd = yStart + fillHeight;
67 y0 = yEnd;
68 y1 = yStart;
69 }
70 else {
71 // For negative values, draw from bottom up
72 yEnd = maxY - yOffset;
73 yStart = yEnd - fillHeight;
74 y0 = yStart;
75 y1 = yEnd;
76 }
77
78 // Draw a sidechain level shape
79 image.drawLine(minX + xOffset, y0, maxX - xOffset, y1, true);
80 image.drawVerticalLine(minX + xOffset, yStart, yEnd);
81 image.drawVerticalLine(minX + xOffset + 1, yStart, yEnd);
82 image.drawHorizontalLine(y1 - 1, maxX - xOffset, maxX - 1);
83 image.drawHorizontalLine(y1, maxX - xOffset, maxX - 1);
84 image.drawHorizontalLine(y1 - 1, minX + 1, minX + xOffset + 1);
85 image.drawHorizontalLine(y1, minX + 1, minX + xOffset + 1);
86 }
87};
88
89} // namespace deluge::gui::menu_item::sidechain
bool showColumnLabel() const override
Show a label for the parameter in Horizontal menu.
Definition volume.h:31