gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > Is the PSG worth it?

#126545 - 0xtob - Tue Apr 24, 2007 10:29 am

Hi!

I have a suspicion: The PSG might be emulated in software on the DS. If so, there would be no advantage in using it, and you could just generate the samples in software, as documented in gbatek.

To answer this question once and for all, I wrote a test program that plays back the same sound sequence one time using the PSG and one time using samples. And you have to guess what is what.

The program is available here:

http://tobw.net/ds/psg_vs_dac/psg_vs_dac.zip

Captured wav files and pictures of the waves are available on my blog:

http://blog.dev-scene.com/0xtob/2007/04/23/is-the-psg-worth-it/

Can you tell a difference?

Please post your guesses.

Thanks!
Tob
_________________
http://blog.dev-scene.com/0xtob | http://nitrotracker.tobw.net | http://dsmi.tobw.net

#126548 - LiraNuna - Tue Apr 24, 2007 11:09 am

Quote:
I have a suspicion: The PSG might be emulated in software on the DS. If so, there would be no advantage in using it, and you could just generate the samples in software, as documented in gbatek.


Ofcourse there's an advantage! Why emulate something that exists on the host machine? not to mention wasting resources to handle the emulation.
_________________
Private property.
Violators will be shot, survivors will be shot again.

#126555 - 0xtob - Tue Apr 24, 2007 1:19 pm

The PSG is limited to certain channels. There are six pulse channels and two noise channels only. The pulse tone is only 16 bytes, that are played in a loop, so it's not that much of a waste to emulate it in software. OK, for noise I need a longer sample in order to not make it sound periodic. But still, it would be some work to implement the PSG in NitroTracker, because I would have to limit the PSG instruments to certain channels (which might be confusing to the user) and treat them in a different way than PCM instruments. So, if there is no audible difference, I will go with the software solution.
_________________
http://blog.dev-scene.com/0xtob | http://nitrotracker.tobw.net | http://dsmi.tobw.net

#126577 - tepples - Tue Apr 24, 2007 5:52 pm

Advantage of psg: Multiple instruments can share the 8-byte sample, like .it instruments and unlike .xm instruments.

Advantage of psg: An instrument can use a phase envelope. I know a lot of instruments in Pro Wrestling, Punch-Out!!, and Super Mario Bros. 3 on NES used this.

A lot of existing custom music players use a degenerate envelope (like .s3m) for pcm instruments but an xm style envelope for psg instruments.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#126808 - xrl - Thu Apr 26, 2007 11:38 pm

B is the PSG. The sounds sound very distinct to me. Is the duty cycle the same?

Using the PSG is a lot better than using square samples (less code, different sound). In hardware doing a square wave is very simple so it probably is hardware generated, not a sample.

#126829 - tepples - Fri Apr 27, 2007 3:51 am

LiraNuna wrote:
Ofcourse there's an advantage! Why emulate something that exists on the host machine?

Because a single program might be designed to run on multiple host machines. Or because none of the existing .xm content at modarchive.com has PSG instruments. Or because you might run out of the six PSG tone channels and have to overflow into the first 8 channels, which are sample-only.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#127028 - xrl - Sun Apr 29, 2007 11:31 am

tepples wrote:
LiraNuna wrote:
Ofcourse there's an advantage! Why emulate something that exists on the host machine?

Because a single program might be designed to run on multiple host machines. Or because none of the existing .xm content at modarchive.com has PSG instruments. Or because you might run out of the six PSG tone channels and have to overflow into the first 8 channels, which are sample-only.

You can't mix rocks with aeroplanes! XM is XM. It's not made for PSGs. But you probably can emulate YM/AY very easily.

#127029 - kusma - Sun Apr 29, 2007 11:35 am

can the PSG be used to emulate adlib-support for proper S3M module playback? Not that I've ever seen an S3M-file who uses the adlib-features :P

#127041 - tepples - Sun Apr 29, 2007 3:13 pm

In theory, yes. But in practice, it's often hard to tell which of the four possible phases (12.5%, 25.0%, 37.5%, 50.0%) sounds like the current state of the FM synthesizer at any given time.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.