Page 1 of 1

streaming .wav music player

Posted: Fri Mar 03, 2023 4:13 pm
by desertfish
This program can play normal .wav sampled music files. Not only that, but it streams them from disk rather than loading it all in memory, so that there is virtually no limit on how long you want the music to play!

Personally I'm using sox and adpcm-xq to convert music to .wav, but you can create these with almost all audio tools.

Supported:
- 8 and 16 bit sample widths
- mono or stereo
- uncompressed or ima-adpcm compression with 256 bytes block size (mono only for now)
- up to 48828 Hz sample rate

In practice the sample rate is limited by the streaming speed from disk. (and adpcm decompression if applicable)
I've successfully played the following in the emulator :
- stereo 16 bit uncompressed at 16 kHz
- mono 16 bit adpcm at 17 kHz
- mono 8 bit uncompressed at 44.1 kHz

Mostly written in Prog8. Source code is here.

Re: streaming .wav music player

Posted: Thu Oct 12, 2023 8:28 pm
by voidstar
No luck on R44 playing some WAV samples found here:

https://archive.org/download/onclassica ... ical-music

Re: streaming .wav music player

Posted: Thu Oct 12, 2023 9:41 pm
by desertfish
No sound? or does it say "invalid format?"
Because it doesn't support all formats. Maybe I should improve the error message.

Ah, I think those wavs are 44.1 khz stereo, which is too much for the poor x16 to handle. Try converting it to mono or <=16khz first, and play that instead?
Anyway I've updated it with a more recent version that has some optimizations since the original was posted.

Re: streaming .wav music player

Posted: Fri Apr 19, 2024 12:37 am
by ahenry3068
desertfish wrote: Thu Oct 12, 2023 9:41 pm No sound? or does it say "invalid format?"
Because it doesn't support all formats. Maybe I should improve the error message.

Ah, I think those wavs are 44.1 khz stereo, which is too much for the poor x16 to handle. Try converting it to mono or <=16khz first, and play that instead?
Anyway I've updated it with a more recent version that has some optimizations since the original was posted.
44.1 khz 16 bit stereo seems to play ok when playing from RAM (i.e. Bloading a ZCM file). Sample size is necessarily short because that format takes up huge amounts of Ram. I wonder if you can stream it now with the new Disk enhancements in r47