Deluge Firmware 1.4.0
Build date: 2026.11.30
Loading...
Searching...
No Matches
mic_velocity_calibration.h
1/*
2 * Copyright © 2026 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 "dsp/mic_velocity/velocity_map.h"
21#include "gui/ui/ui.h"
22#include "hid/button.h"
23#include <array>
24#include <cstdint>
25
29namespace deluge::gui {
30
31class MicVelocityCalibration final : public UI {
32public:
33 MicVelocityCalibration() { oledShowsUIUnderneath = false; }
34
35 bool opened() override;
36 void focusRegained() override;
37 ActionResult padAction(int32_t x, int32_t y, int32_t velocity) override;
38 ActionResult buttonAction(deluge::hid::Button b, bool on, bool inCardRoutine) override;
39 void modEncoderAction(int32_t whichModEncoder, int32_t offset) override {} // The knobs don't reach the song
40 void modButtonAction(uint8_t whichButton, bool on) override {}
41
42 bool renderMainPads(uint32_t whichRows, RGB image[][kDisplayWidth + kSideBarWidth],
43 uint8_t occupancyMask[][kDisplayWidth + kSideBarWidth], bool drawUndefinedArea) override;
44 bool renderSidebar(uint32_t whichRows, RGB image[][kDisplayWidth + kSideBarWidth],
45 uint8_t occupancyMask[][kDisplayWidth + kSideBarWidth]) override;
46 void renderOLED(deluge::hid::display::oled_canvas::Canvas& canvas) override;
47 UIType getUIType() override { return UIType::MIC_VELOCITY; }
48
50 [[nodiscard]] bool measuresPad(int32_t x, int32_t y) const { return x < kDisplayWidth; }
51
52private:
53 static constexpr int32_t kTapsPerStrength = 2;
54
55 void finishPoint();
56 void leave();
57 void redraw();
58 [[nodiscard]] bool tappingSoft() const { return tap_ < kTapsPerStrength; }
59
60 bool trying_ = false;
61 int32_t point_ = 0; // Which calibration point
62 int32_t tap_ = 0; // Which of its taps: soft ones, then hard
63 std::array<float, kTapsPerStrength> soft_{};
64 std::array<float, kTapsPerStrength> hard_{};
65 deluge::dsp::mic_velocity::Calibration::PointLevels softDb_{};
66 deluge::dsp::mic_velocity::Calibration::PointLevels hardDb_{};
67 deluge::dsp::mic_velocity::Calibration candidate_{};
68
69 // Trying: the last pad pressed and its velocity
70 int8_t tryX_ = -1;
71 int8_t tryY_ = -1;
72 uint8_t tryVelocity_ = 0;
73};
74
75extern MicVelocityCalibration micVelocityCalibration;
76
77} // namespace deluge::gui
78
80using deluge::gui::micVelocityCalibration;
Definition mic_velocity_calibration.h:31
UIType getUIType() override
What type of UI is this? e.g. UIType::ARRANGER.
Definition mic_velocity_calibration.h:47
bool measuresPad(int32_t x, int32_t y) const
Whether a press on (x, y) should be measured: every main pad, while this is open.
Definition mic_velocity_calibration.h:50
This class represents the colour format most used by the Deluge globally.
Definition rgb.h:16
Definition palette.h:4