YM2612 frequency range

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
YM2612 frequency range
by on (#146902)
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?
Re: YM2612 frequency range
by on (#146930)
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.
Re: YM2612 frequency range
by on (#146935)
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.
Re: YM2612 frequency range
by on (#146947)
Could it be possible for an emulator to sound better than the real thing?
Re: YM2612 frequency range
by on (#146948)
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.
Re: YM2612 frequency range
by on (#146972)
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).
Re: YM2612 frequency range
by on (#147038)
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?
Re: YM2612 frequency range
by on (#147046)
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)
Re: YM2612 frequency range
by on (#147053)
Would it still help to round notes to the nearest divisible frequency, such as C-4 being at sample-rate/192
Re: YM2612 frequency range
by on (#147054)
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?
Re: YM2612 frequency range
by on (#147055)
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:
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)
Re: YM2612 frequency range
by on (#147057)
Code:
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.