SID / FILTER / INTRODUCTION
SID Filter: Change the Brightness of a Sound
Keep one sawtooth note playing. Change what reaches the output, then take the settings into JavaScript.
MOS 6581 · PAL · Tetorica approximation
A small listening experiment
Start with Bypass and one note. Keep it running while you change the controls. All three voices use the same Saw settings. The optional chord adds two notes; it does not replace CH1. Reset controls restores the initial settings. Stop sound fades the software output and releases the audio engine.
Stopped. Sound starts only when you press Start sound.
1. Keep the note. Change the filter output.
A sawtooth contains a fundamental and higher harmonics. A filter changes their balance. The oscillator’s frequency setting stays the same as you switch outputs.
- Press Start sound in Bypass. Listen to the original Saw tone and look at its spectrum.
- Select LP. Move Cutoff slowly from about 1200 toward 200, then back. Compare the higher-frequency part of the spectrum.
- Keep Cutoff fixed and compare BP and HP. Ask which parts of the spectrum remain, rather than judging only loudness.
| Output | What to listen for |
|---|---|
| Bypass | The voices take the direct path. |
| LP · Low-pass | Lower frequencies remain more prominent; frequencies above the cutoff region are reduced. |
| BP · Band-pass | A band around the cutoff region remains more prominent. |
| HP · High-pass | Higher frequencies remain more prominent; lower frequencies are reduced. |
The same SID volume and page gain are used in every mode. The modes can have different output levels; this experiment does not normalize their loudness. Extreme settings can make a tone very quiet even though its Gate is still on.
2. Separate Cutoff from Resonance.
Select LP and try Resonance 0 first. Use Cutoff to move the filter’s transition region. Then leave Cutoff around 500 and raise Resonance slowly: inspect the emphasis around that region, and notice any change in level.
Cutoff is the SID’s 11-bit setting, 0–2047. Resonance is a four-bit setting, 0–15. Neither value is a percentage. This page deliberately does not label a cutoff code as an exact frequency in Hz.
The experiment uses Tetorica’s simplified 6581 PAL model. The chip’s filter routing and control fields guide the interface; the generated sound is a digital approximation. Real 6581 units and their external filter components vary. Use the comparison to investigate this model, not to assign one universal Hz value to each code.
3. Three voices share one filter.
Enable Add CH2 / CH3, select LP, and leave all three routing boxes checked. One Cutoff and one Resonance setting now shape the combined routed voices.
- Uncheck CH2. It now reaches the output directly; CH1 and CH3 still use the filter.
- Move Cutoff. Listen for the direct voice alongside the filtered voices.
- Check CH2 again. All three voices return to the same filter. Unchecking every box makes all voices direct.
| Voice on the page | Code channel | Routing bit |
|---|---|---|
| CH1 | 0 | 1 |
| CH2 | 1 | 2 |
| CH3 | 2 | 4 |
The API uses channels 0, 1, 2 for the page’s CH1, CH2 and CH3. Add routing bits 1 + 2 + 4 to send all three to the filter. CH1 and CH3 together use routing: 5. Unselected voices remain direct.
Bypass here means mode: "off", routing: 0. Setting only mode: "off" while leaving a voice routed removes its filter-output path; that is not a bypass.
SID can also add several filter outputs together. LP + HP is its notch combination. This first experiment selects one output at a time; combined modes are available in SID Synth and the API.
4. Read the settings, then change the code.
This example follows the controls above. Open it in the Playground to edit it. Change one value at a time and compare it with this page; stop the current example before starting the other one.
The copied example plays for four seconds, allows a short release, then disposes its client. The page continues until Stop sound. Master and mixer settings in the Playground or your own app can change the output level.
const sid = await useSoundChip('sid');
try {
await sid.initialize();
const notes = ['C3', 'E3', 'G3'];
for (let ch = 0; ch < 3; ch++) {
await sid.setVoice(ch, {
waveform: 'saw', pulseWidth: 2048,
attack: 2, decay: 6, sustain: 9, release: 4,
sync: false, ring: false, test: false,
});
await sid.setNote(ch, notes[ch]);
}
// One shared hardware filter. Unrouted voices remain dry.
// Bypass uses mode 'off' AND routing 0 to keep the voices audible.
await sid.setFilter({
mode: 'off', cutoff: 500, resonance: 5,
routing: 0, volume: 8, voice3off: false,
});
for (const ch of [0]) await sid.keyOn(ch);
// JavaScript waiting controls the performance; the SID clock runs in audio.
await sleep(4);
await sid.allNotesOff();
await sleep(0.4);
} finally {
sid.dispose();
}
From the experiment to your own app
The Playground supplies useSoundChip() and sleep(). In your own browser app, initialize the npm SID client instead. The existing 02-filter example shows the complete audio setup; its setVoice(), setNote() and setFilter() calls correspond to this experiment. The Synth link opens a separate editor; it does not silently transfer this page’s settings.
What belongs to the chip?
Saw oscillators, voice envelopes, routing, filter outputs, Cutoff and Resonance are SID controls. This page’s sliders, chord selection, note-name conversion, spectrum display, fixed output gain and transport fade are software around the chip. Editing a filter control writes settings to the same running SID; it does not restart the held CH1 note.