Deluge Firmware 1.4.0
Build date: 2026.11.30
Loading...
Searching...
No Matches
mic_velocity.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 <cstdint>
22
32namespace deluge::mic_velocity {
33
36[[nodiscard]] bool active();
37
39[[nodiscard]] bool micAvailable();
40
42void setCalibrating(bool calibrating);
43
45[[nodiscard]] float lastPressLevelDb();
46
49void update();
50
52void noteActivity();
53
55 bool wait;
56 uint8_t velocity;
57};
58
60[[nodiscard]] uint32_t now();
61
63PressVelocity velocityForPress(int32_t x, int32_t y, uint32_t arrived);
64
66[[nodiscard]] bool retryDue();
67
69extern bool enabled;
70
73
75[[nodiscard]] bool calibrated();
76[[nodiscard]] dsp::mic_velocity::Calibration const& calibration();
77void setCalibration(dsp::mic_velocity::Calibration const& newCalibration);
78
82enum class SpeakerCalibration : uint8_t { IDLE, LISTENING, FOUND, NOT_FOUND };
83void startSpeakerCalibration();
86[[nodiscard]] SpeakerCalibration speakerCalibration();
88extern int32_t lineOutDelay;
89[[nodiscard]] int32_t lineOutDelayMs();
90
92[[nodiscard]] bool probing();
93int32_t probeSample();
94
97void readSettings();
98void writeSettingsIfChanged();
100void settingsChanged();
101
102} // namespace deluge::mic_velocity
Definition velocity_map.h:43
Definition mic_input.cpp:31
uint32_t now()
The mic's frame clock now, for stamping a press as it arrives.
Definition mic_velocity.cpp:263
bool probing()
For the audio engine's output: whether the speaker calibration's noise is playing,...
Definition mic_velocity.cpp:199
PressVelocity velocityForPress(int32_t x, int32_t y, uint32_t arrived)
A pad press that arrived at frame arrived (from now()). Call it again for the same press after a wait...
Definition mic_velocity.cpp:267
void settingsChanged()
enabled or curve was changed (setCalibration notes it itself)
Definition settings.cpp:118
bool enabled
Enabled in the settings.
Definition mic_velocity.cpp:31
bool active()
Definition mic_velocity.cpp:170
void stopSpeakerCalibration()
Back to IDLE, after a result or to cancel.
Definition mic_velocity.cpp:185
int32_t lineOutDelay
The delay to the speakers on the line outputs (decimated samples), -1 until they've been calibrated (...
Definition mic_velocity.cpp:32
SpeakerCalibration
Definition mic_velocity.h:82
float lastPressLevelDb()
The level (dB of full scale) the last press measured was at: its thump's, or the noise's if it had no...
Definition mic_velocity.cpp:221
void setCalibrating(bool calibrating)
The calibration screen is open: presses are measured whatever the settings, for their levels.
Definition mic_velocity.cpp:216
void noteActivity()
Any pad or button edge: the echo canceller stops learning for a moment, as the press may be thumping.
Definition mic_velocity.cpp:257
dsp::mic_velocity::VelocityCurve curve
How tap strength maps onto velocity (the settings).
Definition mic_velocity.cpp:33
bool calibrated()
The calibration presses are measured against, once there is one.
Definition mic_velocity.cpp:208
void readSettings()
Definition settings.cpp:122
void update()
Definition mic_velocity.cpp:236
bool retryDue()
After a wait: whether it's time to ask about the press again (0.5 ms on). Cheap enough for a schedule...
Definition mic_velocity.cpp:306
bool micAvailable()
Whether the internal mic can be used: nothing in the mic or line-in jacks (either switches it off).
Definition mic_velocity.cpp:212
How tap strength maps onto velocity (the settings).
Definition velocity_map.h:72
Definition mic_velocity.h:54
uint8_t velocity
Otherwise, the velocity to send the press with (1-127).
Definition mic_velocity.h:56
bool wait
The thump is still rising: hand the press back and ask again shortly.
Definition mic_velocity.h:55