TinySDDA v1.0 - SDcard sector R/W + stereo music + sound effects in one cog and (almost) no Hub RAM

Wuerfel_21Wuerfel_21 Posts: 980
edited 2020-08-06 - 18:00:25 in Propeller 1
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)

Comments

  • Nice...got this working on a Quickstart w/HIB...not an audophile by any means, but it sounds good to me. The sfx playback is snappy too - holding down an sfx key for many seconds while the music is playing doesn't produce any perceivable choppiness in the music, the sfx repeats fast and doesn't have any "queuing" effect, where it keeps going after the key is released.
    Oh, btw...it seems to work fine on an old non-HD/XD (1GB) Sandisk card.

    Cheers
  • Wuerfel_21Wuerfel_21 Posts: 980
    edited 2020-08-02 - 00:33:24
    avsa242 wrote: »
    Nice...got this working on a Quickstart w/HIB...not an audophile by any means, but it sounds good to me.

    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


    avsa242 wrote: »
    The sfx playback is snappy too - holding down an sfx key for many seconds while the music is playing doesn't produce any perceivable choppiness in the music, the sfx repeats fast and doesn't have any "queuing" effect, where it keeps going after the key is released.
    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.
    avsa242 wrote: »
    Oh, btw...it seems to work fine on an old non-HD/XD (1GB) Sandisk card.
    Good to know
  • Wuerfel_21Wuerfel_21 Posts: 980
    edited 2020-08-06 - 17:58:03
    I think this object is now stable enough for a non-preview release, so here it is.

    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
  • I seem to be doing something wrong, I get garbage all over my terminal screen when I try this.

    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?
  • Hmm I was able to get it to work on a QS with HIB, I think... It's been a few weeks since I tried it... Will have to verify after work
  • Garbage on the terminal? Are you sure the baud rate is matched?

    Other than that, I have no idea what the problem might be.
  • Thats odd, because my test of various other sound projects that use the sd card, worked.
    I'll try to play with it more.
    You use a regular FAT formatted micro sd card? (not exfat)
  • Wuerfel_21Wuerfel_21 Posts: 980
    edited 2020-09-01 - 16:02:08
    Yes, normal fat (tinySDDA itself doesn't have any filesystem support, so the example uses KyeFAT to find the files on the SD card) (Integrating this with FSRW is something that's uhh.. somewhere down there on my todo list)

    Anyhow, you should be getting sensible output on your serial terminal. Can you post what you're getting?
  • Clock LoopClock Loop Posts: 1,976
    edited 2020-09-01 - 16:14:01
    I use putty, could that be the issue? (I don't know why tho)

    Ya know, I do have other files on the sd card.. i can see if removing them helps.
  • Clock LoopClock Loop Posts: 1,976
    edited 2020-09-01 - 16:25:23
    Ok, it still dumps a TON of stuff to the terminal,
    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?

  • Hmm, unrelated files shouldn't be causing issues. (But the audio files being fragmented WILL cause an error)

    And yeah, the example dumps all the clusters used by the files onto the terminal (while it is checking for the aforementioned fragmentation)
  • Clock LoopClock Loop Posts: 1,976
    edited 2020-09-01 - 16:33:50
    Wuerfel_21 wrote: »
    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!
  • No, only one at a time. However, the music channel can play one-shot sounds, too (the only difference between the music and sfx channels is the sample format and block size)
  • Wuerfel_21 wrote: »
    No, only one at a time. However, the music channel can play one-shot sounds, too (the only difference between the music and sfx channels is the sample format and block size)

    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!
Sign In or Register to comment.