Deluge Firmware 1.3.0
Build date: 2025.09.14
Loading...
Searching...
No Matches
audio_recorder.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/l10n/l10n.h"
19#include "gui/menu_item/menu_item.h"
20#include "gui/ui/audio_recorder.h"
21#include "gui/ui/sound_editor.h"
22#include "gui/ui_timer_manager.h"
23#include "processing/sound/sound.h"
24
25namespace deluge::gui::menu_item::osc {
26class AudioRecorder final : public MenuItem, FormattedTitle {
27public:
28 AudioRecorder(l10n::String newName, uint8_t sourceId)
29 : MenuItem(newName), FormattedTitle(newName, sourceId + 1), source_id_{sourceId} {}
30
31 [[nodiscard]] std::string_view getTitle() const override { return FormattedTitle::title(); }
32 [[nodiscard]] std::string_view getName() const override { return FormattedTitle::title(); }
33
34 void beginSession(MenuItem* navigatedBackwardFrom) override {
35 soundEditor.shouldGoUpOneLevelOnBegin = true;
36 soundEditor.setCurrentSource(source_id_);
37
38 if (bool success = openUI(&audioRecorder); !success) {
39 if (getCurrentUI() == &soundEditor) {
40 soundEditor.goUpOneLevel();
41 }
42 return uiTimerManager.unsetTimer(TimerName::SHORTCUT_BLINK);
43 }
44
45 audioRecorder.process();
46 }
47
48 bool isRelevant(ModControllableAudio* modControllable, int32_t) override {
49 const auto sound = static_cast<Sound*>(modControllable);
50 return sound->getSynthMode() == SynthMode::SUBTRACTIVE;
51 }
52
53 MenuPermission checkPermissionToBeginSession(ModControllableAudio* modControllable, int32_t,
54 ::MultiRange** currentRange) override {
55 if (!isRelevant(modControllable, source_id_)) {
56 display->displayPopup(l10n::get(l10n::String::STRING_FOR_CANT_RECORD_AUDIO_FM_MODE));
57 return MenuPermission::NO;
58 }
59
60 Sound* sound = static_cast<Sound*>(modControllable);
61 return soundEditor.checkPermissionToBeginSessionForRangeSpecificParam(sound, source_id_, currentRange);
62 }
63
64 [[nodiscard]] bool allowToBeginSessionFromHorizontalMenu() override { return true; }
65 [[nodiscard]] int32_t getColumnSpan() const override { return 2; }
66 [[nodiscard]] bool showColumnLabel() const override { return false; }
67 [[nodiscard]] bool showNotification() const override { return false; }
68
69 void renderInHorizontalMenu(int32_t startX, int32_t width, int32_t startY, int32_t height) override {
70 using namespace hid::display;
71 oled_canvas::Canvas& image = OLED::main;
72
73 // Draw record icon
74 int32_t x = startX + 5;
75 int32_t y = startY + 5;
76 const Icon& recIcon = OLED::recordIcon;
77 image.drawIcon(recIcon, x, y);
78
79 // Draw a "rec" string nearby
80 x += recIcon.width + 3;
81 y += 3;
82 image.drawString("rec", x, y, kTextSpacingX, kTextSpacingY);
83
84 // Draw the arrow icon next
85 x += kTextSpacingX * 3 + 3;
86 image.drawGraphicMultiLine(OLED::submenuArrowIconBold, x, y, 7);
87
88 // Draw a big source number
89 x = startX + width - kTextBigSpacingX - 3;
90 y = startY + 6;
91 DEF_STACK_STRING_BUF(sourceNumberBuf, kShortStringBufferSize);
92 sourceNumberBuf.appendInt(source_id_ + 1);
93 image.drawString(sourceNumberBuf.data(), x, y, kTextBigSpacingX, kTextBigSizeY);
94 }
95
96private:
97 uint8_t source_id_;
98};
99} // namespace deluge::gui::menu_item::osc
Definition mod_controllable_audio.h:47
Definition sound.h:71
Definition multi_range.h:24
bool allowToBeginSessionFromHorizontalMenu() override
Allow entering menu session by selecting the menu item twice in Horizontal menu.
Definition audio_recorder.h:64
int32_t getColumnSpan() const override
Get the number of occupied virtual columns in Horizontal menu.
Definition audio_recorder.h:65
bool showColumnLabel() const override
Show a label for the parameter in Horizontal menu.
Definition audio_recorder.h:66
void beginSession(MenuItem *navigatedBackwardFrom) override
Begin an editing session with this menu item.
Definition audio_recorder.h:34
bool showNotification() const override
Show a popup with the full name and value of the editing parameter at the top of Horizontal menu.
Definition audio_recorder.h:67
bool isRelevant(ModControllableAudio *modControllable, int32_t) override
Check if this MenuItem should show up in a containing deluge::gui::menu_item::Submenu.
Definition audio_recorder.h:48
std::string_view getName() const override
Get the actual name for use on OLED for deluge::gui::menu_item::Submenu s.
Definition audio_recorder.h:32
std::string_view getTitle() const override
Get the title to be used when rendering on OLED, both as a deluge::gui::menu_item::Submenu and when d...
Definition audio_recorder.h:31