Shop OBEX P1 Docs P2 Docs Learn Events
Wav Player help needed — Parallax Forums

Wav Player help needed

NWCCTVNWCCTV Posts: 3,629
edited 2013-03-14 02:05 in Propeller 1
I am totally lost here. I downloaded the OBEX WaveplaerV4_1. I have the pins set correctly to the BOE Board. I have my ear buds plugged in but when I run the program no the chimes.wav file which is on the SD card does not play. I am new to Spin and do not understand what I am doing wrong. Any help is appreciated.
Example of waveplayer usage
con
  _clkmode = xtal1 + pll16x
  _xinfreq = 5_000_000
  bufferLen = 800
obj
  ser : "FullDuplexSerial"
  wpl : "WavePlayerSdAccess"
var                 
  byte buff[bufferLen]
  long stack[50]
pub main | sdBasePin, HeadphoneRightPin, HeadphoneLeftPin
  ser.start(31,30,0,19200)
  'wait for any input from terminal
  'ser.rx
  'change values to match your setup
  sdBasePin := 22
  HeadphoneRightPin := 27
  HeadphoneLeftPin := 26
  wpl.start(sdBasePin, HeadphoneRightPin, HeadphoneLeftPin, @buff, bufferLen)
  'not nessesary if background playing isn't needed(only uses extra cog while playing)
  wpl.setStack(@stack)
       
  ser.str(string("Wave Player example", 13))   
  'replace "winst.wav" with any wav on your sd card        
  wpl.playbgwave(string("chimes.wav"))
  'possibly anoying but pause and unpause wave playing in background  
  repeat while wpl.bgisPlaying
    waitcnt(cnt + 20_000_000)
    'wpl.togglebgPause
  'play wave again using current cog
  wpl.playwave(string("chimes.wav"))
«1

Comments

  • RaymanRayman Posts: 14,665
    edited 2013-03-08 17:27
    Here's my latest version of a wav player:
    WavPlayer2g - Archive [Date 2013.03.04 Time 20.55].zip

    I've recently realized that the one I posted in OBEX could be improved...

    I think this version is a bit easier to use.

    I've heard that Kye's is good too.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2013-03-08 17:34
    Does this access an SD card to play the wav files?
  • RaymanRayman Posts: 14,665
    edited 2013-03-08 17:51
    Yes, you will have to change the pins to match your setup though...

    It should tell you the status over serial link too...
  • NWCCTVNWCCTV Posts: 3,629
    edited 2013-03-08 18:00
    OK. Do I need the Serial Terminal running when I load the program?

    Edit: I got it. Thanks, this works great. Is there any way to change to different files if there are multiple files on the card?
  • RaymanRayman Posts: 14,665
    edited 2013-03-08 18:10
    Yes, just call the "PlayWav" routine for every file you want to play...
  • NWCCTVNWCCTV Posts: 3,629
    edited 2013-03-08 18:14
    Forgive me for being "illiterate" on this subject, but how do I do that? In the Serial Terminal or the program itself?

    Also, Any idea on how to convert 24 bit wav files to 16 bit?
  • kwinnkwinn Posts: 8,697
    edited 2013-03-08 18:31
    I'm pretty sure Audacity can do that for you and it's a free download.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2013-03-08 18:35
    Yea, I just found a quick online program that did it.

    ARayman, How do I call the Playwav routine? Is that done within the program or on the Serial terminal? I new to Spin so forgive my ignorance.
  • RaymanRayman Posts: 14,665
    edited 2013-03-08 18:37
    I meant in the program... But, you could code it to do it over serial too...

    The demo just plays one file with this line:
    PlayWav(string("test7.wav")) '
    

    If you want to play three files, one after the other, just add a couple copies:
      PlayWav(string("test7.wav")) '    
      PlayWav(string("test7.wav")) '   
      PlayWav(string("test7.wav")) '
    

    (change the filenames to what you want...)
  • NWCCTVNWCCTV Posts: 3,629
    edited 2013-03-08 18:43
    Very odd. I was able to get the Windows chimes.wav to play but can not get any of the files I just converted to play.

    What is the file size limit, if any?
  • NWCCTVNWCCTV Posts: 3,629
    edited 2013-03-08 19:18
    So where is this value suppose to show up?
    ser.str(string(13,13,"Playing wav file...",13)
    

    I have the Serial Terminal open and enabled but nothing comes up in it.
  • RaymanRayman Posts: 14,665
    edited 2013-03-08 19:22
    Hmm... That's strange... Maybe make sure port and baud are set right?
  • NWCCTVNWCCTV Posts: 3,629
    edited 2013-03-08 19:26
    How do you mean? I added the test7.wav file to my SD card and it plays just fine. It just seems that any of the files I converted to 16 Bit 44KHz are not working.

    Edit: Oops, I thought you were talking about the files not playing.
  • RaymanRayman Posts: 14,665
    edited 2013-03-08 19:34
    I'd be interested in figuring this out... Can you email me a .wav file that isn't working?
  • NWCCTVNWCCTV Posts: 3,629
    edited 2013-03-08 19:55
    Can you email me a .wav file that isn't working?

    Sure, PM me your email address.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2013-03-08 20:03
    Port and Baud are correct. Are DTR,RTS and Echo On suppose to be checked or unchecked?
  • RaymanRayman Posts: 14,665
    edited 2013-03-08 20:14
    email is ray@rayslogic.com ...

    BTW: wav needs to be 16-bit PCM with no compression
  • NWCCTVNWCCTV Posts: 3,629
    edited 2013-03-08 20:15
    Yes, That is what the files are after I converted them. 48 Hz, 16 Bit PCM No Compression
  • cavelambcavelamb Posts: 720
    edited 2013-03-08 21:06
    NWCCTV wrote: »
    How do you mean? I added the test7.wav file to my SD card and it plays just fine. It just seems that any of the files I converted to 16 Bit 44KHz are not working.

    Edit: Oops, I thought you were talking about the files not playing.

    I only took a quick look at Rayman's latest player.
    The wave sample is indeed 32 bits, not 16.
    Even thought the warning about only supporting 16 bit files is still there in the PlayWav function.

    'open the WAV file (NOTE: Only plays stereo, 16-bit PCM WAV Files !!!!!!!!!!!!!)


    Ray? Zup bud?
  • cavelambcavelamb Posts: 720
    edited 2013-03-08 21:07
    NWCCTV wrote: »
    Yes, That is what the files are after I converted them. 48 Hz, 16 Bit PCM No Compression

    Not all converters are created equal.
    Download and use Audacity.
    I had similar problems when I fist started playing with wavs.
  • RaymanRayman Posts: 14,665
    edited 2013-03-09 05:55
    I think I see the problem with the wave player and that wav file...
    It is getting stuck looking for "data". I was assuming that this marker would be long aligned, but it's not in this case.
    So, I'm going to have to change the code to look at it more as a byte stream...
    Should have something this morning to try.

    Each of the sound samples is 16 bits. But if it's stereo, somebody might call it 32 bits...
    The code actually checks the header now to make sure it's 16 bit...
  • skylightskylight Posts: 1,915
    edited 2013-03-10 14:59
    Rayman wrote: »
    Yes, just call the "PlayWav" routine for every file you want to play...
    That's how I got the player to play multiple files, one thing that worries me though is I have only tested this with an eight track album, looking through the code the PlayWav subroutine calls a new cog each time, does this mean that each time I call PlayWav that another cog is started?As I am calling the PlayWav routine eight times have I used up all the cogs as I dont see a stop cog command anywhere in the code, if another call was made to PlayWav would an error occur? As a beginner still I don't understand using different cogs yet, one thing i'm wanting to do is run the relevant code for a touchscreen in one cog and the Wav player in another cog.
  • RaymanRayman Posts: 14,665
    edited 2013-03-10 15:30
    It is supposed to shut itself down when done by jumping here:
    Done
            
             'now stop
            COGID thisCog
            COGSTOP thisCog
    
  • skylightskylight Posts: 1,915
    edited 2013-03-10 16:30
    Thanks Rayman I missed that,
  • NWCCTVNWCCTV Posts: 3,629
    edited 2013-03-10 16:48
    Ok, I think I have it now. Try this one please:


    It gets stuck here.

    Playing wav file...
    Attempting to mountSD card
    ........................................................
    .
    Edit: Note, This is happening on files that were playing correctly in revision "g".
  • RaymanRayman Posts: 14,665
    edited 2013-03-10 19:04
    Hmm... Looks like it can't find the SD card...

    Please check the SD pin settings and reinsert the SD card.

    Not sure what else..
  • NWCCTVNWCCTV Posts: 3,629
    edited 2013-03-10 19:09
    Yea, but it works fine if I use the "G" revision, with the exception of it not playing the file like I sent you. It does this on all files, even the ones that worked on Rev. G.
  • ErlendErlend Posts: 612
    edited 2013-03-11 01:25
    I had a similar problem. The wav played fine in windows, but not in prop, and in Audacity the specs were correct. Then when I recorded a new file in Audacity it played fine on the prop. The mystery though, is that other music files I've checked out through Audacity afterwards, plays fine when I delete (non-existent) tag-info from the files.
    Problem solved, so I have not done any more investigation.

    Erlend
  • RaymanRayman Posts: 14,665
    edited 2013-03-11 02:36
    I think I've fixed the problem with that tag info with this new version...

    NWCCTV, you don't really have a wav playback probelm now, it's an SD card mounting problem.
    Please triple check that these settings are the same in this version and the one that works:
    CON 'SD card pin settings
      'Set the pins used for SD card here
      'Propeller Platform Express settings:
      SD_MISO=0
      SD_CLK=1
      SD_MOSI=2
      SD_CS=3
    

    If so, then something wierd is going on... Please quit the Prop Tool extract the zip file to a new folder, then open the wav player in a fresh Prop Tool and try again...
Sign In or Register to comment.