Upload files to "Source"
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
#pragma once
|
||||
#include <JuceHeader.h>
|
||||
#include <functional> // <-- for std::function used by WaveShaper
|
||||
#include <memory>
|
||||
#include <cmath>
|
||||
#include "NeuralSharedParams.h"
|
||||
#include "BlepOsc.h"
|
||||
#include "WavetableOsc.h"
|
||||
|
||||
//==============================================================================
|
||||
// A single polyBLEP oscillator voice with per-voice ADSR, filter ADSR,
|
||||
@@ -25,11 +28,45 @@ public:
|
||||
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);
|
||||
struct MorphLFO
|
||||
{
|
||||
void prepare (double sr) { sampleRate = juce::jmax (1.0, sr); updateIncrement(); }
|
||||
void reset() { phase = 0.0f; }
|
||||
void setRate (float hz) { rate = juce::jlimit (0.0f, 30.0f, hz); updateIncrement(); }
|
||||
void setShape (int idx) { shape = juce::jlimit (0, 3, idx); }
|
||||
float process()
|
||||
{
|
||||
float value = 0.0f;
|
||||
|
||||
switch (shape)
|
||||
{
|
||||
case 1: value = 1.0f - 4.0f * std::abs(phase - 0.5f); break; // Triangle
|
||||
case 2: value = 2.0f * phase - 1.0f; break; // Ramp up
|
||||
case 3: value = 1.0f - 2.0f * phase; break; // Ramp down
|
||||
default: value = std::sin (juce::MathConstants<float>::twoPi * phase); break; // Sine
|
||||
}
|
||||
|
||||
phase += phaseInc;
|
||||
if (phase >= 1.0f)
|
||||
phase -= 1.0f;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
private:
|
||||
void updateIncrement()
|
||||
{
|
||||
phaseInc = (float) (rate / (float) sampleRate);
|
||||
if (phaseInc < 0.0f) phaseInc = 0.0f;
|
||||
}
|
||||
|
||||
double sampleRate { 44100.0 };
|
||||
float rate { 1.0f };
|
||||
float phase { 0.0f };
|
||||
float phaseInc { 0.0f };
|
||||
int shape { 0 };
|
||||
};
|
||||
|
||||
//=== Processing chain (without oscillator) ===============================
|
||||
using DelayLine = juce::dsp::DelayLine<float,
|
||||
@@ -77,9 +114,14 @@ private:
|
||||
|
||||
juce::dsp::ProcessSpec spec {};
|
||||
|
||||
// ==== Oscillator (polyBLEP) ============================================
|
||||
BlepOsc osc;
|
||||
std::atomic<int> pendingWaveform {-1}; // set by changeWaveform()
|
||||
// ==== Oscillators ======================================================
|
||||
BlepOsc osc; // polyBLEP oscillator
|
||||
WT::Osc wtOsc; // wavetable oscillator (shared bank)
|
||||
MorphLFO morphLfo;
|
||||
int currentWtBankIndex { -1 };
|
||||
WT::Osc wtOsc2; // secondary wavetable oscillator
|
||||
MorphLFO morphLfo2;
|
||||
int currentWtBankIndex2 { -1 };
|
||||
|
||||
// ==== Envelopes & Filter ===============================================
|
||||
juce::ADSR adsr;
|
||||
|
||||
Reference in New Issue
Block a user