Shop OBEX P1 Docs P2 Docs Learn Events
SD WAV player — Parallax Forums

SD WAV player

David BDavid B Posts: 592
edited 2012-08-15 16:21 in Propeller 1
I was asking rokiki about modifying sdspi to allow two or more files to be opened for reading at the same time, for a new project.

A museum volunteer asked if I could help add sound to his antique airplane museum exhibit. Pretty simple - there are two buttons. Push a button, a sound plays. One button plays an engine start sound and another plays some air traffic control background sound. But they may be pushed at any time, in any order, repeatedly.

Some time ago I made my own propeller SD/MMC reader and WAV player, which is why the volunteer asked me about this. The SD access probably wasn't as fast or as general as rokikis but it still was able to read and play 16 bit 44 kHz stereo WAV files, but only one file at a time. The WAV cog buffered enough data so after the end of each FAT16 cluster, there was time for the card cog to read the FAT sector to find the location of the next cluster before the WAV cog ran out of samples to play.

Rokiki, I just installed your sdspi code version 1.4 onto my existing WAV player board to try it out. The SD access worked great! All I had to do was change the pin number base and rearrange the order of pin addressing to match my board, and it worked, first try, even when using sdspiqasm, the fastest access mode. I didn't test its speed; all I did was to open a text file for reading, by name, and display its contents on an LCD to make sure the card would open, the file could be found and the data accessed, and everything worked perfectly.

I don't think that data retrieval speed will be a problem for this project. The volunteer sent me a sample of one of the WAV sounds that he wants to play - it's 8 bit, 11 kHz, mono, so I don't think speed will be a problem, even if 3 or 4 of these were to play simultaneously, although he only asked for two.

I'm hoping to have multiple sound channels, where each channel will open a file, read data from it, add its data into a hub buffer, and a separate WAV player cog will read data out of that buffer and play it, until the file is empty. I need at least two of these channels. That seems like a very general sort of object, doesn't it? If it's generalized enough to allow two channels, then I'd think that 3 or 4 should also be possible, as long as the card can feed data fast enough, which at 11 kHz 8 bit mono, I'd think that it could.

That's the plan. My WAV player cog is working, but is pretty crude - it will play a WAV to the end, but doesn't reset properly after the end, and it also isn't generalized enough to be spawned off in 2 or more instances. So there's plenty of work to do...

David

Comments

  • jcullins0jcullins0 Posts: 10
    edited 2012-08-15 16:21
    How do you change the volume on the SD-wave player? I have it working fine but sound is low.
    Jim
Sign In or Register to comment.