Deluge Firmware
1.3.0
Build date: 2026.11.28
Toggle main menu visibility
Loading...
Searching...
No Matches
envelope.h
1
/*
2
* Copyright © 2014-2023 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 "definitions_cxx.hpp"
21
#include "modulation/envelope_curve.h"
22
#include <cstdint>
23
24
class
Sound
;
25
class
Voice
;
26
class
ParamManagerForTimeline
;
27
constexpr
uint32_t SOFT_CULL_INCREMENT = 65536;
28
31
class
Envelope {
32
public
:
33
static
constexpr
uint32_t kStageLength = 8388608;
// 2^23
35
static
constexpr
uint32_t
kAhdHoldSpeedup
= 8;
36
37
Envelope();
38
39
uint32_t pos;
40
EnvelopeStage state;
// You may not set this directly, even from this class. Call setState()
41
float
lastValue;
42
float
lastValuePreCurrentStage;
43
uint32_t timeEnteredState;
44
bool
ignoredNoteOff;
45
uint32_t fastReleaseIncrement{1024};
47
int32_t
noteOn
(
bool
directlyToDecay, int32_t sustain,
48
deluge::modulation::EnvelopeMode mode = deluge::modulation::EnvelopeMode::ADSR);
49
int32_t
noteOn
(uint8_t envelopeIndex,
Sound
* sound,
Voice
* voice);
50
void
noteOff(uint8_t envelopeIndex,
Sound
* sound,
ParamManagerForTimeline
* paramManager,
const
Voice
* voice);
53
int32_t
render
(uint32_t numSamples, uint32_t attack, uint32_t decay, uint32_t sustain, uint32_t release,
54
const
deluge::modulation::EnvelopeConfig
& config, int32_t followInput = 0);
55
void
unconditionalRelease(EnvelopeStage typeOfRelease = EnvelopeStage::RELEASE,
56
uint32_t newFastReleaseIncrement = SOFT_CULL_INCREMENT);
57
void
unconditionalOff();
58
void
resumeAttack(
float
oldLastValue,
const
deluge::modulation::EnvelopeConfig
& config);
59
void
resetTimeEntered
();
60
61
private
:
62
int32_t follow(uint32_t numSamples, uint32_t attack, uint32_t sustain, uint32_t release,
63
const
deluge::modulation::EnvelopeShape
& shape, int32_t followInput);
64
void
setState(EnvelopeStage newState);
65
float
smoothedSustain{0};
66
};
Envelope::kAhdHoldSpeedup
static constexpr uint32_t kAhdHoldSpeedup
AHD's hold runs this much faster than a decay stage at the same param value.
Definition
envelope.h:35
Envelope::render
int32_t render(uint32_t numSamples, uint32_t attack, uint32_t decay, uint32_t sustain, uint32_t release, const deluge::modulation::EnvelopeConfig &config, int32_t followInput=0)
Definition
envelope.cpp:50
Envelope::resetTimeEntered
void resetTimeEntered()
resets time to give drone notes a lower likelihood of being culled, since they'll stay in sustain as ...
Definition
envelope.cpp:231
Envelope::noteOn
int32_t noteOn(bool directlyToDecay, int32_t sustain, deluge::modulation::EnvelopeMode mode=deluge::modulation::EnvelopeMode::ADSR)
sustain is the level the smoothed sustain starts from
Definition
envelope.cpp:194
ParamManagerForTimeline
Definition
param_manager.h:156
Sound
Definition
sound.h:78
Voice
Definition
voice.h:36
deluge::modulation::EnvelopeConfig
A sound's settings for one of its envelopes. Not a param: it doesn't vary per clip and can't be modul...
Definition
envelope_curve.h:138
deluge::modulation::EnvelopeShape
The shape of each stage of an envelope.
Definition
envelope_curve.h:89