Fix line endings and some cleanup
This commit is contained in:
97
Source/SynthVoice.h
Normal file
97
Source/SynthVoice.h
Normal file
@@ -0,0 +1,97 @@
|
||||
#pragma once
|
||||
#include <JuceHeader.h>
|
||||
#include <functional> // <-- for std::function used by WaveShaper
|
||||
#include "NeuralSharedParams.h"
|
||||
#include "BlepOsc.h"
|
||||
|
||||
//==============================================================================
|
||||
// A single polyBLEP oscillator voice with per-voice ADSR, filter ADSR,
|
||||
// flanger (delayline), simple delay, chorus, reverb, distortion, EQ, master.
|
||||
class NeuralSynthVoice : public juce::MPESynthesiserVoice
|
||||
{
|
||||
public:
|
||||
explicit NeuralSynthVoice (NeuralSharedParams& sharedParams);
|
||||
|
||||
// JUCE voice API
|
||||
void prepare (const juce::dsp::ProcessSpec& spec);
|
||||
void renderNextBlock (juce::AudioBuffer<float>& outputBuffer,
|
||||
int startSample, int numSamples) override;
|
||||
|
||||
void noteStarted() override;
|
||||
void noteStopped (bool allowTailOff) override;
|
||||
void notePitchbendChanged() override;
|
||||
|
||||
void notePressureChanged() override {}
|
||||
void noteTimbreChanged() override {}
|
||||
void noteKeyStateChanged() override {}
|
||||
|
||||
// Called from the processor when the GUI waveform param changes
|
||||
void changeWaveform (int wf) { setWaveform (wf); }
|
||||
|
||||
private:
|
||||
void setWaveform (int waveformType);
|
||||
|
||||
//=== Processing chain (without oscillator) ===============================
|
||||
using DelayLine = juce::dsp::DelayLine<float,
|
||||
juce::dsp::DelayLineInterpolationTypes::Linear>;
|
||||
using IIR = juce::dsp::IIR::Filter<float>;
|
||||
using Gain = juce::dsp::Gain<float>;
|
||||
using WaveShaper = juce::dsp::WaveShaper<float, std::function<float(float)>>; // <-- fix
|
||||
using Chorus = juce::dsp::Chorus<float>;
|
||||
using Reverb = juce::dsp::Reverb;
|
||||
using Limiter = juce::dsp::Limiter<float>;
|
||||
|
||||
enum ChainIndex
|
||||
{
|
||||
flangerIndex = 0,
|
||||
delayIndex,
|
||||
chorusIndex,
|
||||
reverbIndex,
|
||||
distortionPreGain,
|
||||
distortionIndex,
|
||||
distortionPostLPF,
|
||||
eqLowIndex,
|
||||
eqMidIndex,
|
||||
eqHighIndex,
|
||||
masterIndex,
|
||||
limiterIndex
|
||||
};
|
||||
|
||||
using Chain = juce::dsp::ProcessorChain<
|
||||
DelayLine, // flanger
|
||||
DelayLine, // simple delay
|
||||
Chorus, // chorus
|
||||
Reverb, // reverb
|
||||
Gain, // distortion pre-gain (drive)
|
||||
WaveShaper, // distortion waveshaper
|
||||
IIR, // tone / post-EQ for distortion
|
||||
IIR, // EQ low
|
||||
IIR, // EQ mid
|
||||
IIR, // EQ high
|
||||
Gain, // master gain
|
||||
Limiter // safety limiter
|
||||
>;
|
||||
|
||||
private:
|
||||
NeuralSharedParams& shared;
|
||||
|
||||
juce::dsp::ProcessSpec spec {};
|
||||
|
||||
// ==== Oscillator (polyBLEP) ============================================
|
||||
BlepOsc osc;
|
||||
std::atomic<int> pendingWaveform {-1}; // set by changeWaveform()
|
||||
|
||||
// ==== Envelopes & Filter ===============================================
|
||||
juce::ADSR adsr;
|
||||
juce::ADSR filterAdsr;
|
||||
juce::dsp::StateVariableTPTFilter<float> svf;
|
||||
|
||||
// ==== Chain (FX, EQ, master, limiter) ==================================
|
||||
Chain chain;
|
||||
|
||||
// ==== Scratch buffer (properly allocated) ===============================
|
||||
juce::AudioBuffer<float> tempBuffer;
|
||||
juce::dsp::AudioBlock<float> tempBlock;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (NeuralSynthVoice)
|
||||
};
|
||||
Reference in New Issue
Block a user