Deluge Firmware 1.3.0
Build date: 2025.04.16
Loading...
Searching...
No Matches
chord_library.h
1/*
2 * Copyright © 2016-2024 Synthstrom Audible Limited
3 * Copyright © 2024 Madeline Scyphers
4 *
5 * This file is part of The Synthstrom Audible Deluge Firmware.
6 *
7 * The Synthstrom Audible Deluge Firmware is free software: you can redistribute it and/or modify it under the
8 * terms of the GNU General Public License as published by the Free Software Foundation,
9 * either version 3 of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along with this program.
16 * If not, see <https://www.gnu.org/licenses/>.
17 */
18
19#pragma once
20
21#include "definitions.h"
22#include "gui/ui/keyboard/chords.h"
23#include "gui/ui/keyboard/layout/column_controls.h"
24#include <array>
25
26namespace deluge::gui::ui::keyboard::layout {
27
28constexpr int8_t kVerticalPages = ((kUniqueChords + kDisplayHeight - 1) / kDisplayHeight); // Round up division
29
31class KeyboardLayoutChordLibrary : public ColumnControlsKeyboard {
32public:
33 KeyboardLayoutChordLibrary() = default;
34 ~KeyboardLayoutChordLibrary() override = default;
35
36 void evaluatePads(PressedPad presses[kMaxNumKeyboardPadPresses]) override;
37 void handleVerticalEncoder(int32_t offset) override;
38 void handleHorizontalEncoder(int32_t offset, bool shiftEnabled, PressedPad presses[kMaxNumKeyboardPadPresses],
39 bool encoderPressed = false) override;
40 void precalculate() override;
41
42 void renderPads(RGB image[][kDisplayWidth + kSideBarWidth]) override;
43
44 l10n::String name() override { return l10n::String::STRING_FOR_KEYBOARD_LAYOUT_CHORD_LIBRARY; }
45 bool supportsInstrument() override { return true; }
46 bool supportsKit() override { return false; }
47
48protected:
49 bool allowSidebarType(ColumnControlFunction sidebarType) override;
50
51private:
52 void drawChordName(int16_t noteCode, const char* chordName = "", const char* voicingName = "");
53 inline uint8_t noteFromCoords(int32_t x) { return getState().chordLibrary.noteOffset + x; }
54 inline int32_t getChordNo(int32_t y) { return getState().chordLibrary.chordList.chordRowOffset + y; }
55
56 std::array<RGB, kOctaveSize> noteColours;
57 std::array<RGB, kVerticalPages> pageColours;
58 bool initializedNoteOffset = false;
59};
60
61}; // namespace deluge::gui::ui::keyboard::layout
This class represents the colour format most used by the Deluge globally.
Definition rgb.h:14
void handleVerticalEncoder(int32_t offset) override
Shift state not supplied since that function is already taken.
Definition chord_library.cpp:60
void handleHorizontalEncoder(int32_t offset, bool shiftEnabled, PressedPad presses[kMaxNumKeyboardPadPresses], bool encoderPressed=false) override
Will be called with offset 0 to recalculate bounds on clip changes.
Definition chord_library.cpp:70
bool supportsInstrument() override
This currently includes Synth, MIDI and CV.
Definition chord_library.h:45
void precalculate() override
This function is called on visibility change and if colour offset changes.
Definition chord_library.cpp:96
void renderPads(RGB image[][kDisplayWidth+kSideBarWidth]) override
Handle output.
Definition chord_library.cpp:116
void evaluatePads(PressedPad presses[kMaxNumKeyboardPadPresses]) override
Handle input pad presses.
Definition chord_library.cpp:33
Definition notes_state.h:31