Being able to easily play WAV files with audiocore.WaveFile is amazing,
but there's no way to change the playback speed of the WAV playback.
If WaveFile had a .rate property that could be adjustable in real-time,
it opens up many creative / musical uses:
- "ROMpler" sample player keyboard (single sample repitched across a key range)
- Drum loop BPM matching
- Tuning drum samples for drum machines
- Fun dynamic pitch effects for recorded audio
The WAV repitch algorithm can be pretty simple using the standard phase accumulator
technique. The additional code size to WaveFile should have a fairly small impact
on the smaller platforms.
For CPU efficiency, fixed-point integer math can be used for resampling and the common-case of rate=1.0 could early-out and revert to previous behavior.
In use, the feature would look something like:
wav = audiocore.WaveFile("my_cool_sound.wav")
mixer.voice[0].play(wav, loop=True)
wav.rate = 0.5 # play at half-speed / an octave down
wav.rate = 2.0 # play at 2x speed / an octave up
wav.rate = 1.0 # play at normal speed