Deluge Firmware 1.3.0
Build date: 2026.11.28
Loading...
Searching...
No Matches
voice_note_locks.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 "model/note/note_locks.h"
21#include "modulation/params/param.h"
22#include <cstdint>
23
25class ParamManager;
27class Sound;
28
36public:
38 uint16_t liveEditTag{0};
39
42 bool takePending();
45 [[nodiscard]] static bool pendingTurnsOnASource(Sound& sound);
46
47 // The queries below are inline (definitions in voice_note_locks_inline.h, which needs Sound complete): with no
48 // locks, the common case, each is a test of the lock mask and then exactly the call the Sound makes without locks.
49 // The lock-dependent logic is in the out-of-line ...Locked functions.
50
53 [[nodiscard]] bool giveSustain(Sound& sound, ParamManagerForTimeline* paramManager) const {
54 if (!hasAnyOf(kEnvelope0Tail)) [[likely]] {
55 return false;
56 }
57 return giveSustainLocked(sound, paramManager);
58 }
59
61 [[nodiscard]] inline bool sourceEverActive(ModelStackWithSoundFlags* modelStack, int32_t s) const;
63 [[nodiscard]] inline bool sourceActiveCurrently(Sound& sound, int32_t s,
64 ParamManagerForTimeline* paramManager) const;
66 [[nodiscard]] inline bool oscSyncCurrently(Sound& sound, ParamManagerForTimeline* paramManager) const;
68 [[nodiscard]] inline bool modulatorActive(Sound& sound, int32_t m, ParamManagerForTimeline* paramManager) const;
70 [[nodiscard]] inline bool noiseEverActive(ParamManager* paramManager) const;
71
72 // Some per-voice params are also gated at Sound level on the knob value (is the filter on, is pan applied per
73 // voice): locks on these have to open the gate for their voice (Sound::render).
74 static constexpr uint64_t kPan = deluge::note_locks::paramMask(deluge::modulation::params::LOCAL_PAN);
76 static constexpr uint64_t kStereo = kPan
77 | deluge::note_locks::paramMask(deluge::modulation::params::LOCAL_OSC_A_VOLUME,
78 deluge::modulation::params::LOCAL_OSC_B_VOLUME);
79 static constexpr uint64_t kLPF = deluge::note_locks::paramMask(deluge::modulation::params::LOCAL_LPF_FREQ,
80 deluge::modulation::params::LOCAL_LPF_MORPH);
81 static constexpr uint64_t kHPF = deluge::note_locks::paramMask(deluge::modulation::params::LOCAL_HPF_FREQ,
82 deluge::modulation::params::LOCAL_HPF_MORPH);
83
84private:
87 [[nodiscard]] bool volumeLocked(int32_t param) const {
88 static_assert(deluge::modulation::params::FIRST_LOCAL_NON_VOLUME <= 32);
89 return ((static_cast<uint32_t>(mask()) >> param) & 1) != 0;
90 }
91
92 static constexpr uint64_t kEnvelope0Tail = deluge::note_locks::paramMask(
93 deluge::modulation::params::LOCAL_ENV_0_SUSTAIN, deluge::modulation::params::LOCAL_ENV_0_DECAY,
94 deluge::modulation::params::LOCAL_ENV_0_RELEASE);
95 static constexpr uint64_t kOscBVolume =
96 deluge::note_locks::paramMask(deluge::modulation::params::LOCAL_OSC_B_VOLUME);
97 static constexpr uint64_t kSourceVolumes = deluge::note_locks::paramMask(
98 deluge::modulation::params::LOCAL_OSC_A_VOLUME, deluge::modulation::params::LOCAL_OSC_B_VOLUME);
99 static constexpr uint64_t kNoiseVolume =
100 deluge::note_locks::paramMask(deluge::modulation::params::LOCAL_NOISE_VOLUME);
101
102 [[gnu::cold, gnu::noinline]] bool giveSustainLocked(Sound& sound, ParamManagerForTimeline* paramManager) const;
103 [[gnu::cold, gnu::noinline]] bool sourceEverActiveLocked(ModelStackWithSoundFlags* modelStack,
104 int32_t s) const; // some source volume is locked
105 [[gnu::cold, gnu::noinline]] bool sourceActiveCurrentlyLocked(Sound& sound, int32_t s) const;
106 [[gnu::cold, gnu::noinline]] bool oscSyncCurrentlyLocked(Sound& sound) const;
107 [[gnu::cold, gnu::noinline]] bool modulatorActiveLocked(Sound& sound, int32_t m) const;
108 // Only called with a lock on the param asked about
109 [[gnu::cold, gnu::noinline]] bool noiseEverActiveLocked() const;
110};
Definition model_stack.h:282
Definition param_manager.h:156
Definition param_manager.h:45
Definition sound.h:78
Definition voice_note_locks.h:35
bool giveSustain(Sound &sound, ParamManagerForTimeline *paramManager) const
Definition voice_note_locks.h:53
bool noiseEverActive(ParamManager *paramManager) const
The noise volume is ever above -inf, from its knob / automation or a lock.
Definition voice_note_locks_inline.h:69
static bool pendingTurnsOnASource(Sound &sound)
Definition voice_note_locks.cpp:59
uint16_t liveEditTag
note_locks::LiveEdit::tag of the held pad whose uncommitted lock edits this voice was started with,...
Definition voice_note_locks.h:38
static constexpr uint64_t kStereo
Sound::renderingVoicesInStereo only looks for stereo samples in the sources the knob values have on.
Definition voice_note_locks.h:76
bool oscSyncCurrently(Sound &sound, ParamManagerForTimeline *paramManager) const
Sound::renderingOscillatorSyncCurrently, with a lock on osc B's volume in place of its knob value.
Definition voice_note_locks_inline.h:53
bool volumeLocked(int32_t param) const
Definition voice_note_locks.h:87
bool takePending()
Definition voice_note_locks.cpp:47
bool sourceEverActive(ModelStackWithSoundFlags *modelStack, int32_t s) const
Definition voice_note_locks_inline.h:35
bool modulatorActive(Sound &sound, int32_t m, ParamManagerForTimeline *paramManager) const
The FM modulator's volume is above -inf, from a lock if there is one, else its knob value.
Definition voice_note_locks_inline.h:60
bool sourceActiveCurrently(Sound &sound, int32_t s, ParamManagerForTimeline *paramManager) const
Sound::isSourceActiveCurrently, with a lock on the source's volume in place of its knob value.
Definition voice_note_locks_inline.h:45
Definition note_locks.h:63
uint64_t mask() const
Bit p set if param p is locked.
Definition note_locks.h:72
constexpr uint64_t paramMask(Params... params)
A bit per param, as LockSet::mask() has them.
Definition note_locks.h:55