#pragma once #include #include "NeuralSharedParams.h" #include /*struct ADSRProcessor : public juce::dsp::ProcessorBase { // ----------------------------------------------------------------- void prepare(const juce::dsp::ProcessSpec& spec) override { adsr.setSampleRate(spec.sampleRate); } void reset() override { adsr.reset(); } void process(const juce::dsp::ProcessContextReplacing &ctx) override { DBG("Processing..."); auto& outputBlock = context.getOutputBlock(); const auto numSamples = (int)outputBlock.getNumSamples(); const auto numChannels = (int)outputBlock.getNumChannels(); // Wrap the outputBlock into AudioBuffer for (int ch = 0; ch < numChannels; ++ch) buffer.setWritePointer(ch, outputBlock.getChannelPointer(ch)); adsr.applyEnvelopeToBuffer(buffer, 0, numSamples); } // ----------------------------------------------------------------- // These two are NOT part of the ProcessorBase interface – they are // your private hooks that the voice will call on note events. void noteOn(const juce::ADSR::Parameters& p) { adsr.setParameters(p); adsr.noteOn(); } void noteOff() { adsr.noteOff(); } private: juce::ADSR adsr; juce::AudioBuffer buffer; };*/ //============================================================================== class NeuralSynthVoice : public juce::MPESynthesiserVoice { public: NeuralSynthVoice(NeuralSharedParams& sp); //============================================================================== void prepare(const juce::dsp::ProcessSpec& spec); //============================================================================== void noteStarted() override; //============================================================================== void notePitchbendChanged() override; //============================================================================== void noteStopped(bool) override; //============================================================================== void notePressureChanged(); void noteTimbreChanged(); void noteKeyStateChanged(); //============================================================================== void renderNextBlock(juce::AudioBuffer& outputBuffer, int startSample, int numSamples); void setWaveform(int waveformType); void changeWaveform(int waveform) noexcept { this->waveform = waveform; } private: //============================================================================== juce::HeapBlock heapBlock; juce::dsp::AudioBlock tempBlock; enum { oscIndex, distortionPreGain, distortionIndex, distortionPostLPF, flangerIndex, chorusIndex, delayIndex, reverbIndex, eqLowIndex, eqMidIndex, eqHighIndex, masterIndex }; juce::dsp::ProcessorChain< juce::dsp::Oscillator, juce::dsp::Gain, juce::dsp::WaveShaper>, juce::dsp::IIR::Filter, juce::dsp::DelayLine, juce::dsp::Chorus, juce::dsp::DelayLine, juce::dsp::Reverb, juce::dsp::IIR::Filter, // Low shelf juce::dsp::IIR::Filter, // Mid peak juce::dsp::IIR::Filter, // High shelf juce::dsp::Gain > processorChain; juce::dsp::ProcessSpec spec; juce::ADSR adsr; NeuralSharedParams& shared; static constexpr size_t lfoUpdateRate = 100; static inline float msToSecs(float ms) { return ms * 0.001f; } std::atomic waveform { -1 }; };