r/AudioProgramming • u/c00ble • May 17 '24
Realtime audio playback speed
Hello everyone,
I've got an idea for a little project in my head but one of the main components that I haven't already blocked out is a way to load an audio file and change the speed in real time like you get with DJ software or a turntable or cassette player.
If anyone could point me in the right direction of how I would go about achieving this I would be eternally grateful!
I'm not too fussed about the language or platform or any of that stuff. I'm studying software engineering so I have a decent amount of knowledgeable in all the "big" languages.
Thank you!
View all comments
Show parent comment
1
u/dycide May 17 '24
Good, that’s the easier one! :D
Did you already manage to load a file and play it back? Basically you will end up with a buffer of samples and to play them back you iterate through the buffer and write each sample to your output buffer in your callback function.
To change the playback speed, you adjust the rate at which each sample is output. This can be done by changing the index increment in your sample playback loop. For example, if you normally increment the index by 1 for each frame (to play at the original speed), you can increment by 2 to play at double the speed, or by 0.5 to play at half speed.
I would suggest giving the JUCE library a try, it offers audio file loading and audio backend handling + GUI all in one and it is possible to build standalone apps and vst plugins. It’s written in c++. If you just want a quick prototype and don’t need best performance it’s probably easier to go with python and some real-time audio lib though.
Good luck! :)