YM2612 - prescaler init question

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

Moderator: BigEvilCorporation

Post Reply
neologix
Very interested
Posts: 122
Joined: Mon May 07, 2007 5:19 pm
Location: New York, NY, USA
Contact:

YM2612 - prescaler init question

Post by neologix » Wed Aug 10, 2011 10:47 pm

When the YM2612 initializes, it sets the base audio frequency to CLOCK_RATE / (OUTPUT_SAMPLE_RATE * PRESCALER) and PRESCALER is set to 144 (6*24, acc. to Eke's inline comments, 6 mixed channels and 24 FM clocks, which I presume is 6 FM channels * 4 slots per channel). If I change the number of FM channels from 6 to something else, like 16 or something, would I set PRESCALER equal to 16*64 (16 channels and 64 FM clocks) or would I leave it as 144?

This will be a huge deal for me, as when I finally make the YM2612 VSTi I'd like to offer more than 6 note FM polyphony, and need to know if the prescaler should be adjusted like so. Also, the YM2612 reference thread is still too large to try to search through to find the necessary info regarding something relatively minor in practice but potentially important in theory like the prescaler.

GManiac
Very interested
Posts: 92
Joined: Thu Jan 29, 2009 2:05 am
Location: Russia

Post by GManiac » Thu Aug 11, 2011 5:31 am

Hmm, my first thought was about real prescaler (regs $2D-2F)...

Example:
clock_rate = 7 670 000
channels = 6
operators per channel = 4
cycles per operator = 6
Channel_freq = 7670000 / 6 / 4 / 6 = 53263

If you increase number of channels without changing clock_rate, Channel_freq will decrease and sound will be more dirty/muffle.
If you want to preserve Channel_freq, you should increase clock_rate and number of channels proportionally.

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

Post by Eke » Thu Aug 11, 2011 9:49 am

This is the post you should read
viewtopic.php?t=386&postdays=0&postorder=asc&start=105

The input clock (VCLK) is internally divided by 6 (fixed prescaler value for YM2612). This clock is later divided by 24 to get the channel "samplerate" (6 channels x 4 operators).


These values affects the emulator calculation when dealing with operators frequency (phase, detune, etc) so changing the default value will affect the sound of each channel. Adding channels will NOT change anything to this since :

- this is a custom feature you are adding which does not exist originally, so you could as well decide this custom chip could still handle all these channels at the same rate. In short, if you want the 6 original channel to sound like they originally did, don't change this value.

- you only need to increase the number of registers and modify the core to handle additional channels, providing you want them to work like the original ones . You could as well have additional channels that all have the extra features of CH3 (distinct frequency per operators) or that all can serve as DAC like CH6. your only limitation is the available register range.

clock_rate = 7 670 000
channels = 6
operators per channel = 4
cycles per operator = 6
Channel_freq = 7670000 / 6 / 4 / 6 = 53263

If you increase number of channels without changing clock_rate, Channel_freq will decrease and sound will be more dirty/muffle.
If you want to preserve Channel_freq, you should increase clock_rate and number of channels proportionally.
No, because this formula is only valid for a real YM2612, which the emulator is trying to replicate. If you add channels, this is not a real YM2612 anymore and so the behavior is undetermined, it' s up to you to decide at which frequency this new chip can operate but as I said above, if you adjust the clock rate, original channels will NOT sound the same as beforesince they will be running slower.

neologix
Very interested
Posts: 122
Joined: Mon May 07, 2007 5:19 pm
Location: New York, NY, USA
Contact:

Post by neologix » Thu Aug 11, 2011 2:51 pm

1. i kinda brainfarted for a minute when i made the first post; i slightly misinterpreted the setPrescaler routine wrongly in the post as a "set frequency value" routine instead of as a "set frequency multiplier" one; not the first time i've done that, but i don't know why i keep doing it. anyways, the question i had was still approximately the same and was answered very thoroughly in eke's response :D

2. since it would indeed be a custom feature, would it make more sense to just add more ym2612 cores, each keeping the original intended functionality, instead of trying to hack one singular core to add more channels? i would have no problem sending events to X or Y core in the synthesizer's voice management code (which would be copied almost verbatim from the mda DX10 VSTi source).

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

Post by Eke » Thu Aug 11, 2011 3:41 pm

neologix wrote: 2. since it would indeed be a custom feature, would it make more sense to just add more ym2612 cores, each keeping the original intended functionality, instead of trying to hack one singular core to add more channels? i would have no problem sending events to X or Y core in the synthesizer's voice management code (which would be copied almost verbatim from the mda DX10 VSTi source).
I think this would be more feasible than adding registers for additional channels to the current core, yes; And a lot more practical also.
I am curious to hear some music made from 10x YM2612 mixed together :)

Post Reply