TinySDDA v1.0 - SDcard sector R/W + stereo music + sound effects in one cog and (almost) no Hub RAM
Wuerfel_21
Posts: 5,052
So here's another one of these somewhat under-cooked objects...
What it does:
- Allow sector-level access to the SD card (both SDSC and SDHC/SDXC should work, but the former hasn't been tested yet)
- Allow partial sector reads and writes (partial writes will overwrite the non-written part of the sector with $FF, not super useful)
- Play signed 16 bit stereo audio from the SD card on the "music channel"
- Play A-law compressed mono audio from the SD card on the "effect channel"
- Play either at up to ~48 kHZ or both together at up to ~32 kHZ (sample rate is specified at startup, failure to keep up is graceful)
- Emit """subcode""" data - the first long (=left/right sample pair) of every music block (256 bytes) is written to Hub - the bottom 8 bits of either sample can be replaced with data without too much distortion...
What it doesn't (yet?):
- Use more than 5 longs of Hub RAM after startup
- Any sort of file-system operation (I think I could hack some version of FSRW onto it... haven't tried yet)
- Play audio from fragmented files
- SD card initialization - the card needs to be ready in SPI mode at startup (I've seen some pure-Spin SD init code somewhere (some version of FSRW also?), might dig that up)
- Properly support cards larger than 512GB (SFX stored above that limit won't work right due to address overflow)
- HiFi sound - aside from the fair amount of sampling jitter, the low speed SD read seems to generate an unusual amount of background noise
NOTE: A new version (v1.0) has been released! Scroll down to find it!
I've attached threw up on MEGA the object and a quick demo I tossed together - load the provided audio files (and SDDAWR.txt) onto your SD card, push some keys on your serial terminal, be amazed.
(A ZIP without any example audio files has been attached, aswell)
What it does:
- Allow sector-level access to the SD card (both SDSC and SDHC/SDXC should work, but the former hasn't been tested yet)
- Allow partial sector reads and writes (partial writes will overwrite the non-written part of the sector with $FF, not super useful)
- Play signed 16 bit stereo audio from the SD card on the "music channel"
- Play A-law compressed mono audio from the SD card on the "effect channel"
- Play either at up to ~48 kHZ or both together at up to ~32 kHZ (sample rate is specified at startup, failure to keep up is graceful)
- Emit """subcode""" data - the first long (=left/right sample pair) of every music block (256 bytes) is written to Hub - the bottom 8 bits of either sample can be replaced with data without too much distortion...
What it doesn't (yet?):
- Use more than 5 longs of Hub RAM after startup
- Any sort of file-system operation (I think I could hack some version of FSRW onto it... haven't tried yet)
- Play audio from fragmented files
- SD card initialization - the card needs to be ready in SPI mode at startup (I've seen some pure-Spin SD init code somewhere (some version of FSRW also?), might dig that up)
- Properly support cards larger than 512GB (SFX stored above that limit won't work right due to address overflow)
- HiFi sound - aside from the fair amount of sampling jitter, the low speed SD read seems to generate an unusual amount of background noise
NOTE: A new version (v1.0) has been released! Scroll down to find it!
I've attached threw up on MEGA the object and a quick demo I tossed together - load the provided audio files (and SDDAWR.txt) onto your SD card, push some keys on your serial terminal, be amazed.
(A ZIP without any example audio files has been attached, aswell)
Comments
Oh, btw...it seems to work fine on an old non-HD/XD (1GB) Sandisk card.
Cheers
For me it's significantly quieter and noisier than the real good stuff (aka NCOWAV.spin as found in PropPlay)... Then again, my board has a kinda decent filter(with those pretentious gold audio grade capacitors), some of the Parallax boards... don't... not sure about the HIB
It will catch the chops if you change the sample rate (last arg to sdda.start) to 44_100 and play sfx+music at the same time, if you want to witness that.
Good to know
The main changes:
- SFX channel is now a bit louder
- mono output is supported - just set the right pin to -1 and it will automagically patch itself to downmix the stereo audio to mono
MEGA Download with example files
It also cannot mount the sd card.
I am using the Propeller Activity Board WX, the sd card pins are set correctly and so are the audio pins.
Anyone else get this to work?
Other than that, I have no idea what the problem might be.
I'll try to play with it more.
You use a regular FAT formatted micro sd card? (not exfat)
Anyhow, you should be getting sensible output on your serial terminal. Can you post what you're getting?
Ya know, I do have other files on the sd card.. i can see if removing them helps.
Gosh, I think its dumping the ENTIRE FILE to the terminal right before it plays, I will post the first page of terminal dump.
but eventually played the "a" music file when I typed a and pressed enter.
Since I have your attention, can this play two Sfx at the same time?
And yeah, the example dumps all the clusters used by the files onto the terminal (while it is checking for the aforementioned fragmentation)
oh, ok. Since I have your attention, can this play two Sfx at the same time?
This DOES sound good!
So then that is two outputs at once.... I noticed that.
Ok thanks. Im looking for 6+ (up to 10) sfx or music channels to be played at once!
So far I have only found that I must mix the channels externally using multiple pin outputs, and that is only with code that can integrate reading the data also.
Thanks for the neat sound demo!