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

Thread: Pausing/Seeking audio

  1. #1
    Junior Member
    Join Date
    Oct 2018
    Posts
    1

    Pausing/Seeking audio

    Hi All

    Apologies if this has been answered before - I've found a few old posts on this subject but nothing that seems to resolve the question. I am playing back wavs from a SD card through the audio shield on a 3.2 and really need to be able to pause and/or seek to a point in an audio file - One post I found said it's easier to do using the raw format, however the link it included as an example was dead.

    Ideally I don't want to modify the Audio library as this then becomes unreliable to maintain, but if that's the only way then needs must..

    If anyone has any ideas they would be much appreciated!

    Thanks

    Richard

  2. #2
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    1,896
    Modifying the audio lib for yourself makes things unmaintainable, that's true. But extend it thoughtfully and make a pull request afterwards, so that Paul could integrate the improved functionality for all users, could be a great idea.
    A wav file is basically a raw file with an added file header containing information about the sample rate, the word size, the number of channels and so on. I think that the actual wav player object does already identify the header and thus know the offset when the raw data starts. From all that header information and the overall file size, it should not be too difficult to calculate the new read address within the file for skipping n seconds forward or backward. Pausing would simply consist of sending (repeatedly, as long as you are in pause mode) one audio block full of zeros without advancing the file read address and continue at that address when you quit the pause mode. I think that it's neither rocket science nor music theory.

  3. #3
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    4,536
    Probably you can simply copy the rawplayer from the audio library to your sketch directory and change the name. Then add a #include "mynewplayer" to your program and change the name within "automatically generated code".
    That should be all there is to do. Then you can customize the code to your needs.

    Not tested.

  4. #4
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    4,536
    Here you will also find useful information: https://github.com/PaulStoffregen/Au...new_objects.md

Posting Permissions

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