Deluge Firmware 1.3.0
Build date: 2025.04.16
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/stereo_sample.h"
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(std::span<StereoSample> 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 StereoSample processOneModFXSample(StereoSample sample, int32_t modFXDelayOffset, int32_t thisModFXDelayDepth,
47 int32_t feedback, int32_t lfoOutput, int32_t lfo2Output);
48 StereoSample processOnePhaserSample(StereoSample sample, int32_t modFXDepth, int32_t feedback, int32_t lfoOutput);
49
50public:
51 ModFXProcessor() {
52 // Mod FX
53 ModFXProcessor::modFXBuffer = nullptr;
54 ModFXProcessor::modFXBufferWriteIndex = 0;
55 memset(allpassMemory, 0, sizeof(allpassMemory));
56 }
57 ~ModFXProcessor() {
58 // Free the mod fx memory
59 if (modFXBuffer) {
60 delugeDealloc(modFXBuffer);
61 }
62 }
63 // Phaser
64 StereoSample phaserMemory{0, 0};
65 StereoSample allpassMemory[kNumAllpassFiltersPhaser];
66 StereoSample* modFXBuffer{nullptr};
67 uint16_t modFXBufferWriteIndex{0};
68 LFO modFXLFO;
69 LFO modFXLFOStereo;
70 void processModFX(std::span<StereoSample> buffer, const ModFXType& modFXType, int32_t modFXRate, int32_t modFXDepth,
71 int32_t* postFXVolume, UnpatchedParamSet* unpatchedParams, bool anySoundComingIn);
72 void resetMemory();
73 void setupBuffer();
74 void disableBuffer();
75 void tickLFO(int32_t numSamples, int32_t phaseIncrement) {
76 // Do Mod FX
77 modFXLFO.tick(numSamples, phaseIncrement);
78 }
79};
80// helper functions for the mod fx types
81namespace modfx {
82deluge::vector<std::string_view> getModNames();
83
84const char* getParamName(ModFXType type, ModFXParam param);
85
86const char* modFXToString(ModFXType type);
87} // 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(std::span< StereoSample > 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
Definition stereo_sample.h:25