audioeffects.pitchshifter
PitchShifter - a fixed-interval splice pitch shifter.
The player’s text is the class docstring; the CLAIMS table in the class’s
test file ties its claim sentences to tests.
- audioeffects.pitchshifter.DELAY_MAX_MS = 112.5
The Delay and Feedback spans’ tops.
- audioeffects.pitchshifter.WINDOW_MS = 30.0
the default and the clamp.
- Type:
The shifter’s window, in ms
- audioeffects.pitchshifter.LINE_MS = 120.0
The line holds Delay’s top and a little; the loop holds Delay’s top, the half window and crossfade it adds, and the window its splicer reads over.
- audioeffects.pitchshifter.BLOCK = 256
The frames one pull of the output hands out.
- audioeffects.pitchshifter.STEPS = 256
121`).
- Type:
The node’s read rate is whole 256ths of unity (`PitchShift.c
- audioeffects.pitchshifter.DEFAULTS = (7.0, 0.0, 1.0, 0.0, 0.0)
The constructor defaults, which NaN falls back to.
- audioeffects.pitchshifter.crossfade_frames(sample_rate)[source]
The shifter’s crossfade: 4/3 ms in whole frames, 64 at 48 kHz.
- audioeffects.pitchshifter.window_frames(window_ms, sample_rate)[source]
The shifter’s window in whole frames at the running rate.
- audioeffects.pitchshifter.step_centre_semitones(step)[source]
Semitones that put the node on
step: the centre of the step, so the node’s truncation lands on it at any float width.
- audioeffects.pitchshifter.step_semitones(step)[source]
The step itself in semitones, for the loop; exactly 0 at unity.
- class audioeffects.pitchshifter.PitchShifter(source, *options, **keywords)[source]
Bases:
ComponentPlay your part again a fixed interval up or down, a little behind you, the way the first harmonizer boxes did.
The controls. Pitch is the interval in whole semitones. Fine detunes it. The shifter reads in steps of 1/256 of the speed, so Fine moves in steps of about 7 cents near unity and 13.5 near the octave down, and the interval is within 0.5 % of the one Pitch and Fine name. Mix keeps your dry signal at unity up to its centre, 1, with the shifted voice coming up to unity beside it; at 2 you hear the shifted voice alone, and at 0 the output is your input. Delay holds the shifted voice back. Feedback sends the shifted voice round again, and every repeat is shifted once more: at a fifth up the repeats climb a fifth, then a ninth, then a thirteenth. The Effect controls page lists what the knobs span.
The splice. The shifter keeps a short memory of what you play, the window, and reads it at the new speed, splicing back to the other end when it runs out. Off unity, each note comes back anywhere from straight away to one window and 1.3 ms late, plus Delay, the delay sweeping and jumping at every splice. At unity it sits still, 1.3 ms late, from a fresh start, a reset or a return from Mix 0; after a Pitch move it sits wherever the splice left it, up to one window and 1.3 ms late. On CircuitPython’s own pitch shifter a reset or a return from Mix 0 does not restart the splice, so there it sits wherever the splice was. Shifting down drops slices of what you play; shifting up repeats them. The window is 30 ms unless you pass
window_ms, 15 to 60, when you build it: a longer window splices less often and arrives later.The dry. Up to Mix 1 your dry signal passes untouched, sample for sample, with the shifted voice added on top, so a hot input can reach the rail. Feedback stacks level too, far past the input: at Feedback 127, Delay 0 and Mix 2 a noise burst peaking at -10.3 dBFS reaches the rail at unison, and comes within 6 dB of it at an octave or a fourth or fifth either way.
Mono, latency, tail. A one-channel source gets a one-channel shifter with the same window. Latency is zero samples: the dry is never delayed.
tail_samplesis an upper bound on how long the output takes to reach exact zero once your input stops, at every Feedback.reset()empties the shifter and both delay lines and returns to patch 0. The class never reads the host’s tempo. If your host takes the output before it loads a patch or moves Mix, or loads a patch right after a reset, the first 256 frames, 5 ms at 48 kHz, play at the old level.Limits shared by the family. A control that jumps makes the output step: move it in small steps from the host if you need it smooth.
- NAME = 'PitchShifter'
The stable provider name
audioeffects.create()discovers.
- TIER = 'audiodsp'
STOCK or AUDIODSP, with REQUIRES naming the audiodsp-own modules an AUDIODSP class needs.
- Type:
roadmap §3
- CAPABILITIES = ()
The contract’s static reads.
CAPABILITIESnames"tempo_sync"if and only if the class readsself._transport().
- INPUT_CEILING_DBFS = -10.5
Where no patch can reach the rail. At Mix 1 the dry and the shifted voice each reach the input’s peak, and the repeats add Feedback^n of it: 1 + 1 / (1 - 0.5535) = 3.24 times the peak at patches 4 and 5, which -10.21 dBFS keeps under full scale. Feedback at its top stacks up to 21 times, and the kit declares those cells.
- MACRO_LABELS = ('Pitch', 'Fine', 'Mix', 'Delay', 'Feedback')
Knob names, one per macro index; one mode per label; the private engineering spans behind them; and the patches on the 0-127 grid.
- PATCHES = {0: ('Fifth Above', (101, 64, 64, 0, 0)), 1: ('Octave Up', (127, 64, 64, 0, 0)), 2: ('Octave Down', (0, 64, 64, 0, 0)), 3: ('Doubler', (64, 75, 64, 17, 0)), 4: ('Rising Fifths', (101, 64, 64, 102, 74)), 5: ('Falling Fourths', (37, 64, 64, 113, 74)), 6: ('Shifted Only', (101, 64, 127, 0, 0))}
_component.macro_ofof the card’s patch settings.
- macro(index)[source]
What macro
indexcurrently stands for, in its own units; for Pitch, the whole semitones it plays.
- property output
The node the host plays. Asking for it is the host’s first step to pulling, so from here a level that moves is an ordinary move.
- reset()[source]
Empty the shifter and both lines, return to patch 0, and play from there as a new instance does.
- property tail_samples
Frames until the output is exactly zero once the input stops, as an upper bound.
The shifter hands out what it holds for at most one window and crossfade after its input stops, the line adds its delay, and the loop then goes round
laps_to_zero(Feedback)times, each lap at most its delay plus the window its splicer reads across, and a frame for the read between two. At Feedback 0 the loop is a wire.