Deluge Firmware 1.3.0
Build date: 2025.11.26
Loading...
Searching...
No Matches
portamento.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 "deluge/modulation/params/param.h"
19#include "gui/menu_item/unpatched_param.h"
20#include "gui/ui/sound_editor.h"
21#include "hid/display/oled.h"
22
23namespace deluge::gui::menu_item::voice {
24class Portamento final : public UnpatchedParam {
25public:
26 using UnpatchedParam::UnpatchedParam;
27
28 Portamento(l10n::String newName) : UnpatchedParam(newName, deluge::modulation::params::UNPATCHED_PORTAMENTO) {}
29
30 void getColumnLabel(StringBuf& label) override {
31 label.append(deluge::l10n::get(l10n::String::STRING_FOR_PORTAMENTO_SHORT));
32 }
33
34 void renderInHorizontalMenu(const SlotPosition& slot) override {
35 using namespace deluge::hid::display;
36 oled_canvas::Canvas& image = OLED::main;
37
38 constexpr uint8_t porta_graphics_width = 25;
39 const uint8_t center_x = slot.start_x + slot.width / 2;
40 const uint8_t porta_start_x = slot.start_x + 2;
41 const uint8_t porta_end_x = porta_start_x + porta_graphics_width - 1;
42
43 constexpr uint8_t porta_graphics_height = 11;
44 const uint8_t porta_start_y = slot.start_y + kHorizontalMenuSlotYOffset - 1;
45 const uint8_t porta_end_y = porta_start_y + porta_graphics_height - 1;
46
47 const float norm = normalize(getValue());
48 constexpr uint8_t porta_line_width = 9;
49 const uint8_t porta_x0 = std::lerp(center_x, center_x - porta_line_width, norm);
50 const uint8_t porta_x1 = std::lerp(center_x, center_x + porta_line_width, norm);
51
52 if (porta_x0 == porta_x1) {
53 for (uint8_t y = porta_start_y; y <= porta_end_y; y += 2) {
54 image.drawPixel(porta_x0, y);
55 }
56 }
57 else {
58 image.drawLine(porta_x0, porta_end_y, porta_x1, porta_start_y);
59 }
60
61 constexpr uint8_t max_note_width = 6;
62 constexpr uint8_t note_offset = 2;
63 const uint8_t lower_note_start_x = std::max<uint8_t>(porta_start_x, porta_x0 - note_offset - max_note_width);
64 const uint8_t higher_note_end_x = std::min<uint8_t>(porta_end_x, porta_x1 + note_offset + max_note_width);
65
66 image.drawHorizontalLine(porta_end_y, lower_note_start_x, porta_x0 - note_offset);
67 image.drawHorizontalLine(porta_end_y - 1, lower_note_start_x, porta_x0 - note_offset);
68 image.drawHorizontalLine(porta_start_y, porta_x1 + note_offset, higher_note_end_x);
69 image.drawHorizontalLine(porta_start_y + 1, porta_x1 + note_offset, higher_note_end_x);
70 }
71};
72
73} // namespace deluge::gui::menu_item::voice
Definition d_stringbuf.h:16
Definition menu_item.h:33