Shop OBEX P1 Docs P2 Docs Learn Events
Playing Wav files... - Page 2 — Parallax Forums

Playing Wav files...

2»

Comments

  • SONIC the HedgehogSONIC the Hedgehog Posts: 321
    edited 2012-02-08 11:49
    Yeah, but if you get the propeller platform USB from gadet gangster, you already get the micro sd in place. And it's only 50 and it has everything you need really, except for video and audio out but thts easy to get.
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2012-02-08 12:13
    Like Peter pointed out, the quiescent current of an SD card is very low when it is asleep (which happens automatically) and anyway for zero-power there can be a p-channel FET under Prop control in line with the SD card power supply (and pullup resistors if any have to be tied to the switched power). From power up to disk mounted, file opened, 250 bytes written, file closed, dismounted and power turned off takes 0.25 second. For frequent card access, leave it mounted, for infrequent access turn it completely off. Quantitatively there is certain point where turning the card power fully on and off is more efficient than leaving it on.

    I have a situation where an SD card has to hold sound files that can be changed by the end user simply by changing the card. What happens when you get tired of one bell and want to hear another?
  • SONIC the HedgehogSONIC the Hedgehog Posts: 321
    edited 2012-02-08 12:19
    So acsess time is 1/100th of the size of the data?
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2012-02-08 12:27
    @Sonic. No, most of the 0.25 second is spent initializing after power up and mounting the card. The actual writing of the data, even opening and flushing/closing the file, are a very small fraction of that time. I have quantitative data on that somewhere. The ratio is what is useful for determining whether it is more power efficient to turn it off completely vs leaving it on.
  • SONIC the HedgehogSONIC the Hedgehog Posts: 321
    edited 2012-02-08 12:38
    Ah, I asked because you said the time for a file that was 250 bytes was .25 seconds, so I figured a ratio, but basing it off of the numbers I should have gotten 1/1000, which still might not be right. I don't know a ratio to determine size compared to voltage consumtion and all that, but thanks for little facts! I appreciate it!
  • SONIC the HedgehogSONIC the Hedgehog Posts: 321
    edited 2012-02-08 15:47
    @Tracey Allen, you make a great point!! And thanks for explaining, I'm really starting to get the hang of electrons and how to use them effectively!!
  • cavelambcavelamb Posts: 720
    edited 2012-02-08 16:07
    Rayman wrote: »
    Glad you got it!

    The format for playing from HUB RAM (loaded from eeprom) is:
    8-bit PCM mono 16000 or 8000 sample/second WAV

    Ok gang, we've made a little progress this afternoon.
    I grabbed a copy of Audacity and ran my magic dinger through that.
    Out came a 14K wav file that plays on the Propeller using Rayman's example.

    That leaves 18K for program space, so I think we are back on track.

    Then I took a wild guess - it looked like the second ding started about 1/4 of the way
    into the wav file. So I payed the ding-ding, then jumped past the first and played
    a single. That was done by copying the play function in the example.

    wOw. It worked. (There's that big grin again!)

    except...

    There is a bad crunch after the second (single) ding.
    10 - 20 ms or so maybe? It's not there in the full wav file.

    I'm guessing I'm reading out past the end of the wav file?
    But I don't quite completely understand what the example is up to yet.

    Ray? What do you think?

    I've (hopefully] blocked the code here, and added the wav file as Bells.zip



        8000:
          dcnt:=10000
        16000:
          dcnt:=5000
        other:
          return false
    
     'jump over header      
      pWav+=44   'ignore rest of header (so you better have the right file format!)
      'Get ready for fast loop  
      n--
      i:=0
      NextCnt:=cnt+1500
    
      'Play loop
      repeat i from 0 to n
        NextCnt+=dcnt   ' need this to be 5000 for 16KSPS   @ 80 MHz
        waitcnt(NextCnt)
        FRQA:=(byte[pWav+i])<<24
        FRQB:=FRQA
     
      pWav+=3600  ' jump past the first ding
      i:=0
      repeat i from 0 to n
        NextCnt+=dcnt   ' need this to be 5000 for 16KSPS   @ 80 MHz
        waitcnt(NextCnt)
        FRQA:=(byte[pWav+i])<<24
        FRQB:=FRQA
    
    
         
      return true
    
      
    DAT
    
    WAV byte
    'File "test8a.wav"           '   <---  put your 8-bit PCM mono 16000 or 8000 sample/second WAV filename here
    'File "test8b.wav"           '   <---  put your 8-bit PCM mono 16000 or 8000 sample/second WAV filename here
    'File "test8c.wav"           '   <---  put your 8-bit PCM mono 16000 or 8000 sample/second WAV filename here
    File "bell2a.wav"
    
  • SONIC the HedgehogSONIC the Hedgehog Posts: 321
    edited 2012-02-08 16:14
    With audacity you can zoom in on the samples, and look at and even edit the actual sound wave, so you would be able to tell where it dropped out, or even went wrong.
  • kuronekokuroneko Posts: 3,623
    edited 2012-02-08 16:34
    cavelamb wrote: »
    There is a bad crunch after the second (single) ding. 10 - 20 ms or so maybe? It's not there in the full wav file.

    I'm guessing I'm reading out past the end of the wav file?
    Correct. You advance pWav by 3600 but use the original length (n). So either adjust n as well (n -= 3600) or read less in the second loop (and keep n intact).
  • cavelambcavelamb Posts: 720
    edited 2012-02-08 16:41
    Other than changing the wav file format (there are zillions of 'em) all I did was fade out at the end.
    I thought maybe the data was cutting off abruptly. But not...
  • cavelambcavelamb Posts: 720
    edited 2012-02-08 16:46
    Brilliant, Mr K.
    I thought so, but wasn't quite sure how to write it.
    These double character operators are all new to me - and very strange.

    To the point:

    is += the same as =+ ??
    .
    Is there a primer on this stuff somewhere?
  • kuronekokuroneko Posts: 3,623
    edited 2012-02-08 17:02
    cavelamb wrote: »
    To the point:

    is += the same as =+ ??
    There is no =+. Have a look at the manual (rev 1.2, page 43 which lists most if not all of them). Following through to the relevant page(s) you'll find lots of explanations and examples, e.g. += on page 149. HTH
  • cavelambcavelamb Posts: 720
    edited 2012-02-08 17:25
    kuroneko wrote: »
    There is no =+. Have a look at the manual (rev 1.2, page 43 which lists most if not all of them). Following through to the relevant page(s) you'll find lots of explanations and examples, e.g. += on page 149. HTH


    Ok. Thank you.

    Like Mom said, when all else fails, read the manual...
  • SONIC the HedgehogSONIC the Hedgehog Posts: 321
    edited 2012-02-08 19:44
    I always thought reading the manual was fun. Honestly, if I didn't read the manual of my PS2 back in 2000, I wouldn't have been interested in electronics.
  • cavelambcavelamb Posts: 720
    edited 2012-02-08 20:23
    It's nearly a megabyte more than the Bible!

    399 pages of PDF.
    And I can't take it in the bathroom with me.
    I can't think of anything more inclined to make my eyes bleed.
  • Martin HodgeMartin Hodge Posts: 1,246
    edited 2012-02-08 22:55
    Ahle2, here's a challenge for you...

    http://www.youtube.com/watch?v=EGeoG0KQa68
  • cavelambcavelamb Posts: 720
    edited 2012-02-09 00:29
    Challenge? For HIM?
    Come on, Martin. It's 8 bit stuff...
  • SONIC the HedgehogSONIC the Hedgehog Posts: 321
    edited 2012-02-09 04:15
    Challenges are fun.many eigtbit?why not sixteen bit? Weren't you sixteen bit at some point in your life?
    I know I'm sixteen bit.....
  • Martin HodgeMartin Hodge Posts: 1,246
    edited 2012-02-09 09:53
    cavelamb wrote: »
    Challenge? For HIM?
    Come on, Martin. It's 8 bit stuff...

    Well... If the task is too difficult, I can understand... :tongue:
  • SONIC the HedgehogSONIC the Hedgehog Posts: 321
    edited 2012-02-09 09:54
    I believe he can do it!
Sign In or Register to comment.