You are on page 1of 4

28/12/2020 View topic - Sound chip frequencies, FNum and Hz, vgm2mid v0.

, FNum and Hz, vgm2mid v0.35 later today - Forums - SMS Power!

Forums Home - Forums - Games - Scans - Maps - Cheats - Credits


Music - Videos - Development - Hacks - Translations - Homebrew
Sega Master System / Mark III / Game Gear
SG-1000 / SC-3000 / SF-7000 / OMV

View topic - Sound chip frequencies, FNum and Hz, vgm2mid v0.35 later today
Log in Search Membermap Register

Forum Index - Music - Sound chip frequencies, FNum and Hz, vgm2mid v0.35 later today

Author Message
Paul Jensen Sound chip frequencies, FNum and Hz, vgm2mid v0.35 later today
Joined: 29 Jun 1999 Posted: Wed Nov 14, 2001 4:31 pm
Posts: 254
Location: California, Hello,
USA; Hiroshima,
Japan I think I finally found out what the frequency of the YM2612 in the Mega Drive/Genesis, and how it relates to the
YM2413 and Master System PSG.

It seems that the frequencies of these chips are simply divisions of a main oscillating frequency of 53.6931 MHz (NTSC
I guess). The YM2413 and PSG run at 53.6931MHz/15 = 3.57954MHz. The YM2612 runs at 53.6931MHz/14 =
3.83522MHz

Is this right? It would seem so, since I plugged these values into vgm2mid, and now everything is in more or less
PERFECT tune, with absolutely no coarse MIDI note adjustments necessary. This new code is included in vgm2mid
0.35, which will be out later today.

Also, here are the equations for converting YM2413, PSG, and YM2612 FNums into real Hz frequencies:

Const OSC1 = 53693100


Const fM_YM2413_PSG = OSC1 / 15
Const fsam_YM2413_PSG = fM_YM2413_PSG / 72

Const fM_YM2612 = OSC1 / 14


Const fsam_YM2612 = fM_YM2612 / 72

Hz_YM2413 = ((FNum * fsam_YM2413_PSG) * (2 ^ (Block))) / 524288


Hz_PSG = (fM_YM2413_PSG / 32) / FNum
Hz_YM2612 = ((FNum * fsam_YM2612) * (2 ^ (Block))) / 2097152

Thanks to Maxim for the PSG equation.

Paul
gym2mid home page

Maxim Re: Sound chip frequencies, FNum and Hz


Site Admin Posted: Wed Nov 14, 2001 5:01 pm
Joined: 19 Oct 1999
Posts: 13458 Quote
Location: London > I think I finally found out what the frequency of the YM2612 in the Mega Drive/Genesis, and how it
relates to the YM2413 and Master System PSG.

> It seems that the frequencies of these chips are simply divisions of a main oscillating frequency of
53.6931 MHz (NTSC I guess). The YM2413 and PSG run at 53.6931MHz/15 = 3.57954MHz. The
YM2612 runs at 53.6931MHz/14 = 3.83522MHz

Yes. We already knew that :) it was mentioned on S8-dev a while back, I seem to remember. That 53.6931MHz
oscillator is used in lots of things, with different divisions for different stuff.

Note also that the PAL SMS (and probably other stuff) has an oscillator running at a different rate (bah, I can't
remember exactly what) giving the SMS a clock speed of 3546893 Hz (I think, that number came from a VGM Meka
made) (used for the PSG and YM2143). Hmm... multiply by 15 and you get 53.204MHz which sounds very familiar.
The difference is negligible (inaudible) though.

Note that the standard NTSC frequency is often given as 3579545 instead of 3579540, giving the clock a value of
53693175 Hz although of course such accuracy is meaningless and improbable. The clock casing is marked to 4 or 5

https://www.smspower.org/forums/147-SoundChipFrequenciesFNumAndHzVgm2midV035LaterToday 1/4
28/12/2020 View topic - Sound chip frequencies, FNum and Hz, vgm2mid v0.35 later today - Forums - SMS Power!
significant figures, and scientifically speaking the last digit should be +/- 1.

Quote
> Also, here are the equations for converting YM2413, PSG, and YM2612 FNums into real Hz
frequencies:

That'll be useful for me :) I want to improve my YM2413 data interpreter, at the moment it's just "reg xx data yy"... (plus
I need to make changes to VGMTool, FM trimming is currently mauling the output quite horribly... I'm getting the right
notes and percussion, in the right order, just not at the right time).

Maxim

Maxim Waaargh
Site Admin Posted: Wed Nov 14, 2001 10:09 pm
Joined: 19 Oct 1999
Posts: 13458 Quote
Location: London > Const OSC1 = 53693100
> Const fM_YM2413_PSG = OSC1 / 15

So that's 3579540... same as usual...

Quote
> Const fsam_YM2413_PSG = fM_YM2413_PSG / 72

That would therefore be 49716 (roughly).

Quote
> Hz_YM2413 = ((FNum * fsam_YM2413_PSG) * (2 ^ (Block))) / 524288

So... rearranging it to be similar to the one in Richard Talbot-Watkins' doc...

Hz_YM2413 = 48716 * FNum * 2^(Block-19)

since 1/524288 = 2^-19. The two formulae therefore match (I did the intervening maths.) The problem with this is...
FNum ranges from 0 to 512 (9 bits). Block ranges from 0 to 2. So the maximum value you can get here is (48716 *
512) >> 17 = 190 Hz... that's just plain wrong.

So what's the problem? I'm confused...

Maxim

Charles Posted: Wed Nov 14, 2001 10:48 pm


MacDonald
Joined: 28 Sep 1999
Posts: 1161 Quote
> Is this right? It would seem so, since I plugged these values into vgm2mid, and now everything is in
more or less PERFECT tune, with absolutely no coarse MIDI note adjustments necessary. This new
code is included in vgm2mid 0.35, which will be out later today.

I think so too, I had been working on YM2612 timer emulation a while ago and after some experiments on a Genesis,
found that the timer runs at half of the 68000 clock. (which is around 7.67 MHz, so there's the divide-by-14 you came
up with)
And the PSG and Z80 do run at 3.579545 MHz, so that's correct as well.

These values would be different for a PAL machine, since it has a slightly slower clock speed. But that may or may not
be worth emulating.

My Homepage

Paul Jensen YM2413 Block is (more...)

https://www.smspower.org/forums/147-SoundChipFrequenciesFNumAndHzVgm2midV035LaterToday 2/4
28/12/2020 View topic - Sound chip frequencies, FNum and Hz, vgm2mid v0.35 later today - Forums - SMS Power!
Joined: 29 Jun 1999 Posted: Thu Nov 15, 2001 2:34 am
Posts: 254
Location: California, Quote
USA; Hiroshima, > since 1/524288 = 2^-19. The two formulae therefore match (I did the intervening maths.) The problem
Japan with this is... FNum ranges from 0 to 512 (9 bits). Block ranges from 0 to 2. So the maximum value you
can get here is (48716 * 512) >> 17 = 190 Hz... that's just plain wrong.

> So what's the problem? I'm confused...

...3 bits, which of course gives it a max value of 7, and it would appear a max frequency of 609Hz. Maybe that's why
the FM tones are relatively low compared to, say, the YM2612.

Paul

Maxim Re: YM2413 Block is (more...)


Site Admin Posted: Thu Nov 15, 2001 9:07 am
Joined: 19 Oct 1999
Posts: 13458 Quote
Location: London > > since 1/524288 = 2^-19. The two formulae therefore match (I did the intervening maths.) The
problem with this is... FNum ranges from 0 to 512 (9 bits). Block ranges from 0 to 2. So the maximum
value you can get here is (48716 * 512) >> 17 = 190 Hz... that's just plain wrong.

> > So what's the problem? I'm confused...

> ...3 bits, which of course gives it a max value of 7, and it would appear a max frequency of 609Hz.
Maybe that's why the FM tones are relatively low compared to, say, the YM2612.

Ah... yes, I was stupidly looking at "0-2" and reading it as "values 0 to 2" instead of "bits 0 to 2"... in the middle of a
table showing bit numbers.

By the way, (48716*512) * 2^(7-19) is 6089.5 Hz... I presume that was just a typo. While the PSG is capable of much
higher frequencies, they're not used much since 6KHz is already a pretty high frequency - I just generated it in Cool
Edit, it's definitely outside the (normal) musical range.

Maxim

Chris.S Posted: Thu Aug 23, 2007 9:38 am


Guest
Sorry to up this old post but I was searching for some infos about frequencies and found this interesting one ;)

could someone explain me about the "72" division when calculating the "fsam" value ?

Maxim Posted: Thu Aug 23, 2007 10:48 am


Site Admin
Joined: 19 Oct 1999 Good grief, this is old. It's related with how the YM2413 works - in this doc search for "/72" for the basic source for it. To
Posts: 13458 convert YM2413 state into a frequency, the equation is:
Location: London freq = (double)YM2413FNumber * YM2413Clock / 72 / (1 << (19 - YM2413Block) );

for a given F-number/block in the YM2413.

It is because the YM2413 is actually a digital sound synth, it outputs at exactly 1/72 the sampling rate of its input
(3.5MHz) clock. That's 49716Hz, by the way.

For bonus points, realise that it actually outputs its 9 tone channels sequentially, I think using 8-bit PWM, which means
it actually outputs 72 bits of interleaved PWM data at the full 3.5MHz, which gets smoothed by external components
(and the inability of speakers to actually render 3.5MHz audio) to sound like analogue audio.

Chris.S Posted: Thu Aug 23, 2007 12:59 pm


Guest
Thanks for the fast reply, Maxim ;)
This doc helps a lot how FM synth work

https://www.smspower.org/forums/147-SoundChipFrequenciesFNumAndHzVgm2midV035LaterToday 3/4
28/12/2020 View topic - Sound chip frequencies, FNum and Hz, vgm2mid v0.35 later today - Forums - SMS Power!
I have a last question: the fact that the value is the same for YM2612 is theorical or also confirmed ?
(I saw that the MAME YM2612 core divides the input clock frequency by 144, which is exactly 72 * 2)

Maxim Posted: Thu Aug 23, 2007 1:18 pm


Site Admin
Joined: 19 Oct 1999 It's quite likely. The YM2612 is very poorly documented - it was barely used outside the Mega Drive and thus had little
Posts: 13458 need for tech specs - but Yamaha tended to make all their chips in very similar ways. The Mega Drive outputs 6 stereo
Location: London channels so the arithmetic is slightly different, but the numbers are compatible. (144 clock ticks per sample = 24 ticks
per channel per sample = 6 ticks per operator per channel per sample... and an overall "sampling rate" of 26.6kHz.)

I believe the current generation of YMxxxx emulation in MAME was determined by some heavy work involving
oscilloscopes and breadboard, from which it ought to be easy to determine the output's relationship with the input.

Forum Index - Music - Sound chip frequencies, FNum and Hz, vgm2mid v0.35 later today

Script phpBB © 2001, 2005 phpBB Group

Back to the top of this page


Back to SMS Power!

https://www.smspower.org/forums/147-SoundChipFrequenciesFNumAndHzVgm2midV035LaterToday 4/4

You might also like