PT3 Player - joric/ts80player GitHub Wiki
There are a few ways to play 3 or 6-channel AY-8912 music on small MCU's. You could render PSG stream (AY registers, usually 14 bytes at a time at 50 Hz) or you could parse PT3 modules.
PT3 players
- https://sourceforge.net/projects/zxssk C++ implementation (ported from AY_Emul code)
- ESPboy_PT3Play - Shiru C++ version ported from libayfly (bad envelopes in prove_fatal.pt3)
- pt3_play_zxssk.h plain C version, ported from zxssk and libayemu (slow but pretty accurate)
- pt3_play_shiru.h plain C, ported from shiru (faster than zxssk, but envelopes are messed up)
Modules are usually converted to .h files with xxd -i file.pt3
(standard UNIX tool, part of vim). Add const modifier for STM32 and const with PROGMEM for AVR to avoid RAM overflow.
STM32 source:
I've also started writing my own library to test out and benchmark AY emulation code:
Turbo Sound
Turbo Sound (TS, Turbo-AY) utilizes two AY сoprocessors so you get 6 channels instead of 3. Players support Turbo Sound and there are a lot of 6-channel PT3 files in the wild so there's no sense in stripping this option (it doesn't cost anything when you're playing 3-channel files).
PSG compressors
TBK PSG Packer
You could also play compressed PSG. I couldn't find a good streaming compressor except this one:
- http://psndcj.blogspot.com/2014/03/tbk-psg-packer.html TBK PSG Packer
It uses some kind of LZ-based codec with backreferences to the compressed data (not the decompressed one) so you don't need extra memory to stream it (no ring buffers, nothing). Compression is pretty good, about 20-30% of the file on average (better on big files). Unfortunately there is no decompressors available just yet (the existing one is Z80 asm, so you could port it to C as an exercise). Compressor is closed source and win32 only.