Deluge Firmware 1.3.0
Build date: 2025.09.12
Loading...
Searching...
No Matches
ModFXProcessor.h
1/*
2 * Copyright © 2024 Mark Adams
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#pragma once
18
19#include "definitions_cxx.hpp"
20#include "dsp_ng/core/types.hpp"
21#include "modulation/lfo.h"
22#include "util/containers.h"
23#include <cstdint>
24#include <span>
25
26class ModFXProcessor {
27
28 void setupChorus(const ModFXType& modFXType, int32_t modFXDepth, int32_t* postFXVolume,
29 UnpatchedParamSet* unpatchedParams, LFOType& modFXLFOWaveType, int32_t& modFXDelayOffset,
30 int32_t& thisModFXDelayDepth) const;
31
33 void setupModFXWFeedback(const ModFXType& modFXType, int32_t modFXDepth, int32_t* postFXVolume,
34 UnpatchedParamSet* unpatchedParams, LFOType& modFXLFOWaveType, int32_t& modFXDelayOffset,
35 int32_t& thisModFXDelayDepth, int32_t& feedback) const;
36 // not grain!
37 template <ModFXType modFXType>
38 void processModFXBuffer(deluge::dsp::StereoBuffer<q31_t> buffer, int32_t modFXRate, int32_t modFXDepth,
39 LFOType& modFXLFOWaveType, int32_t modFXDelayOffset, int32_t thisModFXDelayDepth,
40 int32_t feedback, bool stereo);
41
42 template <ModFXType modFXType>
43 std::pair<int32_t, int32_t> processModLFOs(int32_t modFXRate, LFOType modFXLFOWaveType);
44
45 template <ModFXType modFXType, bool stereo>
46 deluge::dsp::StereoSample<q31_t> processOneModFXSample(deluge::dsp::StereoSample<q31_t> sample,
47 int32_t modFXDelayOffset, int32_t thisModFXDelayDepth,
48 int32_t feedback, int32_t lfoOutput, int32_t lfo2Output);
49 deluge::dsp::StereoSample<q31_t> processOnePhaserSample(deluge::dsp::StereoSample<q31_t> sample, int32_t modFXDepth,
50 int32_t feedback, int32_t lfoOutput);
51
52public:
53 ModFXProcessor() {
54 // Mod FX
55 ModFXProcessor::modFXBuffer = nullptr;
56 ModFXProcessor::modFXBufferWriteIndex = 0;
57 memset(allpassMemory, 0, sizeof(allpassMemory));
58 }
59 ~ModFXProcessor() {
60 // Free the mod fx memory
61 if (modFXBuffer) {
62 delugeDealloc(modFXBuffer);
63 }
64 }
65 // Phaser
66 deluge::dsp::StereoSample<q31_t> phaserMemory{0, 0};
67 deluge::dsp::StereoSample<q31_t> allpassMemory[kNumAllpassFiltersPhaser];
68 deluge::dsp::StereoSample<q31_t>* modFXBuffer{nullptr};
69 uint16_t modFXBufferWriteIndex{0};
70 LFO modFXLFO;
71 LFO modFXLFOStereo;
72 void processModFX(deluge::dsp::StereoBuffer<q31_t> buffer, const ModFXType& modFXType, int32_t modFXRate,
73 int32_t modFXDepth, int32_t* postFXVolume, UnpatchedParamSet* unpatchedParams,
74 bool anySoundComingIn);
75 void resetMemory();
76 void setupBuffer();
77 void disableBuffer();
78 void tickLFO(int32_t numSamples, int32_t phaseIncrement) {
79 // Do Mod FX
80 modFXLFO.tick(numSamples, phaseIncrement);
81 }
82};
83// helper functions for the mod fx types
84namespace modfx {
85deluge::vector<std::string_view> getModNames();
86
87const char* getParamName(ModFXType type, ModFXParam param, bool shortName = false);
88
89const char* modFXToString(ModFXType type);
90} // namespace modfx
Definition lfo.h:35
void setupModFXWFeedback(const ModFXType &modFXType, int32_t modFXDepth, int32_t *postFXVolume, UnpatchedParamSet *unpatchedParams, LFOType &modFXLFOWaveType, int32_t &modFXDelayOffset, int32_t &thisModFXDelayDepth, int32_t &feedback) const
flanger, phaser, warble - generally any modulated delay tap based effect with feedback
Definition ModFXProcessor.cpp:100
void processModFX(deluge::dsp::StereoBuffer< q31_t > buffer, const ModFXType &modFXType, int32_t modFXRate, int32_t modFXDepth, int32_t *postFXVolume, UnpatchedParamSet *unpatchedParams, bool anySoundComingIn)
NOT GRAIN! - this only does the comb filter based mod fx.
Definition ModFXProcessor.cpp:28
Definition param_set.h:98