having a problem with a .wav object
I downloaded an object for reading and playing wav files from an sd card. I haven't been able to make it work yet, and during the course of this somehow made my sd card write protected. I think when i ran the code it write protected it so i can't change anything on it from my computer.There is a format option, but this doesnt seem to cure the write protection problem. The object link is http://obex.parallax.com/objects/567/ If anyone can point me in the right direction on any of these issues i would appreciate it. It looks like this object plays back a certain file at different rates. The ideal thing for me would be to play a certain wav file based on a condition.Thanks.-mike

Comments
'' Simple Parallax Serial Terminal Wav Player Demo '' Uses WAV-Player_DACEngine.spin by Kwabena W. Agyeman '' '' The WAV-Player program can play any standard WAV file. E.g. 16/8-Bit 16000/22050/44100-Hz. '' '' A useful tool for converting wav files to 16bit PCM is Audacity '' Audacity is available for Windows, Mac, GNU/Linux, and other operating systems. '' http://audacity.sourceforge.net/ '' CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 do = 0 clk = 1 di = 2 cs = 3 laudio = 11 ' -1 if unused. raudio = 10 ' -1 if unused. volume = 20 ' Default volume. OBJ wav : "WAV-Player_DACEngine.spin" pst : "Parallax Serial Terminal" VAR long spinPlayerStack[100] byte key PUB demo pst.start(115200) wav.FATEngineStart(do, clk, di, cs, -1, -1, -1, -1, -1) wav.DACEngineStart(laudio, raudio, volume) repeat key := pst.CharIn pst.clear pst.str(@Music) case key "1": wav.playWAVFile(@file1) "2": wav.playWAVFile(@file2) "3": wav.playWAVFile(@file3) "4": wav.playWAVFile(@file4) DAT Music byte "==================", 13 byte " Wav Audio Player ", 13 byte "==================", 13,13 byte "[1] Wilhelm scream ", 13 byte "[2] Angel theme ", 13 byte "[3] Benny Hill ", 13 byte "[4] Barney Miller ", 13,0 file1 byte "wilhelm.wav", 0 file2 byte "angel.wav", 0 file3 byte "bhill.wav", 0 file4 byte "bmiller.wav", 0 {{ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // TERMS OF USE: MIT License /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation // files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, // modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the // Software is furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the // Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// }}Problems with sd can be caused by hardware. In my environment, SD card added to Propeller Demo Board sometime caused resets and other strange symptoms. After one of these resets SD card was empty, all files disappeared.
Then I added 100 uF capacitor between vcc and vdd, soldered directly to SD slot and this solved all my problems with SD card
There is no resistors In my configuration. Only this 100 uF capacitor added after these stability problems.
OBC
What i am doing is just replacing "wilhelm.wav", with the file name my wav file is saved under in my laptop that i copied to the sd card "whatever.wav". Is this correct?...I feel like i'm making a simple mistake somewhere and not sure how to proceed.-mike
DAT Music byte "==================", 13 byte " Wav Audio Player ", 13 byte "==================", 13,13 byte "[1] Wilhelm scream ", 13 byte "[2] Angel theme ", 13 byte "[3] Benny Hill ", 13 byte "[4] Barney Miller ", 13,0 file1 byte "wilhelm.wav", 0 file2 byte "angel.wav", 0 file3 byte "bhill.wav", 0 file4 byte "bmiller.wav", 0http://obex.parallax.com/objects/567/
there is a demo wave player program
You have to rename your wave file to wav.wav or change this name in the code
Try this. I use this program ( after I remove all this tempo change stuff) to play wav files.
{{ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // WAV-Player Program // // Author: Kwabena W. Agyeman // Updated: 7/20/2011 // Designed For: P8X32A // Version: 1.2 // // Copyright (c) 2011 Kwabena W. Agyeman // See end of file for terms of use. // // Update History: // // v1.0 - Original release - 7/6/2011. // v1.1 - Tested with updated driver - 7/18/2011. // v1.2 - Added support for dither mode - 7/20/2011. // // Plays a WAV file over and over again at different sample rates. The WAV file is specified by its file path name string that // can be found in the code below. The WAV-Player program can play any standard WAV file. E.g. 16/8-Bit 16000/22050/44100-Hz. // // Nyamekye, /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// }} CON _clkmode = xtal1 + pll16x ' The clkfreq is 80MHz. _xinfreq = 5_000_000 ' Demo board compatible. _dopin = 0 _clkpin = 1 _dipin = 2 _cspin = 3 _cdpin = 4 ' -1 if unused. _wppin = 5 ' -1 if unused. _rtcres1 = -1 ' -1 always. _rtcres2 = -1 ' -1 always. _rtcres3 = -1 ' -1 always. _lpin = 11 ' -1 if unused. _rpin = 10 ' -1 if unused. _volume = 10 ' Default volume. _ditherEnable = true ' "true" or "false" please. _ditherLevel = 4 ' 0 = Most Dither ... 31 = Least Dither. OBJ dac: "WAV-Player_DACEngine.spin" VAR long spinPlayerStack[100] PUB demo dac.FATEngineStart(_dopin, _clkpin, _dipin, _cspin, _wppin, _cdpin, _rtcres1, _rtcres2, _rtcres3) dac.DACEngineStart(constant(_lpin | (not(not(_ditherEnable)))), constant(_rpin | (not(not(_ditherEnable)))), _volume) ' Above Never fail - no need to check return value. if(_ditherEnable) dac.DACDitherEngineStart(_lpin, _rpin, _ditherLevel) ' Never fails - no need to check return value. cognew(spinPlayer, @spinPlayerStack) ' Startup separate process. repeat ' Repeat forever. repeat until(dac.wavePlayerState) ' Wait until start. repeat until(dac.fileSamplePosition > (dac.fileSampleNumber / 3)) ' Wait until 1/3rds in. dac.fileSampleRateSetup((dac.fileSampleRate * 4) / 3) ' Sample rate set to 4/3rds the original. repeat until(dac.fileSamplePosition > ((dac.fileSampleNumber / 3) * 2)) ' Wait until 2/3rds in. dac.fileSampleRateSetup((dac.fileSampleRate * 3) / 4) ' Sample rate set to 3/4ths the original. repeat while(dac.wavePlayerState) ' Wait until stop. PUB spinPlayer ' Plays a WAV file over and over again. repeat ' Forever dac.playWAVFile(string("WAV.wav")) ' Supports WAV files up to ~2GB. {{ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // TERMS OF USE: MIT License /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation // files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, // modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the // Software is furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the // Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Are you using supported wav files? 16bit or 8bit. Note the information on this in the top of the file I posted. There is a free program to convert them.
Also, I'm having some doubts about your SD configuration. Could you test it with another known program like Femtobasic and see if the "files" command works for you?
OBC
FemtoBasic doesn't work with SDHC.
Has anyone written a "simple", "one-trick" test program to simply display a list of files from SD using K's code?
This would have been handy in debugging this.
OBC
I have a KyeDos. I had to modify it to work with my environment - I replaced SD driver to newest version from OBEX. Its "dir" command seems to work, displaying names in 8.3 format.
I plan to write my own code for this as soon as I finish this "VGA Nostalgia" driver which I want to use with it. First program I want to do with it is media player (sid/ym/wav) with sdhc/fat32 support - Ahle's version is written for TV driver and I am listening to these tunes without any video output and it doesn't support fat32 (it can see only a few files in it)
Yes good idea, as Kye updated the driver after Kyedos was published.
]
That sounds fun. Back in the olden days when memory was precious everyone compressed to .mp3. But SD cards have so much capacity now you can easily just expand your music collection back to .wav files. A media player would be cool.