Skip to content

Commit

Permalink
Move the oscillator count to Config.h
Browse files Browse the repository at this point in the history
  • Loading branch information
jpcima committed Apr 7, 2020
1 parent 0dca7db commit fb2dc60
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/sfizz/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ namespace config {
constexpr int filtersInPool { maxVoices * 2 };
constexpr int filtersPerVoice { 2 };
constexpr int eqsPerVoice { 3 };
constexpr unsigned oscillatorsPerVoice { 9 };
constexpr float noiseVariance { 0.25f };
/**
Minimum interval in frames between recomputations of coefficients of the
Expand Down
2 changes: 1 addition & 1 deletion src/sfizz/Defaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ namespace Default
constexpr float oscillatorPhase { 0.0 };
constexpr Range<float> oscillatorPhaseRange { -1.0, 360.0 };
constexpr int oscillatorMulti { 1 };
constexpr Range<int> oscillatorMultiRange { 1, 9 };
constexpr Range<int> oscillatorMultiRange { 1, config::oscillatorsPerVoice };
constexpr float oscillatorDetune { 0 };
constexpr Range<float> oscillatorDetuneRange { -9600, 9600 };

Expand Down
4 changes: 1 addition & 3 deletions src/sfizz/Voice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ void sfz::Voice::setupOscillatorUnison()
waveUnisonSize = m;

// detune (cents)
float detunes[maxWaveOscillators];
float detunes[config::oscillatorsPerVoice];
detunes[0] = 0.0;
detunes[1] = -d;
detunes[2] = +d;
Expand Down Expand Up @@ -703,5 +703,3 @@ void sfz::Voice::setupOscillatorUnison()
}
#endif
}

constexpr unsigned sfz::Voice::maxWaveOscillators;
10 changes: 4 additions & 6 deletions src/sfizz/Voice.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,15 +288,13 @@ class Voice {
ADSREnvelope<float> egEnvelope;
float bendStepFactor { centsFactor(1) };

static constexpr unsigned maxWaveOscillators = Default::oscillatorMultiRange.getEnd();

WavetableOscillator waveOscillators[maxWaveOscillators];
WavetableOscillator waveOscillators[config::oscillatorsPerVoice];

// unison of oscillators
unsigned waveUnisonSize { 0 };
float waveDetuneRatio[maxWaveOscillators] { };
float waveLeftGain[maxWaveOscillators] { };
float waveRightGain[maxWaveOscillators] { };
float waveDetuneRatio[config::oscillatorsPerVoice] { };
float waveLeftGain[config::oscillatorsPerVoice] { };
float waveRightGain[config::oscillatorsPerVoice] { };

Duration dataDuration;
Duration amplitudeDuration;
Expand Down

0 comments on commit fb2dc60

Please sign in to comment.