16-bit PCM .wav file audio player
Rayman
Posts: 14,633
Finally got around to updating this with latest FSRW.
Could also use FAT32 instead if need folders...
Also here are versions that plays from flash and from HUB RAM.
Comments
Tested with P2 Eval board with audio file on uSD card and A/V accessory on pin group P0..P7
We have also mp3 decoder for a P2:) (in C)
https://gitlab.com/pik33/P2-retromachine/-/blob/main/Propeller/P2P16/mp3.c?ref_type=heads
MP3 would be better if want to have audio files on flash, so good to have, thanks @pik33
I think you have a player for other file types too, right?
Thanks to @JonnyMac , this version probably has a better txflush() routine in the serial driver (if I did it right).
Yes. That's the way Chip showed me how to read the TX pin busy flag -- and it solved an odd problem I was having with a project.
Speaking of different formats, I think I already posted this somewhere, but I've actually designed a custom codec that doesn't use much more resources than a straight wave player but compresses at 4.39 to 1 ratio (for 32kHz that comes out to ~232 kbit/s, which crucially is at most one 512 byte sector that has to be buffered per 60Hz video frame). https://github.com/Wuerfel21/Heptafon (check the propeller2 folder... also here's some sample files if you don't want to deal with the wonky C++ encoder)
Though it's really optimized for P1 rather, on P2 you could spend more cycles and make use of fast multiply to get more quality out of the same bitrate.
Yes, the repository that I linked, where this decoder code is, is the player repository. It is configured for P2-EC32 board, but can be adapted to work on anything that has an external ram that can be driven by rogloh's driver.
Plays .wav, .mp3, .sid/.dmp, .mod and .spc and of course is still buggy but works. Now when Flexprop supports flash file system It can be updated to use flash too.
Doing some testing today, trying to get this to work from flash instead of uSD.
Think about have it.
But, along the way, decided the signed math in the previous version wasn't quite right.
Reverted to the unsigned math way from the original P1 version...
Ver.2e in top post.
Just noticed that the cog is hardcoded to #2 in the previous posted examples...
Seems I couldn't figure out why this didn't work:
But, now I see you can do << with a register contents.
Fixed like this now (hopefully):
Just made a version that plays a wav file embedded in HUB RAM.
Will put in top post...
instead of
you want