Page 1 of 2
YM2612 Timers
Posted: Tue Feb 26, 2013 3:20 pm
by r57shell
I just tired in searching for precise info.
Common formula:
18 * (1024 - TIMER A) microseconds
Timer A - all 1's -> 18 µs = 0.018 ms
But, I think it is not precise. Where it goes from?
I suppose 18µ goes from 1s / 53267 Hz =
18,773349353258114780257945820114 µs
But I'm not sure, in this.
And... 53267 Hz - is it correct?) And what is 53267 Hz? Frequency of what?
I know, it is frequency of YM2612 but frequency of what event exactly?
So... me confused. Help me
By the way... How does "Ultimate Mortal Kombat 3" play two PCM in same time? Any guesses?
Posted: Tue Feb 26, 2013 4:47 pm
by GManiac
YM2612 Master Clock is 7.67 Mhz - same as for 68k.
Look at large pictures here
viewtopic.php?t=386&postdays=0&postorder=asc&start=360
viewtopic.php?t=386&postdays=0&postorder=asc&start=375
Channels are "switched" every 24 cycles, so channel frequency is
7.67 / 24 = 317-319 kHz
Channels are multiplexed in time, not added to each other, so their output goes consequently. Look here
http://nemesis.hacking-cult.org/MegaDri ... lexing.png
So real frequency of ONE channel is 317/6 = 53 kHz - it is maximal digital frequency you can reach with YM.
Posted: Tue Feb 26, 2013 6:08 pm
by TmEE co.(TM)
2+ PCM at same time is done by software mixing. My MD sound engine does it too :
http://www.youtube.com/watch?v=3M2szG4maJo
Posted: Tue Feb 26, 2013 6:16 pm
by r57shell
Thanks for info.
From picture
http://nemesis.hacking-cult.org/MegaDri ... lexing.png
image measures gives:
19.1 +- 0.2 µs delay between switch channels returns.
http://nemesis.hacking-cult.org/MegaDri ... exing3.png
I DON'T see 24 clock cycles between them, 23 only.
So clock cycle (19.1 +- 0.2 µs)/6/23 = 0.1384 +- 0.0015 µs
It is 7147962 - 7304602 Hz.
Nothing will help me with precision

.
Posted: Tue Feb 26, 2013 6:20 pm
by r57shell
TmEE co.(TM)
How many PCM you can mix and samplerate?
UMK3 can play maximum 2 PCM, each 6500 Hz. Quite ugly.
Posted: Tue Feb 26, 2013 6:53 pm
by TmEE co.(TM)
I only mix 2 channels at about 23Khz in the video, but it can be as high as 45KHz. Going past 26KHz will sound distorted
Posted: Tue Feb 26, 2013 7:05 pm
by r57shell
In UMK3 too many DMA, is it reason why PCM played only 6500 Hz?
I made some test: I removed timer overflow check, and I got same 6500 Hz. But If I change timer to 5200 Hz, for example - it works well.
Wanna cool sound (((.
Posted: Tue Feb 26, 2013 7:22 pm
by TmEE co.(TM)
You have to rewrite the sound engine to be able to process things faster...
Posted: Tue Feb 26, 2013 9:07 pm
by HardWareMan
r57shell wrote:I DON'T see 24 clock cycles between them, 23 only.
So clock cycle (19.1 +- 0.2 µs)/6/23 = 0.1384 +- 0.0015 µs
It is 7147962 - 7304602 Hz.
Nothing will help me with precision

.
Indeed, only 23...

But still 55kHz. :3
VCLK = 53203.4 / 7 = 7600.48kHz
CHANNEL = 7600.48 / 23 = 330.45kHz
CYCLE = 330.45 / 6 = 55.075kHz
55.075kHz = 18.15µs
Problems with math?
Posted: Wed Feb 27, 2013 7:44 am
by r57shell
HardWareMan wrote:55.075kHz = 18.15µs
Problems with math?
Those calculations was from image measuring - As I told.
On your image noted 3.03µs. 6 channels -> 18.18µs. It's not same as you writed.
23 cycles / 3.03 µs = 7 590 759 Hz.
It's not same with label in bottom of your image.
Assuming 7 692 000 Hz - correct clock, then
23*6 / 7 692 000 = 17.94 µs
Not same, again.
Nothing perfect. So... just use formula from manual

.
HardWareMan wrote:VCLK = 53203.4 / 7 = 7600.48kHz
What is it?
Posted: Wed Feb 27, 2013 8:10 am
by TmEE co.(TM)
53203424Hz is the master clock in PAL MD. YM clock is MCLK / 7 ~ 7600489
Posted: Wed Feb 27, 2013 8:25 am
by r57shell
Give me NTSC Master clock & YM2612 clock for info) 18µs not differs? Differs sequences timing only? (because based on VBLANK) Is it right?
Posted: Wed Feb 27, 2013 10:23 am
by TmEE co.(TM)
53693175Hz is NTSC master clock. There will be a slight pitch and speed difference, but there is no way for hardware to know as every relation matches between PAL and NTSC. There are still same amount of cycles per pixel/line/frame/etc.
Posted: Wed Feb 27, 2013 10:54 am
by r57shell
Have you done some research about DAC FIFO and Frequency ratio?
For example for 11111Hz (Timer A = $3FA = 1019).
->Minimum FIFO Length?
I will make some profiling on emulator soon.
Posted: Wed Feb 27, 2013 10:59 am
by TmEE co.(TM)
There is no FIFO on the DAC register, it is read half of channel sample rate per second, which is why going past ~26KHz makes sound go bad. The writes gets missed.