New Documentation: An authoritative reference on the YM2612

For anything related to sound (YM2612, PSG, Z80, PCM...)

Moderator: BigEvilCorporation

Snake
Very interested
Posts: 206
Joined: Sat Sep 13, 2008 1:01 am

Post by Snake »

Yes, that makes perfect sense. The distortion effect makes the sounds louder as well as making them sound quite different. I think this is probably the culprit here.

Good find, by the way, I can't believe I didn't spot that one myself.
AamirM
Very interested
Posts: 472
Joined: Mon Feb 18, 2008 8:23 am
Contact:

Post by AamirM »

No, in fact I was going to suggest that this topic gets renamed once Nemesis is ready to post his new info, because as he has now stated, most of the stuff in here is completely wrong.
Wait, I thought Nemesis said only SSG-EG stuff was wrong. If you think some other things are wrong as well, then please state the corrections. :D
Nemesis
Very interested
Posts: 791
Joined: Wed Nov 07, 2007 1:09 am
Location: Sydney, Australia

Post by Nemesis »

All the stuff I've posted about the phase generator and operator unit stands. The latest information I provided about those areas is all correct to the best of my knowledge.

There are some significant errors in the information I posted on the envelope generator, some of which I've already corrected, but a lot of which I have yet to correct. Most of the errors relate to SSG-EG mode. Apart from that, there's one error in my description of the interrupt line for the YM2612, which I'll post along with the envelope generator info, but I'm not aware of any other errors apart from that, so far at least.

Feel free to share any corrections you might have about what's been posted in this thread so far, or any further info you might have about the YM2612. Also let me know if there are things you suspect might be incorrect, and I'll re-test.
Snake
Very interested
Posts: 206
Joined: Sat Sep 13, 2008 1:01 am

Post by Snake »

I probably should have worded that differently :)
Nemesis wrote:All the stuff I've posted about the phase generator and operator unit stands. The latest information I provided about those areas is all correct to the best of my knowledge.
Yes, I haven't gone back and read over it, but from what I remember that part is all correct. However, this stuff is pretty straight forward, and as far as I'm aware, was already correct in the MAME core. In other words, it wasn't new information.
Nemesis wrote:There are some significant errors in the information I posted on the envelope generator
This is where I feel the problem is with this thread. Yes, I note that you'd made corrections before I'd even read it all, but its fairly difficult to find all the bits and pieces of correct info among the non correct info, which isn't really what the title of the thread states ;) It could do with cleaning up, but it'd probably be better in a new thread, because the discussion in here has still been interesting.

It really has been way too long since I really looked at this stuff, and I can't think of anything specific off the top of my head. But top of my list of things to try and determine right now, if I had the hardware to do it, would be this distortion stuff. We need to find out what gets fed into the DAC, i.e. the conversion from integer to 'floating point'. I'm fairly certain this is done very cheaply, is bugged, and thats where the error comes from. To me, this is much more important than some stuff already discussed in this thread. It affects all sounds in some way, whereas a lot of the things discussed aren't even used, or in some cases, such as the interrupt lines, can't be used.

Have you looked into this at all?
Snake
Very interested
Posts: 206
Joined: Sat Sep 13, 2008 1:01 am

Post by Snake »

Sorry to quote myself but:
Snake wrote:Yes, that makes perfect sense. The distortion effect makes the sounds louder as well as making them sound quite different. I think this is probably the culprit here.
CONFIRMED: on a Genesis 2, it sounds just like Kega.
Nemesis
Very interested
Posts: 791
Joined: Wed Nov 07, 2007 1:09 am
Location: Sydney, Australia

Post by Nemesis »

This is where I feel the problem is with this thread. Yes, I note that you'd made corrections before I'd even read it all, but its fairly difficult to find all the bits and pieces of correct info among the non correct info, which isn't really what the title of the thread states It could do with cleaning up, but it'd probably be better in a new thread, because the discussion in here has still been interesting.
I think what I'll probably do once I'm finished testing stuff on the YM2612 is actually what someone suggested ages back, and compile everything into a "YM2612 Undocumented" article or the like. Once that's done, it can basically replace this thread as a reference for information on the YM2612. For the time being, I think it's better that I just continue to post new information in this thread as I go.
It really has been way too long since I really looked at this stuff, and I can't think of anything specific off the top of my head. But top of my list of things to try and determine right now, if I had the hardware to do it, would be this distortion stuff. We need to find out what gets fed into the DAC, i.e. the conversion from integer to 'floating point'. I'm fairly certain this is done very cheaply, is bugged, and thats where the error comes from. To me, this is much more important than some stuff already discussed in this thread. It affects all sounds in some way, whereas a lot of the things discussed aren't even used, or in some cases, such as the interrupt lines, can't be used.

Have you looked into this at all?
It's on the to-do list. I'll probably cover the LFO first, then test the DAC. The good news is, I have a studio mastery grade audio card with a 120dB signal to noise ratio, so I can obtain some very accurate samples from the hardware at extremely low volume.

I don't think the distortion from the DAC itself is that bad though. I've observed a minor loss in precision, which is either due to the DAC or the accumulator, and of course there's the obvious jump between low volume and off, but I honestly think that by far the biggest factor is the external amplification/mixing circuitry that the YM2612 feeds into.
Snake
Very interested
Posts: 206
Joined: Sat Sep 13, 2008 1:01 am

Post by Snake »

Nemesis wrote:I don't think the distortion from the DAC itself is that bad though.
Oh, it is... (or rather, to be clear, the DAC itself should only have minor inaccuracies - its the data that's fed INTO it thats hideously innacurate.)
Nemesis wrote:and of course there's the obvious jump between low volume and off
Yes. But not only that, 'off' should happen way earlier than it actually does. The difference between what's supposed to happen and what actually happens is HUGE, and as I've just had confirmed, makes the difference between instruments in afterburner being heard very clearly, and not at all...
Eke
Very interested
Posts: 885
Joined: Wed Feb 28, 2007 2:57 pm
Contact:

Post by Eke »

Snake wrote:Yes, that makes perfect sense. The distortion effect makes the sounds louder as well as making them sound quite different. I think this is probably the culprit here.

Good find, by the way, I can't believe I didn't spot that one myself.
I guess I learn something new every day
is there an accurate way to emulate that "distortion" and, more generally, any side effects/filtering introduced by the sound output circuitry ?
TmEE co.(TM)
Very interested
Posts: 2452
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) »

What Afterburner BGM are we talking about ? I've got to do a recording...
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
Snake
Very interested
Posts: 206
Joined: Sat Sep 13, 2008 1:01 am

Post by Snake »

Eke wrote:is there an accurate way to emulate that "distortion"
There will be, yeah, but first we need to know exactly what happens. That's what I'm trying to convince Mr. Nemesis to test next ;)

TmEE - the track is 'super stripe'. I was hoping you'd turn up to provide a CCAM version :)
Nemesis
Very interested
Posts: 791
Joined: Wed Nov 07, 2007 1:09 am
Location: Sydney, Australia

Post by Nemesis »

Man, this After Burner II music goes nuts. I honestly spent 10 minutes thinking I was listening to an entirely different tune.

You know what, I think I know what causes this, and the answer has already been posted in this thread by someone else. HardWareMan discovered awhile back that the output from the YM2612 is multiplexed. Based on experiments I carried out on my emulator with multiplexed output, this DOES cause an audible difference in some sounds, and I don't even want to think about what the audio output circuitry in the Mega Drive would do to that multiplexed signal. It would probably compress everything together a little, amplifying the low volume channels, and softening the high volume channels. The greater the variance, the greater the effect.

It's the same kind of problem as with the PSG when it hits super-high frequencies. Speaking of the PSG, I've noticed previously that After Burner II runs every channel of the PSG at maximum frequency, around half volume constantly. This PSG signal is also getting mixed with the YM2612 output, and it's possible that the PSG is introducing some destructive interference, cancelling out some of the output from the YM2612.


I've just run some tests on this After Burner II track in my emulator using experimental multiplexed output. I generated wave logs for both combined and multiplexed outputs at their native bitrate, and ran them through Adobe Audition (to take advantage of their groovy output resampling), and there's no doubt that the multiplexed output not only sounds very different to the combined output, but it also sounds much closer to the real hardware.

I've got a feeling that the only way to get this "output distortion" to sound right all the time is to generate a true multiplexed output for the YM2612, correctly generate the full high frequency output from the PSG, faithfully emulate the mixing hardware in the Mega Drive to mix and distort the output, and use some sort of killer resampling algorithm to step down from the super high frequency output we've just generated (over 220KHz for the PSG, and over 310KHz for the multiplexed YM2612) to something the average computer can actually output (around 48Khz), without altering the tone. Ouch.
TmEE co.(TM)
Very interested
Posts: 2452
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) »

The answer to your problem is in accuracy, current emulators are doing the sound too accurately compared to real HW... the After Burner uses very attenuated FM to get it around same levels to PSG which is used for samples so that FM would not overpower PSG... however, YM2612 is not having too great resolution output, and quiet sounds are quite hard to hear as they're very aliased (especially on real YM2612, MD2 ASIC is a bit more accurate). The sounds you hear in emulators are present on real HW, but they're quite aliased and are hard to notice in the sea of aliasing noise. When you mess with 8-bit WAVs, you always try to record in highest possible volume so you would hear less of the aliasing noise.

Here's the recording (a shitty medley with all tunes) :
http://www.fileden.com/files/2008/4/21/ ... TRBRN2.ogg

And 22KHz WAV sounds better on MD than on anything else :P
http://www.fileden.com/files/2008/4/21/ ... KOZMOZ.RAR
(to get original WAV, rip it off the BIN, I've clearly marked the point)
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
GManiac
Very interested
Posts: 92
Joined: Thu Jan 29, 2009 2:05 am
Location: Russia

Post by GManiac »

Why are you both talking about PSG and that PSG at high volume muffles/damps YM2612 or cancelling some of YM2612's output? I said that in 2nd test I CUT OUT all writings to PSG and tones 1, 2 from VGM file and played this VGM on hardware and you can see that emulator still playing the same as with all tones and PSG.

...Hmmm, I listened to "Super Stripe" from CCAM'ed MD2 and... I don't like it :( But, though those instruments play quietly, right as in emulator, they still sound closer to my MD2, not to emulator (you say they are "distorted"). Okay, here's my vgm:
http://shedevr.org.ru/ghost/SS_PSG.7z
Don't pay attention to incorrect loop offset, I'm too lazy to correct it.

Also, in this huge recording of After Burner tunes there are strange clicks in "Final Take Off" tune (seconds 28-40). It's wrong of course.

Though in this topic someone named various chipsets and YM2612 variations, it seems that there's no any etalon :( In one cases one console sounds better, in other it sounds worse. It seems, the only way is to allow to choose chipset and other factors in emulator, but user still WILL HAVE to choose the best factors.

TmEE, can you desribe in detail what model did you use? I used Asian PAL MD2 (Chinese clone) MK 1631-07 and European MD1 PAL 1600-05 and they sound identical (MD2 sounds a bit clearer).

upd: to make sure that I provided right playing of tune (with loud "instruments") you can listen to other versions of After Burner (NES, 32X and others) - they are loud there too.
Snake
Very interested
Posts: 206
Joined: Sat Sep 13, 2008 1:01 am

Post by Snake »

Nemesis wrote:You know what, I think I know what causes this, and the answer has already been posted in this thread by someone else. HardWareMan discovered awhile back that the output from the YM2612 is multiplexed.
Yeah, thats one of those things thats completely incorrect. What do you think the accumulator does? I thought you'd covered this already.

It's the DAC distortion, I'm telling you. This stuff is exactly in the range where the distortion is most noticable. But if that's not convincing, there's nothing else that explains why this does not happen on an MD2.
TmEE wrote:however, YM2612 is not having too great resolution output
Well, this is the point. It does - or - it's supposed to. The DAC is designed to lose accuracy at higher volumes and retain it at lower volumes. But I'm convinced there's a bug there that causes it to lose accuracy all the time, under the right conditions. This bug is probably fixed in the later models so all you are left with is the fairly minor distortion caused by the fact it does this at all.
GManiac wrote:you can listen to other versions of After Burner (NES, 32X and others) - they are loud there too.
Indeed, I don't think anybody is saying that the tune isn't supposed to sound like the file you posted. It definitely should, and when you pointed this out, I noticed you were correct right away. I listened to this stuff for hours with headphones back when it was released :)

But, It, like most other Genesis/MD music, was created on an MD1. The official MD2 does not have the same level of distortion, so it will sound very different, which you can now hear for yourself. I guess your clone is closer to a real MD1.
GManiac wrote:I don't like it
No, me neither ;)
GManiac wrote:In one cases one console sounds better, in other it sounds worse
I wouldn't worry about it. How it sounds on an original MD1 is how its supposed to sound, and this is going to be true for everything. That's the one to focus on.
Nemesis
Very interested
Posts: 791
Joined: Wed Nov 07, 2007 1:09 am
Location: Sydney, Australia

Post by Nemesis »

Snake wrote:
Nemesis wrote:You know what, I think I know what causes this, and the answer has already been posted in this thread by someone else. HardWareMan discovered awhile back that the output from the YM2612 is multiplexed.
Yeah, thats one of those things thats completely incorrect. What do you think the accumulator does? I thought you'd covered this already.
Sorry, but the output from the YM2612 is definitely multiplexed. The accumulator combines the output from operators, it does not combine the output from channels. The output from the YM2612 is multiplexed. Hook up an oscilloscope to the output and you can see it. I can also see it (although not enough to get a complete sample of each individual channel) when I record at 192KHz.
It's the DAC distortion, I'm telling you. This stuff is exactly in the range where the distortion is most noticable. But if that's not convincing, there's nothing else that explains why this does not happen on an MD2.
Maybe you're right. I will run tests on the DAC. There are other things I want to test first however. It makes sence to figure out things "higher up the chain" first. The DAC is also crossing into the analog domain, so it's going to be much harder to obtain precise results.
Post Reply