Deluge Firmware 1.3.0
Build date: 2026.11.28
Loading...
Searching...
No Matches
voice_note_locks_inline.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// Inline definitions of VoiceNoteLocks' queries that need Sound / ModelStack complete (voice_note_locks.h can't include
21// them: sound.h's includes reach voice.h). Include after sound.h, in the .cpp files that call them.
22
23#include "model/model_stack.h"
24#include "model/voice/voice_note_locks.h"
25#include "modulation/params/param_manager.h"
26#include "modulation/params/param_set.h"
27#include "processing/sound/sound.h"
28
29namespace deluge::voice_note_locks_detail {
30constexpr int32_t kVolumeOff = -2147483648;
31} // namespace deluge::voice_note_locks_detail
32
33// With no locks (the common case) each of these is a test of the lock mask, then exactly what the Sound does itself.
34
35inline bool VoiceNoteLocks::sourceEverActive(ModelStackWithSoundFlags* modelStack, int32_t s) const {
36 if (modelStack->checkSourceEverActive(s)) [[likely]] {
37 return true;
38 }
39 if (!hasAnyOf(kSourceVolumes)) [[likely]] {
40 return false;
41 }
42 return sourceEverActiveLocked(modelStack, s);
43}
44
45inline bool VoiceNoteLocks::sourceActiveCurrently(Sound& sound, int32_t s,
46 ParamManagerForTimeline* paramManager) const {
47 if (!volumeLocked(deluge::modulation::params::LOCAL_OSC_A_VOLUME + s)) [[likely]] {
48 return sound.isSourceActiveCurrently(s, paramManager);
49 }
50 return sourceActiveCurrentlyLocked(sound, s);
51}
52
53inline bool VoiceNoteLocks::oscSyncCurrently(Sound& sound, ParamManagerForTimeline* paramManager) const {
54 if (!hasAnyOf(kOscBVolume)) [[likely]] {
55 return sound.renderingOscillatorSyncCurrently(paramManager);
56 }
57 return oscSyncCurrentlyLocked(sound);
58}
59
60inline bool VoiceNoteLocks::modulatorActive(Sound& sound, int32_t m, ParamManagerForTimeline* paramManager) const {
61 if (!volumeLocked(deluge::modulation::params::LOCAL_MODULATOR_0_VOLUME + m)) [[likely]] {
62 return sound.getSmoothedPatchedParamValue(deluge::modulation::params::LOCAL_MODULATOR_0_VOLUME + m,
63 *paramManager)
64 != deluge::voice_note_locks_detail::kVolumeOff;
65 }
66 return modulatorActiveLocked(sound, m);
67}
68
69inline bool VoiceNoteLocks::noiseEverActive(ParamManager* paramManager) const {
70 if (paramManager->getPatchedParamSet()->params[deluge::modulation::params::LOCAL_NOISE_VOLUME].containsSomething(
71 deluge::voice_note_locks_detail::kVolumeOff)) {
72 return true;
73 }
74 if (!hasAnyOf(kNoiseVolume)) [[likely]] {
75 return false;
76 }
77 return noiseEverActiveLocked();
78}
Definition model_stack.h:282
Definition param_manager.h:156
Definition param_manager.h:45
Definition sound.h:78
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
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 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