YM2612 Timers

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

Moderator: BigEvilCorporation

r57shell
Very interested
Posts: 478
Joined: Sun Dec 23, 2012 1:30 pm
Location: Russia
Contact:

YM2612 Timers

Post by r57shell » Tue Feb 26, 2013 3:20 pm

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 :D

By the way... How does "Ultimate Mortal Kombat 3" play two PCM in same time? Any guesses?
Image

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

Post by GManiac » Tue Feb 26, 2013 4:47 pm

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.

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Tue Feb 26, 2013 6:08 pm

2+ PCM at same time is done by software mixing. My MD sound engine does it too :
http://www.youtube.com/watch?v=3M2szG4maJo
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

r57shell
Very interested
Posts: 478
Joined: Sun Dec 23, 2012 1:30 pm
Location: Russia
Contact:

Post by r57shell » Tue Feb 26, 2013 6:16 pm

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 :D.
Image

r57shell
Very interested
Posts: 478
Joined: Sun Dec 23, 2012 1:30 pm
Location: Russia
Contact:

Post by r57shell » Tue Feb 26, 2013 6:20 pm

TmEE co.(TM)
How many PCM you can mix and samplerate?
UMK3 can play maximum 2 PCM, each 6500 Hz. Quite ugly.
Image

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Tue Feb 26, 2013 6:53 pm

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
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

r57shell
Very interested
Posts: 478
Joined: Sun Dec 23, 2012 1:30 pm
Location: Russia
Contact:

Post by r57shell » Tue Feb 26, 2013 7:05 pm

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 (((.
Image

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Tue Feb 26, 2013 7:22 pm

You have to rewrite the sound engine to be able to process things faster...
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

HardWareMan
Very interested
Posts: 745
Joined: Sat Dec 15, 2007 7:49 am
Location: Kazakhstan, Pavlodar

Post by HardWareMan » Tue Feb 26, 2013 9:07 pm

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 :D.
Indeed, only 23...
Image
Image
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?

r57shell
Very interested
Posts: 478
Joined: Sun Dec 23, 2012 1:30 pm
Location: Russia
Contact:

Post by r57shell » Wed Feb 27, 2013 7:44 am

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 :D.
HardWareMan wrote:VCLK = 53203.4 / 7 = 7600.48kHz
What is it?
Image

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Wed Feb 27, 2013 8:10 am

53203424Hz is the master clock in PAL MD. YM clock is MCLK / 7 ~ 7600489
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

r57shell
Very interested
Posts: 478
Joined: Sun Dec 23, 2012 1:30 pm
Location: Russia
Contact:

Post by r57shell » Wed Feb 27, 2013 8:25 am

Give me NTSC Master clock & YM2612 clock for info) 18µs not differs? Differs sequences timing only? (because based on VBLANK) Is it right?
Image

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Wed Feb 27, 2013 10:23 am

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.
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

r57shell
Very interested
Posts: 478
Joined: Sun Dec 23, 2012 1:30 pm
Location: Russia
Contact:

Post by r57shell » Wed Feb 27, 2013 10:54 am

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.
Image

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Wed Feb 27, 2013 10:59 am

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.
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

Post Reply