SOUND: SN76489 PSG "SID" sound

Announce (tech) demos or games releases

Moderator: Mask of Destiny

Post Reply
Aly James
Very interested
Posts: 74
Joined: Sun Mar 31, 2013 11:34 pm
Location: FRANCE
Contact:

SOUND: SN76489 PSG "SID" sound

Post by Aly James » Sat Nov 30, 2013 3:00 pm

Nothin new but simple proof of concept that we simply can add the "SID" sound feature to a simple SN76489 PSG tone channel...
I have tested the Z80 Hblank interrupt and use it as a Timer to write Volume data to the PSG register at audio rate...
As far as the timer resolution goes, we can synchronize to the Tone period in near 1 useful octave range for NTSC or PAL and 2 octave for a discrete down clocked SN76489.
We can also use the Timer waveform alone to play notes below the 10bit frequency limitation of the PSG (109Hz for NTSC, 108 for PAL)
As for any clocked frequency method the pitch resolution increase as you increase the wave period. good for bass!

Anyway, this feature will be available on my upcoming Super PSG Vsti :)

Here is a test on emulator then on the Sega Megadrive PSG:
Only 1 channel is used.
http://youtu.be/08Sm8BL-BF4

Here is the feature implemented in the PSG Vsti (beta)
(you might see some AY3 8910 EG at some point, this is because I have emulated this feature to add Buzz and SyncBuzz type sound to the Sn76489...also added ability to play PCM or PWM samples!)
http://youtu.be/ZRCEDi-DbVI

Last but not least, an implementation of the same feature on a discrete SN76489 chip controlled by a micro-controller (that will optionally work with my vsti too)
http://youtu.be/pm8b83xhCoE

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Sun Dec 01, 2013 5:49 am

I never thought of using this approach, but then again it is not very usable in a game environment (Hint eat lots of power).
But same kind of stuff can be got by playing samples over the channels, but that can end up using lot of space, and CPU time is still scarce on the Z80 side...
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

Aly James
Very interested
Posts: 74
Joined: Sun Mar 31, 2013 11:34 pm
Location: FRANCE
Contact:

Post by Aly James » Sun Dec 01, 2013 5:17 pm

TmEE co.(TM) wrote:I never thought of using this approach, but then again it is not very usable in a game environment (Hint eat lots of power).
But same kind of stuff can be got by playing samples over the channels, but that can end up using lot of space, and CPU time is still scarce on the Z80 side...
I agree that I usually not consider the interaction with a Game engine running at the same time when I do audio stuff :)
But the SID effect only writes (0x00, ...wait x overflow,0x0F,...wait x overflow) in a loop to the PSG volume register...does it really eats a lot?
In this case is there a better way to have a timer ?
not that I need it for my application but it is good to know from you :)

:) :) :) I thought about a chip decap to get the PSG frequency counter overflow but it will probably not happen :) :) :)

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Sun Dec 01, 2013 5:25 pm

HINT every line can easily eat over half the CPU power, which is unacceptable for many games.
On Z80 side doing this alone is not much of a problem, but doing all other stuff like FM and PCM playback makes things much less manageable.

I tend to look things from game environment perspective, rather than just music making :P
Just music making i would have a softsynth instead, the Z80 or 68K are both powerful enough for couple channels of chipsounds generation at decent enough sample rate, I would use the PSG as a crude DAC of sorts. I think you get where I am pointing at here :)

As for freq counter overflow you can do that on Game Gear, in a way. The chip has analog loopback of every channel and you could use one channel as the overflow indicator (level change means overflow :P).
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

Aly James
Very interested
Posts: 74
Joined: Sun Mar 31, 2013 11:34 pm
Location: FRANCE
Contact:

Post by Aly James » Sun Dec 01, 2013 7:09 pm

Nice infos! My point was to look at it on a Master System way without YM2413, even if I tested it on a Genesis :).

By the way I have a question, I have implemented PCM and PWM sample playing in my upcoming Super PSG vsti. For now the user can import samples that will be played at 44.1 , 22, 11 or 8khz through the volume register.
If you set apart what would be needed for Game engine etc... is there a limit in the sample rate that can really be streaming without missing writes etc...
in other words do i have to apply a down-sampling for the sake of fidelity ?
I did not find to many infos about that and I know you did a lot of PCM playback on the PSG :)

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Mon Dec 02, 2013 8:50 am

The big problem with sample playback is that it needs to have consistent invervals between sample writes. That makes it incredibly hard to use in any game scenario and is the reason why games stop when samples play. It would be possible to make a game engine that has a sample write sections all over the code but it would be quite a nightmare to manage ^^

As for downsampling, you may do that, but probably should but the effects are hard to notice as the almost 3 bits of info the PSG can give makes up for very very noisy sound and the noise overpowers all else.
You can enhance sound quality a little by taking the logaritmic scale into account when converting the sample for PSG environment.
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

Aly James
Very interested
Posts: 74
Joined: Sun Mar 31, 2013 11:34 pm
Location: FRANCE
Contact:

Post by Aly James » Mon Dec 02, 2013 11:09 pm

I read somewhere that people used to rescale for example a signed waveform (0x0 -0xFF) keeping only the positive part to output through the PSG... I prefer to rescale the whole waveform (0x0 -0xFF) to (0xF - 0x0)
witch gives me better result. As for the Db scale of the PSG I kinda like what it does to the wave-shape :) even if it makes the sample quieter than rescaling first.
It is sort of a transient enhancer.
Outputting to 2 or 3 channels at the same time kinds of cover the lost of power.
For brute force there is still PWM :)

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Tue Dec 03, 2013 10:06 am

http://www.tmeeco.eu/BitShit/SMSPCM0.SMS
http://www.tmeeco.eu/BitShit/SMSPCM1.SMS

This demonstrates difference between taking and not taking the log scale into account.

Here's original : http://www.tmeeco.eu/BitShit/GreenHillsXGremixLOOP.flac
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

Aly James
Very interested
Posts: 74
Joined: Sun Mar 31, 2013 11:34 pm
Location: FRANCE
Contact:

Post by Aly James » Sun Dec 15, 2013 7:23 pm

Yep that showcases well the effect, I have had similar results on my side.
thanks for that ;)

Post Reply