Ray's ASM Wav Player
Rayman
Posts: 14,826
Update (Feb 2013): I finally got around to fixing this up... Here's the new version:
Attachment not found.
I wasn't particulary pleased with my previous mono, 16ksps SPIN WAV player...
I just converted it to ASM (on my lunch break) and now it does up to 48 ksps in stereo!
Songs must be 16-bit PCM stereo WAV.
Downside is that full songs are now very big!· I can only upload 10 second clips here...
Post Edited (Rayman) : 12/21/2007 1:26:48 PM GMT
Attachment not found.
I wasn't particulary pleased with my previous mono, 16ksps SPIN WAV player...
I just converted it to ASM (on my lunch break) and now it does up to 48 ksps in stereo!
Songs must be 16-bit PCM stereo WAV.
Downside is that full songs are now very big!· I can only upload 10 second clips here...
Post Edited (Rayman) : 12/21/2007 1:26:48 PM GMT
Comments
Great job guy !!!
Congratulations.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Regards.
Alberto.
Nice work indeed!
OBC
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
New to the Propeller?
Getting started with the Protoboard? - Propeller Cookbook
Got an SD card? - PropDOS
A Living Propeller FAQ - The Propeller Wiki
(Got the Knowledge? Got a Moment? Add something today!)
How long are your lunch breaks ??
Well done ..
cheers Ron Melbourne OZ
If Elvis was the king of twist, Rayman is probably the king of Spin!!!
By the way do you expect to make a keyboard routine for changing song, play pause etc...
·
Maybe doing it,· 0 to 50% with a smooth ramp ?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Regards.
Alberto.
So, your code is likely to be "coming soon to a theater near you" (if you're near Minneapolis...)
One minor bug that bit me - You define the output pins twice, and or the two together. They are defined in OPinL and OPinR, but they're also in the low 6 bits of CountModeR/L.
Again, this is fantastic! I'll probably sound better when I add the resistor and the two caps.
Also, it's very possible that I have left and right channels reversed.· If anybody figures this out, pls let me know...
The former requires many cogs, the latter a lot of memory. However, I think both would have their place.
Might be quite a bit of work though to get it up and running on the Prop.
I like Rayman's WAV player. It should work in most places where MP3 would be used.
MP3 would only be good for if you wanna load a SD card with a lot of audio or something.
OBC
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
New to the Propeller?
Getting started with the Protoboard? - Propeller Cookbook
Got an SD card? - PropDOS
A Living Propeller FAQ - The Propeller Wiki
(Got the Knowledge? Got a Moment? Add something today!)
Consider: You can reach many places on earth afoot and in a canoe... But it is a minority making it their living to prove this...
the problem is were the spin code loads the wave file it checks for buff[noparse][[/noparse]n] ==0 but this is some times set to 0 by the read it's self causing it to overrite the buffer on the next itteration of the loop.
[noparse][[/noparse]code]
repeat while (j==buffsize*4)· 'repeat until end of file
··· if (buff1[noparse][[/noparse]n]==0)
····· j:=sd.pread(@buff1, buffSize*4) 'read data words to input stereo buffer
··· if (buff2[noparse][[/noparse]n]==0)
····· j:=sd.pread(@buff2, buffSize*4) 'read data words to input stereo buffer
[noparse][[/noparse]/code]
My Fix
[noparse][[/noparse]code]
repeat while (j==buffsize*4)· 'repeat until end of file
··· if (buff1[noparse][[/noparse]n]==0)
····· j:=sd.pread(@buff1, buffSize*4) 'read data words to input stereo buffer
····· if(buff1[noparse][[/noparse]n]==0)
······· buff1[noparse][[/noparse]n]:=1
··· if (buff2[noparse][[/noparse]n]==0)
····· j:=sd.pread(@buff2, buffSize*4) 'read data words to input stereo buffer
····· if (buff2[noparse][[/noparse]n]==0)
······· buff2[noparse][[/noparse]n]:=1
[noparse][[/noparse]/code]
Atached is my slightly altered version of PlayWav_16bitSreteo.spin from the object exchange.· one other thing to note is I changed the first part of the asm code so as not to break anything if·I accidentaly changed the order of the initialized variables.· It should still do what it's supposed to.
David
But, it's been a while...· I'll have to re-examine this to see if "0" corresponds to the middle of the range or an extreme of the range...
Post Edited (Rayman) : 3/20/2009 6:02:43 PM GMT
So, I would have to guess that a zero value means midrange. I would further guess that most files wouldn't stay at exactly zero for long due to noise at least, but because this was computer generated it does...
Anyway, the player definitely needs to be fixed! I'll add your code (if you don't mind) or something equivalent soon...
But, you're fix is also fine as the change in output is trivial. But, it doesn't change a 0 to a 1 until after the buffer is filled. This is a potential problem if the buffer is being read as it is being filled. But, you say you've tested it already and found it to work. Still, that could be a problem if the buffer size is reduced...