streaming .wav music player

Post Reply
User avatar
desertfish
Posts: 1095
Joined: Tue Aug 25, 2020 8:27 pm
Location: Netherlands

streaming .wav music player

Post 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.
Attachments
STREAM-WAV.PRG
(4 KiB) Downloaded 325 times
Last edited by desertfish on Thu Oct 12, 2023 9:46 pm, edited 1 time in total.
voidstar
Posts: 494
Joined: Thu Apr 15, 2021 8:05 am

Re: streaming .wav music player

Post by voidstar »

No luck on R44 playing some WAV samples found here:

https://archive.org/download/onclassica ... ical-music
User avatar
desertfish
Posts: 1095
Joined: Tue Aug 25, 2020 8:27 pm
Location: Netherlands

Re: streaming .wav music player

Post 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.
User avatar
ahenry3068
Posts: 1134
Joined: Tue Apr 04, 2023 9:57 pm

Re: streaming .wav music player

Post 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
Post Reply