Upload files to "Source"
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
#include "SynthVoice.h"
|
||||
#include <cmath>
|
||||
std::shared_ptr<WT::Bank> NeuralSynthVoice::wtBank;
|
||||
|
||||
//==============================================================================
|
||||
|
||||
@@ -16,15 +15,6 @@ void NeuralSynthVoice::prepare (const juce::dsp::ProcessSpec& newSpec)
|
||||
// --- Oscillator
|
||||
osc.prepare (spec.sampleRate);
|
||||
setWaveform (0); // default to sine
|
||||
// --- Wavetable bank (build once), then prepare osc ---
|
||||
if (!wtBank)
|
||||
{
|
||||
wtBank = std::make_shared<WT::Bank>(2048, 16, 6); // N=2048, frames=16, levels=6
|
||||
wtBank->generateDefaultMorph(); // Sine -> Saw -> Square -> Triangle
|
||||
wtBank->buildMipmaps();
|
||||
}
|
||||
wtOsc.prepare(spec.sampleRate);
|
||||
wtOsc.setBank(wtBank);
|
||||
|
||||
// --- Scratch buffer (IMPORTANT: allocate real memory)
|
||||
tempBuffer.setSize ((int) spec.numChannels, (int) spec.maximumBlockSize,
|
||||
@@ -80,25 +70,21 @@ void NeuralSynthVoice::renderNextBlock (juce::AudioBuffer<float>& outputBuffer,
|
||||
if (numSamples <= 0)
|
||||
return;
|
||||
|
||||
//if (! adsr.isActive())
|
||||
// clearCurrentNote();
|
||||
if (! adsr.isActive())
|
||||
clearCurrentNote();
|
||||
|
||||
// Apply pending waveform change (from GUI / processor thread)
|
||||
const int wf = pendingWaveform.exchange (-1, std::memory_order_acq_rel);
|
||||
if (wf != -1)
|
||||
setWaveform (wf);
|
||||
|
||||
// --- Generate oscillator into temp buffer (WT or BLEP) ---
|
||||
// --- Generate oscillator into temp buffer
|
||||
tempBuffer.clear();
|
||||
const int numCh = juce::jmin ((int) spec.numChannels, tempBuffer.getNumChannels());
|
||||
|
||||
const bool useWT = (shared.wtOn && shared.wtOn->load() > 0.5f);
|
||||
if (useWT && shared.wtMorph)
|
||||
wtOsc.setMorph(shared.wtMorph->load()); // 0..15 continuous
|
||||
|
||||
for (int i = 0; i < numSamples; ++i)
|
||||
{
|
||||
const float s = useWT ? wtOsc.process() : osc.process();
|
||||
const float s = osc.process();
|
||||
for (int ch = 0; ch < numCh; ++ch)
|
||||
tempBuffer.getWritePointer (ch)[i] = s;
|
||||
}
|
||||
@@ -336,14 +322,10 @@ void NeuralSynthVoice::noteStarted()
|
||||
{
|
||||
const float freqHz = (float) getCurrentlyPlayingNote().getFrequencyInHertz();
|
||||
|
||||
// Oscillator frequency + phase
|
||||
// Oscillator frequency and phase retrigger
|
||||
osc.setFrequency (freqHz);
|
||||
osc.resetPhase (0.0f);
|
||||
|
||||
// Wavetable oscillator too
|
||||
wtOsc.setFrequency(freqHz);
|
||||
wtOsc.resetPhase(0.0f);
|
||||
|
||||
// Chorus snapshot
|
||||
if (shared.chorusCentre) chain.get<chorusIndex>().setCentreDelay (shared.chorusCentre->load());
|
||||
if (shared.chorusDepth) chain.get<chorusIndex>().setDepth (shared.chorusDepth->load());
|
||||
@@ -390,7 +372,6 @@ void NeuralSynthVoice::notePitchbendChanged()
|
||||
{
|
||||
const float freqHz = (float) getCurrentlyPlayingNote().getFrequencyInHertz();
|
||||
osc.setFrequency (freqHz);
|
||||
wtOsc.setFrequency (freqHz);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
||||
Reference in New Issue
Block a user