Skip to content

Commit

Permalink
MoogVCF: Scale resonance to 0..1
Browse files Browse the repository at this point in the history
  • Loading branch information
ideoforms committed Aug 16, 2024
1 parent 0d98efa commit f80ee37
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion source/include/signalflow/node/processors/filters/moog.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
namespace signalflow
{
/**--------------------------------------------------------------------------------*
* Moog ladder low-pass filter.
* Simulation of the Moog ladder low-pass filter. `cutoff` sets the cutoff
* frequency; `resonance` should typically be between 0..1.
*---------------------------------------------------------------------------------*/
class MoogVCF : public UnaryOpNode
{
Expand Down
8 changes: 7 additions & 1 deletion source/src/node/processors/filters/moog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@ void MoogVCF::process(Buffer &out, int num_frames)
for (int frame = 0; frame < num_frames; frame++)
{
float cutoff = signalflow_scale_lin_lin(this->cutoff->out[channel][frame], 0, this->graph->get_sample_rate() / 2, 0.005, 1);
float resonance = this->resonance->out[channel][frame];

/*------------------------------------------------------------------------
* The original algorithm typically expects resonance values between
* [0, 4]. Rescale in this implementation, for consistency with other
* filter nodes that expect [0, 1].
*-----------------------------------------------------------------------*/
float resonance = this->resonance->out[channel][frame] * 4.0;
float f = cutoff * 1.16;
float fb = resonance * (1.0 - 0.15 * f * f);

Expand Down

0 comments on commit f80ee37

Please sign in to comment.