audioeffects.flanger

Flanger - a swept comb on CircuitPython’s own audiodelays.Flanger.

The player’s text is the class docstring; the CLAIMS table in the class’s test file ties its claim sentences to tests. How the node behaves is told where the class drives it, in Flanger._build.

audioeffects.flanger.MAX_DELAY_MS = 10

nothing re-allocates after construction.

Type:

The line, fixed

audioeffects.flanger.BLOCK = 256

the palette’s block.

Type:

Frames a pull hands out

audioeffects.flanger.DIVISION_BARS = (4.0, 2.0, 1.0, 0.5, 0.3333333333333333, 0.25, 0.125)

DIVISION_BARS`).

Type:

Sync’s divisions in bars, Phaser’s own (`phaser.py

audioeffects.flanger.SILENCE_DB = 90.31

a peak this far under full scale is under one LSB.

Type:

20 log10(32768), rounded up

audioeffects.flanger.ECHO_TOLERANCE = 1e-06

How far a knob may sit from the step its constructor value seeded and still count as not moved (a host echoing get_macro back).

audioeffects.flanger.PATCH_0 = (39, 76, 59, 94, 127, 0, 0, 42)

Patch 0, “Slow jet”, on the grid. Construction is patch 0 (the contract), so each constructor default is the value of patch 0’s step.

audioeffects.flanger.DEFAULTS = (0.2544400749392052, 0.5984251968503937, 1.0054385170446731, 0.7031496062992126, 1.0)

Rate about 0.25 Hz, Range about 0.6, Manual about 1 ms, Color about 0.7, Mix 1.

Type:

Each constructor keyword’s default, which NaN falls back to

audioeffects.flanger.tail_frames(color, top_ms, rate)[source]

Frames until the ring is exact silence, for Color color and a sweep whose top is top_ms, at rate (the card’s section 5).

Interpolation never exceeds its two samples and the feedback truncates toward zero, so the line’s peak falls by at least g each D + 1 frames, and is zero once it would fall under one LSB.

class audioeffects.flanger.Flanger(source, *options, **keywords)[source]

Bases: Component

A flanger: your signal plus a copy of itself a few milliseconds late, the delay swept up and down by a triangle, so the comb of notches the sum makes moves through the spectrum.

The controls. Rate is the sweep’s speed. Manual is the sweep’s floor, and Range is how far it climbs from there towards 10 ms: at Range 0 the comb holds still at Manual. Color feeds the copy back into the line and raises the comb’s peaks into a ring. Mix is the copy’s level against a dry that never moves: 1 is equal weight and the deepest notches, 0 is a wire. Polarity minus turns the comb over and puts a notch at DC. With Sync on, one sweep lasts Division bars at the host’s tempo and meter, and Rate is ignored. Constructor values play exactly until their knob first moves or a patch loads. The Effect controls page lists what the knobs span.

What you hear. The copy is your signal exactly Manual late, added at Mix. At Color 0 and Mix 1 a tone on a notch comes out at least 40 dB down. Color raises the peaks by up to 26.4 dB over the input and fills the notches to 6 dB under it. The sweep is a triangle in milliseconds that starts at Manual and reaches its top once a sweep. The ring lasts about 0.4 s to -60 dB at 3 ms and full Color, and about 0.7 s at 5 ms; it grows as Range sweeps the delay longer, and it never oscillates on its own.

Limits. It is linear only to about -28 dBFS on a resonant frequency at full Color, and -7.5 dBFS at Color 0: above that the output is squashed and gritty, not louder. Turning Mix up makes the output louder, by 6 dB on a comb peak at Mix 1: there is no wet-only setting. There is no tone control, no through-zero and no stereo spread: both channels sweep together. Sync sets the sweep’s period, not its phase: the sweep starts at Manual when the class is built or reset, not on a bar line, and a synced sweep faster than 20 Hz runs at 20 Hz. A jump of Mix walks to its new setting over 20 ms rather than stepping the output. A jump of another control steps it: move that in small steps from the host if you need it smooth. At 22.05 kHz the sweep’s top is 9.977 ms, half a frame under 10 ms. Mix’s first step above 0 is still a wire; the copy comes in at the second step, about 36 dB down. Keep the input under -6 dBFS.

Wire, latency, tail. At Mix 0 the output is the input, byte for byte. There is no latency. tail_samples is the longest the ring can last at the controls in force, while the source keeps playing, silence included. If the source ends, the output stops dead; reset() clears what the line held and returns to patch 0. On a CircuitPython board, stop the flanger from the host if your source can run dry: CircuitPython’s own flanger waits on a source that comes back empty. Firmware built with omnipython-builds’ build_mp.py carries the fix and returns.

NAME = 'Flanger'

The stable provider name audioeffects.create() discovers.

TIER = 'stock'

it runs on a stock CircuitPython board.

Type:

Upstream’s own node

CAPABILITIES = ('tempo_sync',)

The contract’s static reads. CAPABILITIES names "tempo_sync" if and only if the class reads self._transport().

TAIL_SAMPLES = 98607

full Color and the sweep at the line’s top (D = 480 frames). tail_samples is the bound at the controls in force.

Type:

The worst case at 48 kHz

INPUT_CEILING_DBFS = -6.0

On stock CircuitPython the wet’s interpolation overflows int32 where two neighbouring line samples are more than 32768 apart at a fractional delay (audiodsp#76, widened in audiodsp’s copy). At Color 0 the line is the input, so -6 dBFS keeps it safe there.

MACRO_LABELS = ('Rate', 'Range', 'Manual', 'Color', 'Mix', 'Polarity', 'Sync', 'Division')

Knob names, one per macro index; one mode per label; the private engineering spans behind them; and the patches on the 0-127 grid.

transport_changed()[source]

With Sync on, follow the host’s tempo and its meter: a move of either sets the sweep’s rate again. The base follows the tempo alone, so a 4/4 to 3/4 change at one tempo would keep the old rate.

macro(index)[source]

What macro index currently stands for, in its own units; for the first five, the value that plays.

property tail_samples

The bound at the controls in force; see the class docstring.