audiospeed – Audio processing tools
- class audiospeed.SpeedChanger(source: circuitpython_typing.AudioSample, rate: float = 1.0)
Wraps an audio sample to play it back at a different speed.
Uses nearest-neighbor resampling with a fixed-point phase accumulator for CPU-efficient variable-speed playback.
Create a SpeedChanger that wraps
source.- Parameters:
source (audiosample) – The audio source to resample.
rate (float) – Playback speed multiplier. 1.0 = normal, 2.0 = double speed, 0.5 = half speed. Must be positive.
Playing a wave file at 1.5x speed:
import board import audiocore import audiospeed import audioio wav = audiocore.WaveFile("drum.wav") fast = audiospeed.SpeedChanger(wav, rate=1.5) audio = audioio.AudioOut(board.A0) audio.play(fast) # Change speed during playback: fast.rate = 2.0 # double speed fast.rate = 0.5 # half speed