Initial plugin version
This commit is contained in:
100
Source/SynthVoice.h
Normal file
100
Source/SynthVoice.h
Normal file
@@ -0,0 +1,100 @@
|
||||
#pragma once
|
||||
|
||||
#include <JuceHeader.h>
|
||||
#include "NeuralSharedParams.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
/*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<float> &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 <20> 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<float> 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<float>& outputBuffer, int startSample, int numSamples);
|
||||
|
||||
void setWaveform(int waveformType);
|
||||
|
||||
void changeWaveform(int waveform) noexcept {
|
||||
this->waveform = waveform;
|
||||
}
|
||||
|
||||
private:
|
||||
//==============================================================================
|
||||
juce::HeapBlock<char> heapBlock;
|
||||
juce::dsp::AudioBlock<float> tempBlock;
|
||||
|
||||
enum
|
||||
{
|
||||
synthIndex
|
||||
};
|
||||
|
||||
juce::dsp::ProcessorChain<
|
||||
juce::dsp::Oscillator<float>
|
||||
> processorChain;
|
||||
|
||||
juce::ADSR adsr;
|
||||
NeuralSharedParams& shared;
|
||||
|
||||
static constexpr size_t lfoUpdateRate = 100;
|
||||
|
||||
static inline float msToSecs(float ms) { return ms * 0.001f; }
|
||||
|
||||
std::atomic<int> waveform { -1 };
|
||||
};
|
||||
Reference in New Issue
Block a user