Skip to content

Commit

Permalink
Remove DC from oscillators
Browse files Browse the repository at this point in the history
  • Loading branch information
madskjeldgaard committed Mar 31, 2021
1 parent f8c0813 commit c05ae18
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 5 deletions.
3 changes: 2 additions & 1 deletion plugins/NeoFormant/NeoFormant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace NeoFormant {
NeoFormant::NeoFormant() {
const float samplerate = sampleRate();
formantosc.Init(samplerate);
dcblocker.Init(samplerate);

mCalcFunc = make_calc_function<NeoFormant, &NeoFormant::next>();
next(1);
Expand All @@ -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;
Expand Down
1 change: 1 addition & 0 deletions plugins/NeoFormant/NeoFormant.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class NeoFormant : public SCUnit {
float m_carrierfreq_past {0.f};

daisysp::FormantOscillator formantosc;
daisysp::DcBlock dcblocker;

};

Expand Down
3 changes: 2 additions & 1 deletion plugins/NeoVarSawOsc/NeoVarSawOsc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace NeoVarSawOsc {
NeoVarSawOsc::NeoVarSawOsc() {
const float samplerate = sampleRate();
varsawosc.Init(samplerate);
dcblocker.Init(samplerate);

mCalcFunc = make_calc_function<NeoVarSawOsc, &NeoVarSawOsc::next>();
next(1);
Expand All @@ -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;
Expand Down
1 change: 1 addition & 0 deletions plugins/NeoVarSawOsc/NeoVarSawOsc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 };

Expand Down
3 changes: 2 additions & 1 deletion plugins/VarShapeOsc/VarShapeOsc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace VarShapeOsc {
VarShapeOsc::VarShapeOsc() {
const float samplerate = sampleRate();
varshapeosc.Init(samplerate);
dcblocker.Init(samplerate);

mCalcFunc = make_calc_function<VarShapeOsc, &VarShapeOsc::next>();
next(1);
Expand All @@ -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;
Expand Down
1 change: 1 addition & 0 deletions plugins/VarShapeOsc/VarShapeOsc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class VarShapeOsc : public SCUnit {
float m_syncfreq_past{100.f};

daisysp::VariableShapeOscillator varshapeosc;
daisysp::DcBlock dcblocker;
};

} // namespace VarShapeOsc
Expand Down
3 changes: 2 additions & 1 deletion plugins/VosimOsc/VosimOsc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace VosimOsc {
VosimOsc::VosimOsc() {
const float samplerate = sampleRate();
vosim.Init(samplerate);
dcblocker.Init(samplerate);

mCalcFunc = make_calc_function<VosimOsc, &VosimOsc::next>();
next(1);
Expand All @@ -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;
Expand Down
1 change: 1 addition & 0 deletions plugins/VosimOsc/VosimOsc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
4 changes: 3 additions & 1 deletion plugins/ZOsc/ZOsc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace ZOsc {
ZOsc::ZOsc() {
const float samplerate = sampleRate();
zosc.Init(samplerate);
dcblocker.Init(samplerate);

mCalcFunc = make_calc_function<ZOsc, &ZOsc::next>();
next(1);
Expand All @@ -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;
Expand Down
1 change: 1 addition & 0 deletions plugins/ZOsc/ZOsc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class ZOsc : public SCUnit {
float m_mode_past{0.5f};

daisysp::ZOscillator zosc;
daisysp::DcBlock dcblocker;
};

} // namespace ZOsc

0 comments on commit c05ae18

Please sign in to comment.