Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix up the Sin osc FM channel #1036

Merged
merged 1 commit into from
Aug 16, 2019
Merged
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
53 changes: 16 additions & 37 deletions src/common/dsp/Oscillator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,46 +73,25 @@ osc_sine::~osc_sine()

void osc_sine::process_block(float pitch, float drift, bool stereo, bool FM, float fmdepth)
{
if (FM)
driftlfo = drift_noise(driftlfo2);
double omega = min(M_PI, (double)pitch_to_omega(pitch + drift * driftlfo));
// FMdepth.newValue(fmdepth);
FMdepth.newValue(32.0 * M_PI * fmdepth * fmdepth * fmdepth);
FB.newValue(localcopy[id_fb].f);

for (int k = 0; k < BLOCK_SIZE_OS; k++)
{
driftlfo = drift_noise(driftlfo2);
double omega = min(M_PI, (double)pitch_to_omega(pitch + drift * driftlfo));
FMdepth.newValue(fmdepth);
auto fb = localcopy[id_fb].f;
for (int k = 0; k < BLOCK_SIZE_OS; k++)
{
output[k] = valueFromSinAndCos(sin(phase + lastvalue * fb), cos(phase + lastvalue * fb));
phase += omega + master_osc[k] * FMdepth.v;
lastvalue = output[k];
FMdepth.process();
}
// Replicate FM2 exactly
auto p = phase + lastvalue;
if (FM)
p += FMdepth.v * master_osc[k];
output[k] = valueFromSinAndCos(sin(p), cos(p));
phase += omega;
lastvalue = output[k] * FB.v;
FMdepth.process();
FB.process();
}
else
{
driftlfo = drift_noise(driftlfo2);
double omega = min(M_PI, (double)pitch_to_omega(pitch + drift * driftlfo));
auto fb = localcopy[id_fb].f;
for (int k = 0; k < BLOCK_SIZE_OS; k++)
{
float phs = phase + fb * lastvalue;
output[k] = valueFromSinAndCos(sin(phs), cos(phs));
phase += omega;
lastvalue = output[k];
FMdepth.process();
}

/*driftlfo = drift_noise(driftlfo2);
sinus.set_rate(min(M_PI, (double)pitch_to_omega(pitch + drift * driftlfo)));

for (int k = 0; k < BLOCK_SIZE_OS; k++)
{
sinus.process();
float svalue = sinus.r;
float cvalue = sinus.i;

output[k] = valueFromSinAndCos(svalue, cvalue);
}*/
}
if (stereo)
{
memcpy(outputR, output, sizeof(float) * BLOCK_SIZE_OS);
Expand Down
1 change: 1 addition & 0 deletions src/common/dsp/Oscillator.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class osc_sine : public Oscillator
double phase;
float driftlfo, driftlfo2;
lag<double> FMdepth;
lag<double> FB;

int id_mode, id_fb;
float lastvalue = 0;
Expand Down