PCM maximum Hz

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:

PCM maximum Hz

Post by r57shell » Wed Jun 26, 2013 5:17 pm

I just came up with one thing. When you update backdrop palette color to same color it was, it will make glitch pixel at screen, if not during VBLANK period.
So, idea is: may be quality of PCM at high rates worse because you update output level during its propogation to output signal.

Then, I suguest to somehow sync with YM2612 cycle, and try different delays after sync.

This is just idea for tests. :)
Image

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

Post by TmEE co.(TM) » Wed Jun 26, 2013 6:48 pm

YM and Z80 run off different clocks and any kind of syncing is hard to get and near impossible to maintain, especially when you read ROM area or do uncoordinated DMA.
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 Jun 26, 2013 6:54 pm

Timer A sync with YM2612? I think so.
I think set Timer A to 3FF to make about 55555 Hz period.
Then, in loop just spin around :S.

Code: Select all

spin:
bit	0,(HL) ; spin till Timer A overflows
jp	Z,spin
<some nops>
write DAC LEVEL
Image

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

Post by TmEE co.(TM) » Wed Jun 26, 2013 7:10 pm

The problem with that is that you are likely not gonna hit the timer as it overflows, only some times. YM accepts address writes every 17 cycles and up data writes every 83 cycles (those are YM or 68K cycles not Z80 ones). Those waits alone make things iffy...
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 Jun 26, 2013 7:39 pm

TmEE co.(TM) wrote:The problem with that is that you are likely not gonna hit the timer as it overflows, only some times.
I don't need exactly, just with some precision.
TmEE co.(TM) wrote:YM accepts address writes every 17 cycles and up data writes every 83 cycles (those are YM or 68K cycles not Z80 ones).
Why then not to do same thing from M68k?

I don't claim that 55555 Hz PCM reachable :) Just, it is intersting to get MAXIMUM :]
Image

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

Post by TmEE co.(TM) » Wed Jun 26, 2013 7:52 pm

From my tests the maximum PCM rate is half of YM sample rate, which in case of PAL machines is 54203424 / 7 / 144 / 2 ~ 26390.59 Hz

Going past that definitely results in missed writes.
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

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

Post by GManiac » Wed Jun 26, 2013 8:25 pm

I'll say more, different consoles give you different results. You can get maximum rate from 18k to 28k. To calculate the real rate you need to read from YM2612 busy flag (I don't remember exactly), check YM is not busy and only then write next sample.

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

Post by r57shell » Wed Jun 26, 2013 8:35 pm

So, no data corruption occurs, just YM2612 rejects access?
Then, if I do something like this:

Code: Select all

  ld A,0
loop:
  inc A
  ld (HL),A
  jp loop
YM2612 I will get something like: 1,3,7,8,10,13,14,16,18,21,22... and so on?
Image

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

Post by TmEE co.(TM) » Wed Jun 26, 2013 8:46 pm

Data seems to be rejected on PCM writes, but in case of FM parameters, particularly TL there seems to be corruption when writes happen too fast.
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 Jun 26, 2013 11:12 pm

Tested in emulators: http://elektropage.ru/r57shell/MAXPCM.7z
Gens 17000 Hz, RetroArch 40000 Hz with sync.
Without sync, much better.
I didn't know that 64 cycle for z80 very low to check timer.
There is no interupt by timer?
Argh, bored. I'll do some tests may be later, "NOT TODAY". :)
Image

Chilly Willy
Very interested
Posts: 2826
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Thu Jun 27, 2013 12:54 am

Yes, the timer generates ints, but unfortunately the INT line doesn't connect to the Z80. Polling means you'll be a dozen or more cycles off the actual time, which isn't much compared to the sample rate, but is FOREVER compared to the FM chip cycle timing for "synchronized" access.

Stef
Very interested
Posts: 3008
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Thu Jun 27, 2013 8:31 pm

It's just impossible to perfectly sync PCM rate as it seems to vary depending the system... On my 2 MD1 (1 pal and 1 jap) PCM rate seems to accept 32 Khz (at least i can clearly heard the difference between 26 Khz and 32 Khz).
It would be nice to have a test program which actually loop in waiting for busy flag and feeding the dac then we can read number of sent sample per second and somehow estimate the accepted PCM rate on each system :)

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

Post by GManiac » Fri Jun 28, 2013 10:28 am

Stef wrote:It would be nice to have a test program which actually loop in waiting for busy flag and feeding the dac then we can read number of sent sample per second and somehow estimate the accepted PCM rate on each system :)
I'd already done this program, it's somewhere on my hard disk :) Comparing original wav length and real output length I could easily calculate its frequency.
If you want, you can send to DAC not real wave samples, but ladder like 0 1 2 3 ... 255 0 1 2... So it will be easy to check frequency with waiting for busy flag.
And sending to DAC something like 0 0 0 0 0 0 255 0 0 0 0 0 0 without waiting for busy flag we can see if values on some frequency are really rejected or not.

Stef
Very interested
Posts: 3008
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Fri Jun 28, 2013 7:50 pm

GManiac wrote: I'd already done this program, it's somewhere on my hard disk :) Comparing original wav length and real output length I could easily calculate its frequency.
If you want, you can send to DAC not real wave samples, but ladder like 0 1 2 3 ... 255 0 1 2... So it will be easy to check frequency with waiting for busy flag.
And sending to DAC something like 0 0 0 0 0 0 255 0 0 0 0 0 0 without waiting for busy flag we can see if values on some frequency are really rejected or not.
How much rate you measured ? Having a rom which directly directly the sample rate on screen would be convenient for fast testing ;) I should think about it when i will have some free time for that :)

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

Post by TmEE co.(TM) » Fri Jun 28, 2013 8:11 pm

When I wait for the busy bit I get roughly 33KHz rate on my machines, but sound is garbage compared to 26KHz playback without respecting busy bit.
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