Feat: refactoring codebase
This commit is contained in:
131
docs/engine/filters.md
Normal file
131
docs/engine/filters.md
Normal file
@@ -0,0 +1,131 @@
|
||||
# Filters
|
||||
|
||||
Filters attenuate frequencies above or below a cutoff point.
|
||||
|
||||
## Lowpass Filter
|
||||
|
||||
The lowpass filter (`lpf`) attenuates frequencies above the cutoff.
|
||||
|
||||
```forth
|
||||
saw 1000 lpf . ( cut above 1000 Hz )
|
||||
saw 500 lpf 0.8 lpq . ( with resonance )
|
||||
```
|
||||
|
||||
| Parameter | Range | Description |
|
||||
|-----------|-------|-------------|
|
||||
| `lpf` | Hz | Cutoff frequency |
|
||||
| `lpq` | 0-1 | Resonance (peak at cutoff) |
|
||||
|
||||
## Highpass Filter
|
||||
|
||||
The highpass filter (`hpf`) attenuates frequencies below the cutoff.
|
||||
|
||||
```forth
|
||||
kick 200 hpf . ( cut below 200 Hz )
|
||||
pad 400 hpf 0.3 hpq . ( with resonance )
|
||||
```
|
||||
|
||||
| Parameter | Range | Description |
|
||||
|-----------|-------|-------------|
|
||||
| `hpf` | Hz | Cutoff frequency |
|
||||
| `hpq` | 0-1 | Resonance |
|
||||
|
||||
## Bandpass Filter
|
||||
|
||||
The bandpass filter (`bpf`) attenuates frequencies outside a band around the center frequency.
|
||||
|
||||
```forth
|
||||
noise 1000 bpf 0.7 bpq . ( narrow band around 1000 Hz )
|
||||
```
|
||||
|
||||
| Parameter | Range | Description |
|
||||
|-----------|-------|-------------|
|
||||
| `bpf` | Hz | Center frequency |
|
||||
| `bpq` | 0-1 | Resonance (narrower band) |
|
||||
|
||||
## Filter Slope
|
||||
|
||||
The `ftype` parameter sets the filter slope (rolloff steepness).
|
||||
|
||||
| Value | Slope |
|
||||
|-------|-------|
|
||||
| `1` | 12 dB/octave |
|
||||
| `2` | 24 dB/octave (default) |
|
||||
| `3` | 48 dB/octave |
|
||||
|
||||
```forth
|
||||
saw 800 lpf 3 ftype . ( 48 dB/oct lowpass )
|
||||
```
|
||||
|
||||
## Filter Envelope
|
||||
|
||||
Filters can be modulated by an ADSR envelope. The envelope multiplies the base cutoff:
|
||||
|
||||
```
|
||||
final_cutoff = lpf + (lpe × envelope × lpf)
|
||||
```
|
||||
|
||||
When the envelope is at 1.0 and `lpe` is 1.0, the cutoff doubles. When the envelope is at 0, the cutoff equals `lpf`.
|
||||
|
||||
```forth
|
||||
saw 200 lpf 2 lpe 0.01 lpa 0.3 lpd . ( cutoff sweeps from 600 Hz down to 200 Hz )
|
||||
```
|
||||
|
||||
| Parameter | Description |
|
||||
|-----------|-------------|
|
||||
| `lpe` | Envelope depth (multiplier, 1.0 = double cutoff at peak) |
|
||||
| `lpa` | Attack time in seconds |
|
||||
| `lpd` | Decay time in seconds |
|
||||
| `lps` | Sustain level (0-1) |
|
||||
| `lpr` | Release time in seconds |
|
||||
|
||||
The same pattern works for highpass (`hpe`, `hpa`, etc.) and bandpass (`bpe`, `bpa`, etc.).
|
||||
|
||||
## Ladder Filters
|
||||
|
||||
Ladder filters use a different algorithm (Moog-style) with self-oscillation at high resonance.
|
||||
|
||||
```forth
|
||||
saw 800 llpf 0.7 llpq . ( ladder lowpass )
|
||||
saw 300 lhpf 0.5 lhpq . ( ladder highpass )
|
||||
saw 1000 lbpf 0.8 lbpq . ( ladder bandpass )
|
||||
```
|
||||
|
||||
| Parameter | Range | Description |
|
||||
|-----------|-------|-------------|
|
||||
| `llpf` | Hz | Ladder lowpass cutoff |
|
||||
| `llpq` | 0-1 | Ladder lowpass resonance |
|
||||
| `lhpf` | Hz | Ladder highpass cutoff |
|
||||
| `lhpq` | 0-1 | Ladder highpass resonance |
|
||||
| `lbpf` | Hz | Ladder bandpass cutoff |
|
||||
| `lbpq` | 0-1 | Ladder bandpass resonance |
|
||||
|
||||
Ladder filters share the lowpass envelope parameters (`lpe`, `lpa`, etc.).
|
||||
|
||||
## EQ
|
||||
|
||||
The 3-band EQ applies shelf and peak filters at fixed frequencies.
|
||||
|
||||
```forth
|
||||
kick 3 eqlo -2 eqhi . ( +3 dB at 200 Hz, -2 dB at 5000 Hz )
|
||||
snare 2 eqmid . ( +2 dB at 1000 Hz )
|
||||
```
|
||||
|
||||
| Parameter | Frequency | Type |
|
||||
|-----------|-----------|------|
|
||||
| `eqlo` | 200 Hz | Low shelf (dB) |
|
||||
| `eqmid` | 1000 Hz | Peak (dB) |
|
||||
| `eqhi` | 5000 Hz | High shelf (dB) |
|
||||
|
||||
## Tilt EQ
|
||||
|
||||
Tilt EQ applies a high shelf at 800 Hz with up to ±6 dB gain.
|
||||
|
||||
```forth
|
||||
pad -0.5 tilt . ( -3 dB above 800 Hz )
|
||||
hat 0.5 tilt . ( +3 dB above 800 Hz )
|
||||
```
|
||||
|
||||
| Parameter | Range | Description |
|
||||
|-----------|-------|-------------|
|
||||
| `tilt` | -1 to 1 | High shelf gain (-1 = -6 dB, 0 = flat, 1 = +6 dB) |
|
||||
Reference in New Issue
Block a user