FX INTRODUCTION / 05 / DRAFT

Filter: blend with the previous value

Following rapid changes gradually is a first step toward a low-pass filter that reduces high frequencies.

This article is a work in progress. The examples will be refined through listening. Run starts playback; Stop ends it. Use Apply after editing values. Stop the playing iframe before trying another one.

Listen with the built-in FX

SettingMeaning
typelowpass / highpass / bandpass
cutoffFrequency (Hz)
qValue affecting resonance strength

Select none in FX Monitor to see the waveform after the built-in FX. This pass-through effect makes input and output overlap; it does not compare the signal before and after the built-in FX.

Open in a separate Playground tab ↗

How the PCM is processed

With previous += a × (input − previous), a smaller a follows the input more slowly. It follows slow changes but reduces fast ones. Reuse previous for the next sample, and keep separate history for left and right.

input[ch][i] is one input sample. ch identifies a left or right audio channel, not a physical FM voice. Store values carried between blocks in state. Since process cannot access outer variables, put settings in context.

Try it with liveFx

The 48000 in context.sampleRate is a placeholder. Match it to the actual output rate shown in FX Monitor. It is used to calculate times and frequencies; it does not change the browser's output sample rate.

Open in a separate Playground tab ↗

Select filter-lab in FX Monitor to compare the input and output of this process.

  1. Compare cutoff at 300, 800, and 4000 Hz.
  2. Use a tone with more harmonics than a sine wave to hear the change in brightness.
  3. Try output = input − previous in the learning example to extract high frequencies.

Scope of this example

This learning example is a first-order smoothing filter. The coefficient's Hz value is not an exact −3 dB point, especially at high frequencies. Its slope and resonance differ from the built-in biquad, and it has no Q control.

The waveform shows changes over time; Spectrum shows the strength of frequency components. A short display window or smoothing can hide some changes. Listen while changing one setting at a time.