PSG mixing volume?

Official support forum for the Exodus Emulation Platform

Moderator: Nemesis

Post Reply
nothingtosay
Newbie
Posts: 3
Joined: Wed Dec 18, 2013 5:19 pm

PSG mixing volume?

Post by nothingtosay » Wed Dec 18, 2013 6:10 pm

Hi Nemesis. Thanks for all your hard work on this project. I look forward to your future updates and Exodus becoming an accurate, multi-platform emulator.

From what I understand, you have achieved the best sound emulation of any Genesus emulator. (Side question: in your very informed opinion, how accurate is it?)

I want to record some music, but when I record the mixed output of the PSG channels I get some seriously glitched audio back. Recording them individually works properly, however, they're much louder than when mixed. Which is fine, I'm perfectly happy to mix the channels myself along with the YM2612, I just need to know how much exactly is the PSG volume supposed to be reduced?

User avatar
Nemesis
Very interested
Posts: 670
Joined: Wed Nov 07, 2007 1:09 am
Location: Sydney, Australia

Post by Nemesis » Fri Dec 20, 2013 4:41 am

From what I understand, you have achieved the best sound emulation of any Genesus emulator. (Side question: in your very informed opinion, how accurate is it?)
It's very accurate. The PSG is 100% correct to my knowledge, with all internal calculations being done in the same way and at the same rate as the original chip, and even the power-on defaults being correct. The YM2612 is mostly spot on. I know I've got an internal issue with CSM mode which very intermittently causes one cycle to occur at the wrong time, which I know how to fix up I just haven't had time to address it. There are also some remaining questions surrounding a couple of points of behaviour which I have yet to perform hardware tests on, so there may be some, almost certainly inaudible, inaccuracies in those areas, I won't know for sure until I go back and complete that testing, and I know there are some precision issues with the DAC that need to be addressed. None of this should make any audible difference though, and it's just a few isolated areas that can be addressed and made absolutely perfect with just a bit more work.

The biggest issue is actually outputting the generated audio stream on your computer. On the real hardware, a lot of audio devices output at a much higher sample rate than your computer can manage. The PSG outputs at around 223KHz from memory, and your average PC sound card can usually only output a signal at around 48KHz at best. Now, you may think that doesn't matter, since a human can only hear up to around 20KHz, but it's not that simple actually. In reality, any frequency, no matter how high, can make a massive audible difference, if that signal is also varying in amplitude. There's an issue with the PSG for example when playing some games like After Burner II, where a wave is being generated at the maximum sample rate the chip can handle. You can't hear this at all normally, but they're actually using this ultra high frequency signal as a "carrier wave". By varying its amplitude at high speed, they actually produce a lower frequency wave running peak to peak across the carrier signal.

The issue here is, simply performing linear re-sampling of a high frequency carrier wave like this down to 48KHz is effectively going to cause the positive and negative oscillations of the wave to cancel each other out. The effect of that is that the signal that's being piggybacked off it basically disappears too, so just from resampling the audio, you've destroyed the audible waveform.

Most emulators cheat here right now, by making a maximum frequency PSG wave not oscillate at all, so filtering doesn't decimate any signals piggybacked off it. This is inaccurate, and simply decreasing the frequency one step will cause a similar decimation. I haven't done this in Exodus, since I want to keep the core accurate, but I do need to research resampling techniques and find out if there's a better way I can downsample the audio for playback so that the audible waveforms will be best preserved during the resampling.
I want to record some music, but when I record the mixed output of the PSG channels I get some seriously glitched audio back.
I'll have to look into that. I'm not aware of any problems in that area, the wav logging basically just gets given the sample output buffers, which are the exact buffers that are then resampled and sent for playback from your sound card. If the output logging was messed up, I'd expect the playback to be messed up too.
Recording them individually works properly, however, they're much louder than when mixed. Which is fine, I'm perfectly happy to mix the channels myself along with the YM2612, I just need to know how much exactly is the PSG volume supposed to be reduced?
The mixing of audio is entirely in the analog domain. The apparent difference in volume levels between the YM2612 and PSG can, and does, vary based on the particular system model, since it depends on exactly how the mixing hardware is wired up, or even between two given "identical" systems, since it depends on the actual effective rating each component has, and each one will vary slightly between systems within a tolerance.

All that said, for Exodus, I currently use a magic "divide by 6" value to scale the PSG volume level to roughly match the YM2612 volume. The PSG is much louder, and this divide seems to match them approximately to the level I hear from the real hardware. This is really inaccurate and unscientific though, it's more just a number I pulled out of the air about 5 years ago and thought "that sounds about right". What I'll be doing in a future version of Exodus is providing an output attenuation value for each audio device which can be set in the system definition, so you basically do the "mixing" between the different devices in the XML file rather than being hardcoded in the cores like it is now.

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

Post by TmEE co.(TM) » Fri Dec 20, 2013 8:09 am

The divide by 6 is not so far from the truth, I just looked in my music tools and it does ~6.4
Just 6 seemed a bit too loud when referencing to hardware I have around. Though there most definitely is variation within models, and not very small ones.
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

nothingtosay
Newbie
Posts: 3
Joined: Wed Dec 18, 2013 5:19 pm

Post by nothingtosay » Fri Dec 20, 2013 3:51 pm

Thanks for the long reply! It has always been impressive to me the way you programmers understand so many things. Many people who specialize in audio don't have the level of understanding of how digital audio works that you do (unfortunately). I appreciate the explanation! I also appreciate minor, even inaudible things to make emulation more accurate.

Odd the After Burner II composer/sound programmer didn't just generate the wave he wanted at the desired frequency instead of generating one so high up to then create one lower. I guess there must have been some reason to do it that way. Interesting the things these guys did to get what they wanted out of the old sound chips. That's such a weird case that I doubt anyone designing resamplers has had that in mind when doing so to preserve it. Good luck in finding a way to do it.

Does anybody else have the problem I do when trying to record the PSG's mixed output? It's seriously messed up. Like it's playing way too fast, but with a big dose of added distortion. I'm doing nothing differently when recording or when resampling for playback compared to when I record the separate channels and they come out right.

Thanks to both of you for your input on the volume adjustment. I'll keep it in that range when I combine the PSG with the FM. I initially tried -20 dB (10% of original) but I discovered that was a bit too much. Divided by 6 is 16 ⅔% which is -15.56 dB and dividing by 6.4 is 15.625% and hence -16.12 dB, so that's in the area I was expecting. It's hard for me to make a precise determination even in matching the hardware recording I'm using for reference because the Genesis's analog output sounds so different. The treble loss is crazy and that's exactly the PSG's chief domain.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest