YM2612 frequency range

Discussion of development of software for any "obsolete" computer or video game system. See the WSdev wiki and ObscureDev wiki for more information on certain platforms.
psycopathicteen
Posts: 3199
Joined: Wed May 19, 2010 6:12 pm

YM2612 frequency range

Post by psycopathicteen »

I've been playing around with TFM and I notice that if the pitch is too high, I get a lot of noise. Is that the deal with a real YM2612, or is that an emulation problem? If this limitation is on the real YM2612, how do I know what the cut off point is? I heard that channel mixing is done by dithering/flickering through the 6 channels, but doesn't that mean that the 53kHz sampling rate is reduced to 9kHz?
Drag
Posts: 1709
Joined: Mon Sep 27, 2004 2:57 pm

Re: YM2612 frequency range

Post by Drag »

Yamaha's FM synths are digital, so they deal with samples, and when you play a high enough frequency, you indeed get aliasing. In fact, when you turn the feedback all the way up, the "noise" you get is actually a mess of aliasing.

Also, the chip's clock is much higher than the chip's output sample rate, so the channel-cycling likely occurs at a faster rate than the sample rate.
User avatar
TmEE
Posts: 1078
Joined: Wed Feb 13, 2008 9:10 am
Location: Norway (50 and 60Hz compatible :P)

Re: YM2612 frequency range

Post by TmEE »

The range is from infrasonic freqs (under 1Hz) to exactly half the sample rate for given clock (clock / 144), in case of PAL MD the highest freq is (53203424 / 7 / 144) / 2 ~ 26390.5873 Hz.
Aliasing plays a huge role in how the instruments sound, and the more harsher your instrument is the higher harmonics it gets, the more it affects your sound. All the fuzz and noise is from the aliasing. If you don't want that noise adjust the KeyScale parameters to get ADSR progress quicker (behaviour of real instruments) and perhaps make instruments especially for the higher notes which have increased TL values for some of the operations.
psycopathicteen
Posts: 3199
Joined: Wed May 19, 2010 6:12 pm

Re: YM2612 frequency range

Post by psycopathicteen »

Could it be possible for an emulator to sound better than the real thing?
User avatar
rainwarrior
Posts: 8764
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada

Re: YM2612 frequency range

Post by rainwarrior »

psycopathicteen wrote:Could it be possible for an emulator to sound better than the real thing?
Of course. Emulators can do the same thing, or something different. If there's something you think is better, they can do that too. At least, if they're well made.
Sik
Posts: 1589
Joined: Thu Aug 12, 2010 3:43 am

Re: YM2612 frequency range

Post by Sik »

psycopathicteen wrote:Could it be possible for an emulator to sound better than the real thing?
They always sound better than the real thing actually, to rather breaking points even >.>; (try listening to Thunder Force IV's guitars without any sort of low pass filtering and you will understand what I mean, your ears will bleed - Sonic Spinball's guitars suffer from the same issue) The only point where they sound worse is in the edge cases which aren't emulated even remotely properly (usually involving SSG-EG or using the wrong emulated rate).
psycopathicteen
Posts: 3199
Joined: Wed May 19, 2010 6:12 pm

Re: YM2612 frequency range

Post by psycopathicteen »

If C9 is at 8khz, and the niquist frequency is at 26khz, then that means you can't have a MUL setting of more than 3. Harmonic frequencies might still be problematic though.

If you adjust every note frequency to be divisible by the sampling rate, would that get rid of some quantization noise?
Sik
Posts: 1589
Joined: Thu Aug 12, 2010 3:43 am

Re: YM2612 frequency range

Post by Sik »

If you have a melody at C-9 then you'll destroy everybody's ears... (remember A-4 is 440Hz, which is far away from 26KHz)
psycopathicteen
Posts: 3199
Joined: Wed May 19, 2010 6:12 pm

Re: YM2612 frequency range

Post by psycopathicteen »

Would it still help to round notes to the nearest divisible frequency, such as C-4 being at sample-rate/192
tepples
Posts: 23006
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)

Re: YM2612 frequency range

Post by tepples »

NES CPU: 315/176 MHz
Genesis CPU: 4725/616 MHz

That could help, but you'd lose tuning precision for high notes. The question becomes whether it'd be noticeable. NES pulse wave frequencies must divide evenly into CPU/16, or 315 MHz/(176*16) = 111,860.8 Hz, so there's a loss of precision at the high end. Triangle wave frequencies must divide into half that, which is why high-pitched triangle waves tend to detune. Atari's POKEY has similar tuning problems.

So how do frequency and "block" translate into an actual frequency? Is the clock source CPU/144 = 4725000000/88704 = 53267 Hz or otherwise?
Sik
Posts: 1589
Joined: Thu Aug 12, 2010 3:43 am

Re: YM2612 frequency range

Post by Sik »

It's a bit more complex than that but yep, it's 1 sample every 144 cycles (and yes, the source clock is the same one used for the 68000 - which also means it varies depending on whether it's NTSC or PAL, but it's so minor that you'll probably just want to ignore it unless you're an audiophile).

I don't recall the details, but block is pretty much a bit shift left (since it's used to determine the octave - one octave/block up = multiply by 2). As for frequencies, this is what Echo uses for each pitch (from C to B), although it's a blend of the frequencies of NTSC and PAL speeds:

Code: Select all

FMFreqTable:
    dw  644, 681, 722, 765
    dw  810, 858, 910, 964
    dw  1021, 1081, 1146, 1214
The maximum is 2047 so you have to resort to blocks to move onto the next octave =/ (you can use lesser values for going down, although you lose some precision)
User avatar
TmEE
Posts: 1078
Joined: Wed Feb 13, 2008 9:10 am
Location: Norway (50 and 60Hz compatible :P)

Re: YM2612 frequency range

Post by TmEE »

Code: Select all

FOR Okt% = 0 TO 7            ' Generate musical note to OPN freq table ------
 FOR NoteS% = 60 TO 71
  MiniStep! = 0
  FOR MiniS% = 0 TO 15
   MFREQ! = 8.1757989156# * (2 ^ ((NoteS% + MiniStep!) / 12))
   OPNnoteStep(Okt%,NoteS%-60,MiniS%)=((MFREQ!*131072)/OPNclk)OR(Okt% SHL 11)
  MiniStep! += (1 / 16)
  NEXT MiniS%
 NEXT NoteS%
NEXT Okt%
This is what I use to create a freq table I use in my stuff. 60 to 71 corresponds to a specific octave in MIDI scale.
% = signed int, # = double precision float, ! = single precision float. OPNclk is 53203424 or 53693175 / 7 / 144
You only need to generate single octave and in my case 16 sub note freqs, octaves are handled by the chip natively.