Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 8 of 8

Thread: SD Audio playback speed

  1. #1
    Junior Member
    Join Date
    May 2017
    Posts
    3

    SD Audio playback speed

    Hello

    Trying to find out if it is possible to play audio files from an sd card while adjusting the speed of which the audio files are played at. I would only need to change the speed by -10% / +10%. This seems like a bit of a grey area atm so any guidance would be greatly appreciated. I am using a teensy 3.6 with a teensy audio adapter.

    Cheers!

  2. #2
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,024
    Quote Originally Posted by Geroge View Post
    Hello

    Trying to find out if it is possible to play audio files from an sd card while adjusting the speed of which the audio files are played at. I would only need to change the speed by -10% / +10%. This seems like a bit of a grey area atm so any guidance would be greatly appreciated. I am using a teensy 3.6 with a teensy audio adapter.

    Cheers!
    Reading from SD card is independent from playing audio. As audio sampling rate is fixed, you could insert a resampling filter between sd card read and audio output. However, I do not know if there are examples available.

  3. #3
    Junior Member
    Join Date
    May 2017
    Posts
    3
    Quote Originally Posted by WMXZ View Post
    Reading from SD card is independent from playing audio. As audio sampling rate is fixed, you could insert a resampling filter between sd card read and audio output. However, I do not know if there are examples available.
    Hmmm massive over-sight on my behalf, should have noticed on that one. I am trying to make a small beatmatching tool, kind of based off cdj 500s. Forgive me as I am pretty new to this, but is there a way of slowing down / speeding up the sd card read rate? Doesn't exactly need to sound good. I noticed that with the flash memory chip installed on the audio board you can get about 8 sec of delay, perhaps this could be used for a re-sampling filter?
    Cheers

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,211
    Quote Originally Posted by Geroge View Post
    is there a way of slowing down / speeding up the sd card read rate? Doesn't exactly need to sound good.
    So far nobody has written the code to do this. It's on my todo list, together with *many* other features. I do not have a solid timeframe for when I'll get around to it.

    To specifically answer your "is there a way" question, yes, there most certainly is a way. But that way involves pretty substantial programming effort within the library. If "a way" is restricted to mean only ways that involve using existing audio library features without difficult programming, then no, there isn't currently such a way.

    I noticed that with the flash memory chip installed on the audio board you can get about 8 sec of delay, perhaps this could be used for a re-sampling filter?
    This is purely a matter of software. The extra memory chip is not needed and would not significantly help. In fact, the software would likely be much more difficult to write if it unnecessarily tried to use that chip in some way.
    Last edited by PaulStoffregen; 05-29-2017 at 05:08 PM.

  5. #5
    Junior Member
    Join Date
    May 2017
    Posts
    3
    Great this clears up a lot thank you. Looking forward to this feature being implemented, along with the many others!

    Cheers!

  6. #6
    Junior Member
    Join Date
    Apr 2013
    Posts
    4
    I had an unsuccessful go at this a few months ago, the goal was to be able to detune samples for a sample-based keyboard.

    Reading from SD card is independent from playing audio, but the code for AudioPlaySdRaw reads data from the SD card in chunks matching the audio buffer size. Reading at double or half speed is relatively easy, but something like 10% slower/faster would require keeping track of excess data that's already read but doesn't fill an entire audio buffer yet. My attempt just resulted in a lot of terrible noise with a hint of the original sound.

  7. #7
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,244
    Quote Originally Posted by floretan View Post
    I had an unsuccessful go at this a few months ago, the goal was to be able to detune samples for a sample-based keyboard.

    Reading from SD card is independent from playing audio, but the code for AudioPlaySdRaw reads data from the SD card in chunks matching the audio buffer size. Reading at double or half speed is relatively easy, but something like 10% slower/faster would require keeping track of excess data that's already read but doesn't fill an entire audio buffer yet. My attempt just resulted in a lot of terrible noise with a hint of the original sound.
    Have you tried to sync the speed-change with the audioblocks (speed-change only when between blocks)

  8. #8
    Junior Member Moo's Avatar
    Join Date
    Oct 2016
    Location
    London
    Posts
    8

    RAW files playback speed

    I was also looking for some kind of playback speed control, and since I didn't find any solutions and quite a few people who seems to have a similar requirements, I thought I'd see if I could hack it... well at least the easy version, which is resampled RAW files...

    I implemented a ResamplingSdReader class which has equivalent methods to File::read(char *buf, long len) but returns a resampled buffer instead of direct buffer from file.

    I've copied play_sd_raw class to play_sd_raw_resampled class and added method setReadRate(float f): where 1 would be regular playback rate, 0.5 half speed, 2 double speed, etc). [Maybe it should be called setPlaybackRate?]

    I've forked https://github.com/PaulStoffregen/Audio -> https://github.com/newdigate/Audio, added this feature, even tested briefly on a teensy, and to my surprise to seemed to work really nicely.

    https://github.com/newdigate/Audio/c...47aecc0c7a1960

    if anybody is interested, I'd be happy to send pull request to PaulStoffregen/Audio

    A nice improvement would be to implement an option to enable linear interpolation on the resampled output.

    It would also be nice to be able to play WAV files at arbitrary rates.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •