New Documentation: An authoritative reference on the YM2612

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

Moderator: BigEvilCorporation

Eke
Very interested
Posts: 884
Joined: Wed Feb 28, 2007 2:57 pm
Contact:

Post by Eke » Mon Feb 22, 2010 8:56 am

blargg wrote:Here are some recordings (sorry for mp3, as I lack FLAC or anything modern): genesis_recordings.zip (2.6 MB; let me know if you have problems, as this host sucks)
yeah, it seems I can't download them :wink:
Yeah. I just modified the channel muting mask from ~0 to ~((1 << 7) - 1). This preserves the sign bit. This was in the MAME version, where it applies this mask to each channel, sums them, divides by 2, then outputs that.
divide by 2 ?

I don't think it could be that, because some of the example tracks above have a tone fading out, yet it's still grossly quantized by the DAC. If it were floating, those would fade out smoothly as on most YM2612 emulators.
Where do you take your recording from btw ?
I don't know, there is circuitry filtering coming in account too, and differences between MD1 & MD2 (I had a look at schematics some time ago and, while MD1 seemed to have only a low pass filter @~26.7 khz and a DC removal capacity before the stereo mixing chip, MD2 had slightly more "destructive" high-pass and low-pass filters, something like 7Khz for LP if I recall correctly)

blargg
Newbie
Posts: 7
Joined: Sat Feb 20, 2010 6:27 am

Post by blargg » Mon Feb 22, 2010 10:52 am

Eke wrote:yeah, it seems I can't download them :wink:
OK, try this mirror: genesis_recordings.zip
blargg wrote:Yeah. I just modified the channel muting mask from ~0 to ~((1 << 7) - 1). This preserves the sign bit. This was in the MAME version, where it applies this mask to each channel, sums them, divides by 2, then outputs that.
Eke wrote:divide by 2 ?
6 channels, each in the range -8192 to +8191, totals -49152 to +49146. Dividing by 2 reduces the range to -24576 to +24573, so it'll fit within a 16-bit sample without any chance of overflow.

I was able to modify your YM2612 as described above:

Code: Select all

ym2612.OPN.pan[ c*2   ] = (v & 0x80) ? ~((1 << 7) - 1) : 0;
ym2612.OPN.pan[ c*2+1 ] = (v & 0x40) ? ~((1 << 7) - 1) : 0;
Where do you take your recording from btw ? I don't know, there is circuitry filtering coming in account too, and differences between MD1 & MD2
US MD1 (the revision that shows the "licensed by sega" at the beginning no matter what cartridge you insert).

Eke
Very interested
Posts: 884
Joined: Wed Feb 28, 2007 2:57 pm
Contact:

Post by Eke » Mon Feb 22, 2010 11:13 am

OK, try this mirror: genesis_recordings.zip
ok, that one works.
6 channels, each in the range -8192 to +8191, totals -49152 to +49146. Dividing by 2 reduces the range to -24576 to +24573, so it'll fit within a 16-bit sample without any chance of overflow.
Well, shouldn't we just apply a limit like it was done in the original core ? By doing this, you are reducing FM output level (relative to PSG)... I think it's not very common that all channels are set to max, hence why a limiter was used but I wonder which solution is best.

(and this remind me I removed the limiter and forgot that clipping/overflow could still occur when adding channels, thanks)
I was able to modify your YM2612 as described above:
Code:
ym2612.OPN.pan[ c*2 ] = (v & 0x80) ? ~((1 << 7) - 1) : 0;
ym2612.OPN.pan[ c*2+1 ] = (v & 0x40) ? ~((1 << 7) - 1) : 0;
edit: i tested similar modification quickly (WB5 intro tune) and it indeed "seems" that emulating DAC precision affects the sound output similar to your recording. There is some channel in background at the beginning of the track ((buzzing static sound) that is not so much audible on emulator but starts to be audible when lowering DAC precision.

However, I found out that lowering below 9-bits precision make the buzzing noise too loud and affect other channels as well, in a very different way than real hardware on therecording: 9-bits (~((1 << 5) - 1)) seemed the most accurate to me.

Still, I 'm not sure if that's the exact way to emulate it: Steve Snake was somehow referring to a DAC issue with negative values, where low values were being output much more louder than they should (much more than if it was simply lower bits precision loss), it seems it's the same issue here.

I guess the only way to be sure would be to write a program that output a range of possible sample value (from -256 to 255 for example) on a channel and measuring chip output directly.

Anyway, can you point me to particular effects to listen in your recordings that sound completely differently in an emulator ?

blargg
Newbie
Posts: 7
Joined: Sat Feb 20, 2010 6:27 am

Post by blargg » Mon Feb 22, 2010 11:21 pm

Eke wrote:Well, shouldn't we just apply a limit like it was done in the original core ? By doing this, you are reducing FM output level (relative to PSG)... I think it's not very common that all channels are set to max, hence why a limiter was used but I wonder which solution is best.
It's definitely rare, or maybe absent from anything real (even that crazy Castlevania stage end doesn't overflow when you remove the divide by two). But doing the clamping there is wasteful since you have to clamp again when you're mixing the PSG in later. And it's conceptually better to avoid clamping here because that's not what the chip does, and dividing by two fully solves the problem (obviously you'd have to halve your PSG volume later, and then apply some gain to the final mix).
Steve Snake was somehow referring to a DAC issue with negative values, where low values were being output much more louder than they should (much more than if it was simply lower bits precision loss), it seems it's the same issue here.
Hmmm, since the DAC is most likely unsigned, the values must be converted to offset binary before being sent to it (toggle the top bit). Maybe they're converting wrong in the chip.
Anyway, can you point me to particular effects to listen in your recordings that sound completely differently in an emulator ?
Those are the most prominent. It's really noticeable with headphones, where current emulators sound way too clean, and the hardware has these distortions and a kind of background noise due to this (you can head this even in Sonic - Green Hill Zone, as a faint background static).

Considering how close emulation is, this for me is one of the most noticeable inaccuracies, and makes the output sound damn close to the recordings. It's true that the distortions introduced by the above masking are NOT exactly the same. I'm thinking that if we can figure out this DAC issue, it will go a long way to ensuring other things are correct, because the distortion effect depends critically on the internal amplitudes, due to the non-linearity of clearing low bits. So I think the reason the distortion differs currently might be because the emulator's amplitude is slightly off (I'm not very familiar with the internals).

Anyway, I just wanted to mention my finding, and am very impressed with the changes I hear when upgrading from my old modified Gens core to your current one. I'm excited to get a new version of Game_Music_Emu out with this new one.

Eke
Very interested
Posts: 884
Joined: Wed Feb 28, 2007 2:57 pm
Contact:

Post by Eke » Tue Feb 23, 2010 8:41 am

So I think the reason the distortion differs currently might be because the emulator's amplitude is slightly off (I'm not very familiar with the internals).
Amplitude depends on the power and sinus tables (TL_TAB & SIN_TAB in the core you use), which have been verified by Nemesis on real chip (and Jarek as well on chip of the same family) , which outputs a 14-bits signed value for each operator (also verified on real chip).

The process used to output a 14-bit operator output and generate phase & enveloppe inputs (10-bits) has also been reverse-engineered and is binary accurate in the MAME core, so I don't think it could be that. It's more likely the DAC is not exactly working as you expect it should, or there are tiny timings differences (maybe the fact channels are time-multiplexed also makes some differences).

Here are some extracted text from the previously posted YM3438 manual that is mentionning the DAC, it would be nice if someone could translate them:

Image

Image

Image

Image

Eke
Very interested
Posts: 884
Joined: Wed Feb 28, 2007 2:57 pm
Contact:

Post by Eke » Tue Feb 23, 2010 10:07 am

On that topic, some other part of the YM3438 manual I would be curious to have translated (i.e info that are not already covered by YM2608 translated manual):

Something about the read mode (when reading FM address 1,2,3):

Image

Image


An article about differences between Yamaha OPN chips:

Image

Ketsuban
Interested
Posts: 25
Joined: Wed Jan 17, 2007 11:37 am
Location: United Kingdom of Great Boredom

Post by Ketsuban » Wed Feb 24, 2010 1:48 am

A friend of mine does freelance translation work to make some extra cash (due to disability he's not able to get a job) and I've passed those on to him. I'll let you know what he comes up with.

Eke
Very interested
Posts: 884
Joined: Wed Feb 28, 2007 2:57 pm
Contact:

Post by Eke » Wed Feb 24, 2010 8:19 am

Thank you, that's what I was hoping for by posting these here :wink:

dtech
Interested
Posts: 33
Joined: Tue Jan 19, 2010 2:56 pm
Location: Latvia, EU
Contact:

Post by dtech » Sun Jun 13, 2010 10:55 pm

Hey, Nemesis, may I ask - how far are you with 2612 decapping? I think interest in details about the chip has not faded in any way.
$90? Is that all a professional decap costs? Hmm, for $90 I might pay to get the YM2612 decapped myself. In fact, I think I will.

I'll need to pick myself up a good digitial microscope to take my own pics. It'll make a valuble addition to my collection of equipment. I'll have to do some research. As soon as I've got a microscope picked out, I'll send away a chip to be decapped. I've got a few chips sitting around here already desoldered and ready to go.

I'm not really sure how much immediately useful info a decap will give us, but it'll be fun.
I am one of those who are impatiently waiting for any nude pictures of our beloved chips.

Cannot decap anything myself as I can't ham any f those few 2612 I have, I'm from europe and don't have any high quality microscope as well.

By the way, it would be nice to decap VDP as well. A curiosity peek with awe at another beloved chip :)

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

Post by Nemesis » Mon Jun 14, 2010 11:12 pm

I agree it would be very interesting. I was always planning to do the VDP and YM2612 together, but that never eventuated. I got in touch with MEFAS, but the catch was they would only ship back to a US address. I tried to arrange with another person in the US to have the decapped chips sent to them, and then back to me, but I never made a concrete arrangement, and then I had doubts that the microscope I had would actually be up to the task of taking the images, so I was weighing up whether to pay more money to MEFAS for images, or shell out for a more professional microscope, and then I wasn't sure which one, and I was questioning whether decapping would show anything useful anyway, so it just kind of faded away.

As things stand today, I don't have the money anyway. I'm now married with a mortgage and a baby on the way. $90 sounds like a fortune now. lol

dtech
Interested
Posts: 33
Joined: Tue Jan 19, 2010 2:56 pm
Location: Latvia, EU
Contact:

Post by dtech » Tue Jun 15, 2010 2:04 am

Nemesis wrote:As things stand today, I don't have the money anyway. I'm now married with a mortgage and a baby on the way. $90 sounds like a fortune now. lol
Ohh, you poor guy, I feel sorry for you :)
Good luck! :))

Well first I thought that MEFAS is in UK or somewhere near, yet then I found out they are in US, so I knew that postage will be a mess (and so I moaned about being in europe). I thought you are in US, but ok whatever.

There's also a post-soviet (but enough advanced) chip decapping facility here in baltic states, yet I cannot find any info on them any more. Don't remember name of the company and it doesn't google up in any way. Also have no idea about prices there, I think it might be 1000$ instead of 90$ and using more destructive methods.

Ok, anyways then the idea from what we have there is getting pretty clear:

1. We have to decap YM2612 and VDP (and could also add the other PQ packaged chip from megadrive1 that has the ROM and logic)

2. We have to do the decapping where we know it's cheap and high quality (decapped chips will remain functional!) - in MEFAS, so we have to arrange a guy in US via a team effort (there is likely to be somebody from US in this forum..?)

3. We have to get chip photos from MEFAS tools, that is - order high resolution images from them. When we get the decapped chips back, we have to keep them in excellent conditions (controlled moisture, no UV, no mechanical stress) and might someday try to do our own pictures as well, whoever will get the most suitable tools for that.

4. We could try to arrange the money for this great cause via some donations or just somebody (or maybe me) will get

5. Maybe Nemesis could provide the chips for decapping, I can smoothlly desolder the large PQ-s from some megadrive mainboard if provided with one.

6. If money is provided from one person, that person becomes the holder of the saint decapped chips as well as gets credited on all images. (a bonus or something)

7. We don't know what we would get from the images, but at least these images are likely to be a tremendously delicious food for brain for a prolonged period of time, as well as an object for aestetical pleasure.

8. If nobody else will want to capture various rom contents from images, I will do it.

At least we've got a plan of some kind :)
_____________
www.dtech.lv

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Tue Jun 15, 2010 2:27 am

I'm in the US and willing to handling all the shipping, but I can't provide the chips or take photos.

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

Post by Nemesis » Tue Jun 15, 2010 6:56 am

I can easily provide the chips as I've got no shortage of hardware that can be "sacrificed" in the interests of science. :)

dtech
Interested
Posts: 33
Joined: Tue Jan 19, 2010 2:56 pm
Location: Latvia, EU
Contact:

Post by dtech » Tue Jun 15, 2010 7:21 am

Well, nice to see that the rock starts to move ;)

This far we see, that on point No.1 we have a common view; No.2 might be solved thanks to Chilly Willy; No.5 is clear thanks to Nemesis; No.7 seems to be acceptable to everyone as well.

So the things we need to figure out are the rest of points - mainly getting to know how much money do we need for this to be done (YM2612 and VDP decapped and photographed in very high resolution in MEFAS), and getting the money for this to happen.

Nemesis - maybe you could ask your contact in MEFAS on prices at the current moment and on making photos?

If things are in reasonable range, we could trow in the other megadrive1 chip as well.

Logistics then are likely to be something like Australia(Nemesis)->US(MEFAS)->US(Chilly Willy)->Whateverland(Whoeverpaysmost)
_____________
www.dtech.lv

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Tue Jun 15, 2010 4:31 pm

Hmm - would it go

Nemesis -> MEFAS -> Chilly

or

Nemesis -> Chilly -> MEFAS -> Chilly

The first would be less expensive. Nemesis - do you have PayPal? It would be easiest to PayPal you money for shipping from your end (when I said I'd cover the shipping, I meant ALL the shipping).

Probably best to discuss any explicit PayPal or shipping info via PMs.

Post Reply