Deluge Firmware 1.3.0
Build date: 2025.09.14
Loading...
Searching...
No Matches
stutterer.h
1/*
2 * Copyright © 2016-2024 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/delay/delay_buffer.h"
21#include <cstdint>
22#include <span>
23
25class ParamManager;
26
28 bool useSongStutter = true;
29 bool quantized = true;
30 bool reversed = false;
31 bool pingPong = false;
32};
33
34class Stutterer {
35public:
36 Stutterer() = default;
37 static void initParams(ParamManager* paramManager);
38 inline bool isStuttering(void* source) { return stutterSource == source; }
39 // These calls are slightly awkward with the magniture & timePerTickInverse, but that's the price for not depending
40 // on currentSong and playbackhandler...
41 [[nodiscard]] Error beginStutter(void* source, ParamManagerForTimeline* paramManager, StutterConfig stutterConfig,
42 int32_t magnitude, uint32_t timePerTickInverse);
43 void processStutter(deluge::dsp::StereoBuffer<q31_t> audio, ParamManager* paramManager, int32_t magnitude,
44 uint32_t timePerTickInverse);
45 void endStutter(ParamManagerForTimeline* paramManager = nullptr);
46
47private:
48 enum class Status {
49 OFF,
50 RECORDING,
51 PLAYING,
52 };
53 int32_t getStutterRate(ParamManager* paramManager, int32_t magnitude, uint32_t timePerTickInverse);
54 bool currentReverse;
56 Status status = Status::OFF;
57 // TODO: This is currently unused! It's set to 7 initially, and never modified. Either we should set it depending
58 // on sync, or get rid of it entirely.
59 uint8_t sync = 7;
60 StutterConfig stutterConfig;
61 int32_t sizeLeftUntilRecordFinished = 0;
62 int32_t valueBeforeStuttering = 0;
63 int32_t lastQuantizedKnobDiff = 0;
66 void* stutterSource = nullptr;
67};
68
69// There's only one stutter effect active at a time, so we have a global stutterer to save memory.
70extern Stutterer stutterer;
Definition param_manager.h:174
Definition param_manager.h:45
Definition stutterer.h:34
void * stutterSource
Definition stutterer.h:66
Definition delay_buffer.h:29
Definition stutterer.h:27