Freeplaytech Forum
PSG library port - Printable Version

+- Freeplaytech Forum (https://forum.freeplaytech.com)
+-- Forum: Neo Geo Pocket (https://forum.freeplaytech.com/forumdisplay.php?fid=1)
+--- Forum: Homebrew (https://forum.freeplaytech.com/forumdisplay.php?fid=5)
+--- Thread: PSG library port (/showthread.php?tid=5147)



PSG library port - sodthor - 08-18-2020

Hi,

Here is a new sound library for ngpc, it's a free port of the PSGLIB (https://github.com/sverx/PSGlib)
It works a bit like the official one from snk: load driver and load music to z80 ram then play.
No SFX.
sources & demo rom attached.

thanks to WinterIsComing for help/comments/...

Edited: PCM playback added for SFX (8bit unsigned stereo PCM), thanks to mic_
09/04: z80 minimized

Thor


RE: PSG library port - sodthor - 08-18-2020

To add new songs: use psg tools (https://github.com/sverx/PSGlib/tree/master/tools)
vgm2psg (to transform vgm files to psg) and psgcomp (to compress a bit, because driver + songs must be less than 4k), then your favorite bin2c.

SMS songs are available here (for example): https://www.zophar.net/music/sega-master-system-vgm
or create your own with deflemask (https://deflemask.com/), target SMS.


RE: PSG library port - Flavor - 08-18-2020

Cool! Thanks, Thor!


RE: PSG library port - winteriscoming - 08-19-2020

Thanks for sharing and thanks for all the PMs as I was trying to figure some of this stuff out on my end.

The one thing I think is missing here is a tuner for SMS to NGPC.  They're clocked at different rates, so an SMS-tuned PSG note will be out of tune on the NGPC's z80.  I've got a script that can pre-process these and I can post here when I get to the point of releasing it.

There are normal tone commands that have to be tuned one way, and then third channel tone commands that affect periodic noise on the noise channel.  These have to be tuned and then adjusted from a 16 bit LFSR to 15 bit.  *Big thanks to mic_ for explaining this to me.


Conversion info as I have implemented it based on my understanding:

Normal tone tuning example:
SMS register value for tone channel 1023
SMS input clock 3580000

frequency 109.3597263
NGPC input clock 3070000
NGPC register val = input clock/frequency/32 877.2653631

Periodic noise tuning example:
SMS register value for tone channel 1023
SMS input clock 3580000
frequency 109.3597263
SMS periodic noise freq = freq/16 6.834982893
NGPC frequency = periodic noise freq*15 102.5247434
NGPC input clock 3070000
NGPC register val = input clock/frequency/32 935.7497207