43 lines
1.3 KiB
C++
43 lines
1.3 KiB
C++
#pragma once
|
|
|
|
#include "SynthVoice.h"
|
|
#include <JuceHeader.h>
|
|
|
|
class NeuralAudioEngine : public juce::MPESynthesiser
|
|
{
|
|
public:
|
|
static constexpr auto maxNumVoices = 4;
|
|
|
|
//==============================================================================
|
|
NeuralAudioEngine(NeuralSharedParams &sp)
|
|
{
|
|
for (auto i = 0; i < maxNumVoices; ++i)
|
|
addVoice(new NeuralSynthVoice(sp));
|
|
|
|
setVoiceStealingEnabled(true);
|
|
}
|
|
|
|
//==============================================================================
|
|
void prepare(const juce::dsp::ProcessSpec& spec) noexcept
|
|
{
|
|
setCurrentPlaybackSampleRate(spec.sampleRate);
|
|
|
|
for (auto* v : voices)
|
|
dynamic_cast<NeuralSynthVoice*> (v)->prepare(spec);
|
|
}
|
|
|
|
//==============================================================================
|
|
template <typename VoiceFunc>
|
|
void applyToVoices(VoiceFunc&& fn) noexcept
|
|
{
|
|
for (auto* v : voices)
|
|
fn(dynamic_cast<NeuralSynthVoice*> (v));
|
|
}
|
|
|
|
private:
|
|
//==============================================================================
|
|
void renderNextSubBlock(juce::AudioBuffer<float>& outputAudio, int startSample, int numSamples) override
|
|
{
|
|
MPESynthesiser::renderNextSubBlock(outputAudio, startSample, numSamples);
|
|
}
|
|
}; |