Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions WaveSabreCore/include/WaveSabreCore/Helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ namespace WaveSabreCore

static double Square135(double phase);
static double Square35(double phase);
static double OpShape(double phase, double waveform);

static float Mix(float v1, float v2, float mix);
static float Clamp(float f, float min, float max);
Expand Down
4 changes: 2 additions & 2 deletions WaveSabreCore/src/Falcon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,10 @@ namespace WaveSabreCore
double baseNote = GetNote() + Detune + falcon->Rise * 24.0f;

double osc1Input = osc1Phase / Helpers::CurrentSampleRate * 2.0 * 3.141592 + osc1Output * osc1Feedback;
osc1Output = ((Helpers::FastSin(osc1Input) + Helpers::Square35(osc1Input) * (double)falcon->osc1Waveform)) * osc1Env.GetValue() * 13.25;
osc1Output = Helpers::OpShape(osc1Input, (double)falcon->osc1Waveform) * osc1Env.GetValue() * 13.25;

double osc2Input = osc2Phase / Helpers::CurrentSampleRate * 2.0 * 3.141592 + osc2Output * osc2Feedback * 13.25 + osc1Output * osc1FeedForwardScalar;
osc2Output = ((Helpers::FastSin(osc2Input) + Helpers::Square35(osc2Input) * (double)falcon->osc2Waveform)) * osc2Env.GetValue();
osc2Output = Helpers::OpShape(osc2Input, (double)falcon->osc2Waveform) * osc2Env.GetValue();

float finalOutput = (float)osc2Output * masterLevelScalar;
outputs[0][i] += finalOutput * leftPanScalar;
Expand Down
47 changes: 28 additions & 19 deletions WaveSabreCore/src/Helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,22 +159,31 @@ namespace WaveSabreCore
return left + (right - left) * fractMix;
}

double Helpers::Square135(double phase)
double Helpers::Square135(double phase) // Unused?
{
return FastSin(phase) +
FastSin(phase * 3.0) / 3.0 +
FastSin(phase * 5.0) / 5.0;
FastSin(phase * 3.0) * (1.0 / 3.0) +
FastSin(phase * 5.0) * (1.0 / 5.0);
}

double Helpers::Square35(double phase)
double Helpers::Square35(double phase) // Unused?
{
return FastSin(phase * 3.0) / 3.0 +
FastSin(phase * 5.0) / 5.0;
return FastSin(phase * 3.0) * (1.0 / 3.0) +
FastSin(phase * 5.0) * (1.0 / 5.0);
}

double Helpers::OpShape(double phase, double waveform) {
double s = FastSin(phase);
double ss = s*s;
const double p5 = 3.2;
const double p3 = -16.0/3.0;
const double p1 = 2.0;
return (((p5 * ss + p3) * ss + p1) * waveform + 1.0) * s; //https://www.desmos.com/calculator/lao6woj19u
}

float Helpers::Mix(float v1, float v2, float mix)
{
return v1 * (1.0f - mix) + v2 * mix;
return v1 + (v2 - v1) * mix;
}

float Helpers::Clamp(float f, float min, float max)
Expand Down Expand Up @@ -237,25 +246,25 @@ namespace WaveSabreCore

float Helpers::ParamToQ(float param)
{
if (param < .5f)
{
return param / .5f * (1.0f - .33f) + .33f;
const float a = 4.0f/3.0f;
const float b = 1.0f/3.0f;
if (param < .5f) {
return param * a + b;
}
else
{
return (param - .5f) / .5f * 11.0f + 1.0f;
else {
return param * 22.0f - 10.0f;
}
}

float Helpers::QToParam(float q)
{
if (q < 1.0f)
{
return (q - .33f) / (1.0f - .33f) * .5f;
const float a = 1.0f/22.0f;
const float b = 10.0f/22.0f;
if (q < 1.0f) {
return 0.75f * q - 0.25f;
}
else
{
return (q - 1.0f) / 11.0f * .5f + .5f;
else {
return a * q + b;
}
}

Expand Down