From c05ae18797d4c500c4dc4099af87702f488dbfd9 Mon Sep 17 00:00:00 2001 From: Mads Kjeldgaard Date: Wed, 31 Mar 2021 19:35:52 +0200 Subject: [PATCH] Remove DC from oscillators --- plugins/NeoFormant/NeoFormant.cpp | 3 ++- plugins/NeoFormant/NeoFormant.hpp | 1 + plugins/NeoVarSawOsc/NeoVarSawOsc.cpp | 3 ++- plugins/NeoVarSawOsc/NeoVarSawOsc.hpp | 1 + plugins/VarShapeOsc/VarShapeOsc.cpp | 3 ++- plugins/VarShapeOsc/VarShapeOsc.hpp | 1 + plugins/VosimOsc/VosimOsc.cpp | 3 ++- plugins/VosimOsc/VosimOsc.hpp | 1 + plugins/ZOsc/ZOsc.cpp | 4 +++- plugins/ZOsc/ZOsc.hpp | 1 + 10 files changed, 16 insertions(+), 5 deletions(-) diff --git a/plugins/NeoFormant/NeoFormant.cpp b/plugins/NeoFormant/NeoFormant.cpp index 402487f..6f4a220 100644 --- a/plugins/NeoFormant/NeoFormant.cpp +++ b/plugins/NeoFormant/NeoFormant.cpp @@ -11,6 +11,7 @@ namespace NeoFormant { NeoFormant::NeoFormant() { const float samplerate = sampleRate(); formantosc.Init(samplerate); + dcblocker.Init(samplerate); mCalcFunc = make_calc_function(); next(1); @@ -37,7 +38,7 @@ void NeoFormant::next(int nSamples) { formantosc.SetCarrierFreq(carrierfreq); formantosc.SetFormantFreq(formantfreq); formantosc.SetPhaseShift(phaseshift); - outbuf[i] = formantosc.Process(); + outbuf[i] = dcblocker.Process(formantosc.Process()); } m_formantfreq_past = slopedFormantFreq.value; diff --git a/plugins/NeoFormant/NeoFormant.hpp b/plugins/NeoFormant/NeoFormant.hpp index 175e245..7bcc9cd 100644 --- a/plugins/NeoFormant/NeoFormant.hpp +++ b/plugins/NeoFormant/NeoFormant.hpp @@ -28,6 +28,7 @@ class NeoFormant : public SCUnit { float m_carrierfreq_past {0.f}; daisysp::FormantOscillator formantosc; + daisysp::DcBlock dcblocker; }; diff --git a/plugins/NeoVarSawOsc/NeoVarSawOsc.cpp b/plugins/NeoVarSawOsc/NeoVarSawOsc.cpp index 372724c..65c8fa9 100644 --- a/plugins/NeoVarSawOsc/NeoVarSawOsc.cpp +++ b/plugins/NeoVarSawOsc/NeoVarSawOsc.cpp @@ -11,6 +11,7 @@ namespace NeoVarSawOsc { NeoVarSawOsc::NeoVarSawOsc() { const float samplerate = sampleRate(); varsawosc.Init(samplerate); + dcblocker.Init(samplerate); mCalcFunc = make_calc_function(); next(1); @@ -29,7 +30,7 @@ void NeoVarSawOsc::next(int nSamples) { varsawosc.SetFreq(slopedFreq.consume()); varsawosc.SetPW(slopedPW.consume()); varsawosc.SetWaveshape(slopedwaveshape.consume()); - outbuf[i] = varsawosc.Process(); + outbuf[i] = dcblocker.Process(varsawosc.Process()); } m_freq_past = slopedFreq.value; diff --git a/plugins/NeoVarSawOsc/NeoVarSawOsc.hpp b/plugins/NeoVarSawOsc/NeoVarSawOsc.hpp index 0a37b8c..1253d1c 100644 --- a/plugins/NeoVarSawOsc/NeoVarSawOsc.hpp +++ b/plugins/NeoVarSawOsc/NeoVarSawOsc.hpp @@ -25,6 +25,7 @@ class NeoVarSawOsc : public SCUnit { float m_pw_past{0.f}; float m_waveshape_past{0.f}; daisysp::VariableSawOscillator varsawosc; + daisysp::DcBlock dcblocker; enum Outputs { Out1, NumOutputParams }; diff --git a/plugins/VarShapeOsc/VarShapeOsc.cpp b/plugins/VarShapeOsc/VarShapeOsc.cpp index 13f0a46..a598320 100644 --- a/plugins/VarShapeOsc/VarShapeOsc.cpp +++ b/plugins/VarShapeOsc/VarShapeOsc.cpp @@ -11,6 +11,7 @@ namespace VarShapeOsc { VarShapeOsc::VarShapeOsc() { const float samplerate = sampleRate(); varshapeosc.Init(samplerate); + dcblocker.Init(samplerate); mCalcFunc = make_calc_function(); next(1); @@ -35,7 +36,7 @@ void VarShapeOsc::next(int nSamples) { varshapeosc.SetSyncFreq(slopedSyncFreq.consume()); varshapeosc.SetPW(slopedPW.consume()); varshapeosc.SetWaveshape(slopedwaveshape.consume()); - outbuf[i] = varshapeosc.Process(); + outbuf[i] = dcblocker.Process(varshapeosc.Process()); } m_freq_past = slopedFreq.value; diff --git a/plugins/VarShapeOsc/VarShapeOsc.hpp b/plugins/VarShapeOsc/VarShapeOsc.hpp index 0b9e213..9cf2aa7 100644 --- a/plugins/VarShapeOsc/VarShapeOsc.hpp +++ b/plugins/VarShapeOsc/VarShapeOsc.hpp @@ -28,6 +28,7 @@ class VarShapeOsc : public SCUnit { float m_syncfreq_past{100.f}; daisysp::VariableShapeOscillator varshapeosc; + daisysp::DcBlock dcblocker; }; } // namespace VarShapeOsc diff --git a/plugins/VosimOsc/VosimOsc.cpp b/plugins/VosimOsc/VosimOsc.cpp index 8cae2a2..bcf8255 100644 --- a/plugins/VosimOsc/VosimOsc.cpp +++ b/plugins/VosimOsc/VosimOsc.cpp @@ -11,6 +11,7 @@ namespace VosimOsc { VosimOsc::VosimOsc() { const float samplerate = sampleRate(); vosim.Init(samplerate); + dcblocker.Init(samplerate); mCalcFunc = make_calc_function(); next(1); @@ -29,7 +30,7 @@ void VosimOsc::next(int nSamples) { vosim.SetForm2Freq(slopedForm1.consume()); vosim.SetShape(slopedShape.consume()); - outbuf[i] = vosim.Process(); + outbuf[i] = dcblocker.Process(vosim.Process()); } m_freq_past = slopedFreq.value; diff --git a/plugins/VosimOsc/VosimOsc.hpp b/plugins/VosimOsc/VosimOsc.hpp index 73a633e..e872210 100644 --- a/plugins/VosimOsc/VosimOsc.hpp +++ b/plugins/VosimOsc/VosimOsc.hpp @@ -20,6 +20,7 @@ class VosimOsc : public SCUnit { enum InputParams { Freq, Form1, Form2, Shape, NumInputParams }; enum Outputs { Out1, NumOutputParams }; daisysp::VosimOscillator vosim; + daisysp::DcBlock dcblocker; float m_freq_past{100.f}, m_form1_past{100.f},m_form2_past{100.f}, m_shape_past{0.f}; diff --git a/plugins/ZOsc/ZOsc.cpp b/plugins/ZOsc/ZOsc.cpp index 42cdd33..daa0f6a 100644 --- a/plugins/ZOsc/ZOsc.cpp +++ b/plugins/ZOsc/ZOsc.cpp @@ -11,6 +11,7 @@ namespace ZOsc { ZOsc::ZOsc() { const float samplerate = sampleRate(); zosc.Init(samplerate); + dcblocker.Init(samplerate); mCalcFunc = make_calc_function(); next(1); @@ -31,7 +32,8 @@ void ZOsc::next(int nSamples) { zosc.SetMode(slopedMode.consume()); zosc.SetShape(slopedShape.consume()); - outbuf[i] = zosc.Process(); + // @TODO dc blocker should be temporary + outbuf[i] = dcblocker.Process(zosc.Process()); } m_freq_past = slopedFreq.value; diff --git a/plugins/ZOsc/ZOsc.hpp b/plugins/ZOsc/ZOsc.hpp index f06dd13..a858882 100644 --- a/plugins/ZOsc/ZOsc.hpp +++ b/plugins/ZOsc/ZOsc.hpp @@ -25,6 +25,7 @@ class ZOsc : public SCUnit { float m_mode_past{0.5f}; daisysp::ZOscillator zosc; + daisysp::DcBlock dcblocker; }; } // namespace ZOsc