Shop OBEX P1 Docs P2 Docs Learn Events
Play wavs backwards? — Parallax Forums

Play wavs backwards?

SciNemoSciNemo Posts: 91
edited 2009-11-01 15:44 in Propeller 1
I am trying to play wav files using the propeller in a way that allows me to use a velocity to determine progression in a song. So far I have forward (positive) velocity working, but I am really at a loss to how I can get backward (negative) velocity working. How could a wav file be played backwards off of an SD card?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Not the fish.
sites.google.com/site/bitwinproject/

Comments

  • KyeKye Posts: 2,200
    edited 2009-11-01 05:15
    Err, that would require you to seek to the end of the file after getting all the wav data specs from the format chunks, and then seek backwards for each data sample to play it.

    Pretty much impossible with the prop due to the amount of overhead that would add.

    ...But then it could be possible. If your code is fast enough.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,
  • lonesocklonesock Posts: 917
    edited 2009-11-01 15:44
    Regarding the SD access, SD cards are optimized for forward sequential reads. In the latest version of FSRW, we even switched to multi-block access mode with read-ahead to help throughput. Unfortunately all of these optimizations only help in the typical usage case, namely reading forward.

    So, I think you have 2 basic options:

    1 - use an older version of FSRW with a single-block driver
    --- lets you go backward with as little overhead as possible
    --- you will still need to reverse the samples in each 512-byte block
    --- will most likely still _not_ work on SDHC (any SD card > 2GB), all the ones I tested are very slow in single-block mode

    2 - Use some software on the PC to reverse and save a backwards copy of the file (Audacity can do it, and is free)
    --- use the newest version of FSRW (2.4) to open both files at once
    --- if the sign of the direction changes, switch the the other file, and use the seek function to jump to your start point

    Jonathan

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    lonesock
    Piranha are people too.
Sign In or Register to comment.