Deluge Firmware 1.3.0
Build date: 2026.11.28
Loading...
Searching...
No Matches
audio_recorder.h
1/*
2 * Copyright © 2016-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
18#pragma once
19
20#include "definitions_cxx.hpp"
21#include "gui/ui/ui.h"
22#include "hid/button.h"
23#include <array>
24
25extern "C" {
26#include "fatfs/ff.h"
27}
28
29class SampleRecorder;
30
31class AudioRecorder final : public UI {
32public:
33 AudioRecorder();
34 bool opened() override;
35 bool getGreyoutColsAndRows(uint32_t* cols, uint32_t* rows) override;
36
37 ActionResult buttonAction(deluge::hid::Button b, bool on, bool inCardRoutine) override;
38 bool beginOutputRecording(AudioRecordingFolder folder = AudioRecordingFolder::RESAMPLE,
39 AudioInputChannel channel = AudioInputChannel::OUTPUT, bool writeLoopPoints = false,
40 bool shouldNormalize = true);
41 void process();
42 void slowRoutine();
43 bool isCurrentlyResampling();
44
45 AudioInputChannel recordingSource;
46
47 SampleRecorder* recorder;
48
49 void endRecordingSoon(int32_t buttonLatency = 0);
50
51 void renderOLED(deluge::hid::display::oled_canvas::Canvas& canvas) override;
52 bool isThresholdRecording();
53 void graphicsRoutine() override;
54
55 bool updatedRecordingStatus = false;
56
57 // ui
58 UIType getUIType() override { return UIType::AUDIO_RECORDER; }
59
60private:
61 // Everything that can change the threshold meter's appearance while recording, so graphicsRoutine() only
62 // requests a redraw when the rendered image would actually change
64 std::array<int32_t, 2> levelEndX{};
65 bool recording = false;
66 // record dot while recording, threshold line while waiting
67 bool blinkOn = false;
68 bool operator==(const ThresholdMeterState&) const = default;
69 };
70 ThresholdMeterState getThresholdMeterState();
71 ThresholdMeterState lastRenderedThresholdMeterState{};
72
73 // whether process() has a recorder state change to act on
74 bool recorderNeedsAttention();
75 void finishRecording();
76 bool setupRecordingToFile(AudioInputChannel newMode, int32_t newNumChannels, AudioRecordingFolder folderID,
77 bool writeLoopPoints = false, bool shouldNormalize = true);
78};
79
80extern AudioRecorder audioRecorder;
Definition audio_recorder.h:31
UIType getUIType() override
What type of UI is this? e.g. UIType::ARRANGER.
Definition audio_recorder.h:58
Definition sample_recorder.h:53
Definition audio_recorder.h:63