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