Deluge Firmware 1.4.0
Build date: 2026.11.30
Loading...
Searching...
No Matches
velocity_map.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 <array>
21#include <cstdint>
22
31
32struct GridPoint {
33 int8_t x;
34 int8_t y;
35};
36
38constexpr int32_t kNumCalibrationPoints = 5;
39constexpr std::array<GridPoint, kNumCalibrationPoints> kCalibrationPoints{{{7, 4}, {0, 7}, {15, 7}, {0, 0}, {15, 0}}};
40
43class Calibration {
44public:
46 static constexpr int32_t kWidth = 18;
47 static constexpr int32_t kHeight = 8;
48 using PointLevels = std::array<float, kNumCalibrationPoints>;
49
50 Calibration() = default;
51 Calibration(PointLevels const& softDb, PointLevels const& hardDb);
52
54 [[nodiscard]] PointLevels const& softDb() const { return softDb_; }
55 [[nodiscard]] PointLevels const& hardDb() const { return hardDb_; }
56
58 [[nodiscard]] float softAt(int32_t x, int32_t y) const { return softAt_[clampY(y)][clampX(x)]; }
59 [[nodiscard]] float hardAt(int32_t x, int32_t y) const { return hardAt_[clampY(y)][clampX(x)]; }
60
61private:
62 static int32_t clampX(int32_t x) { return x < 0 ? 0 : (x >= kWidth ? kWidth - 1 : x); }
63 static int32_t clampY(int32_t y) { return y < 0 ? 0 : (y >= kHeight ? kHeight - 1 : y); }
64
65 PointLevels softDb_{};
66 PointLevels hardDb_{};
67 std::array<std::array<float, kWidth>, kHeight> softAt_{};
68 std::array<std::array<float, kWidth>, kHeight> hardAt_{};
69};
70
73 static constexpr int32_t kMinShape = -50;
74 static constexpr int32_t kMaxShape = 50;
75
76 uint8_t minVelocity = 20;
77 uint8_t maxVelocity = 127;
80 int8_t shape = 25;
81};
82
84[[nodiscard]] uint8_t velocityFor(Calibration const& calibration, VelocityCurve const& curve, int32_t x, int32_t y,
85 float levelDb);
86
88enum class TapCheck : uint8_t {
89 OK,
93};
94
96constexpr float kMaxTapSpreadDb = 6.f;
97constexpr float kMinRangeDb = 6.f;
98
100TapCheck checkPoint(std::array<float, 2> const& softDb, std::array<float, 2> const& hardDb, float* softOut,
101 float* hardOut);
102
103} // namespace deluge::dsp::mic_velocity
Definition velocity_map.h:43
float softAt(int32_t x, int32_t y) const
A pad's soft and hard levels: the points' weighted by closeness (exact on one).
Definition velocity_map.h:58
static constexpr int32_t kWidth
Every pad, the sidebar included (the audition pads are its right-hand column).
Definition velocity_map.h:46
PointLevels const & softDb() const
The calibrated points' levels (what's saved).
Definition velocity_map.h:54
Definition delay_finder.cpp:21
constexpr int32_t kNumCalibrationPoints
The pads calibrated, in the order they're tapped.
Definition velocity_map.h:38
TapCheck checkPoint(std::array< float, 2 > const &softDb, std::array< float, 2 > const &hardDb, float *softOut, float *hardOut)
Checks a point's taps and, if they're fine, gives its soft and hard levels (each the mean of its two,...
Definition velocity_map.cpp:67
constexpr float kMaxTapSpreadDb
Two taps of the same strength have to come within this of each other, and hard has to beat soft by th...
Definition velocity_map.h:96
uint8_t velocityFor(Calibration const &calibration, VelocityCurve const &curve, int32_t x, int32_t y, float levelDb)
The velocity (1-127) a thump of levelDb plays at on pad (x, y).
Definition velocity_map.cpp:54
TapCheck
Checking a calibration point's taps (two soft, two hard).
Definition velocity_map.h:88
@ TOO_CLOSE
Soft and hard came out too alike: the whole point again.
Definition velocity_map.h:92
@ SOFT_UNEVEN
The two soft taps are too far apart: tap soft again.
Definition velocity_map.h:90
@ HARD_UNEVEN
The two hard taps are too far apart: tap hard again.
Definition velocity_map.h:91
Definition velocity_map.h:32
How tap strength maps onto velocity (the settings).
Definition velocity_map.h:72
uint8_t minVelocity
What the softest calibrated tap (and anything softer) plays at.
Definition velocity_map.h:76
uint8_t maxVelocity
Definition velocity_map.h:77
int8_t shape
Definition velocity_map.h:80