Dramatic bad DAC output quality !

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

Moderator: BigEvilCorporation

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

Post by HardWareMan » Sat May 10, 2008 7:16 pm

Well, here is the pictures. At maximum zoom, seen as channels hold strictly defined areas on time. The speed is ~ 5mks / division.
Image
Image
If you slow down the scan-rate of 10, then opens another picture: seen as channels merge together.
Image
Image
But after we get such signal after filter at the outlet. High frequency buzz is present. Notice: more amplitude gets more buzz.
Image
Image
And finally, I noticed that there are distortions "ladder" in hardware YM2612, and that gives artifacts, like 8-bit sound at low volume.
Image
Image
Image

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

Post by Stef » Sat May 10, 2008 8:03 pm

HardWareMan wrote:Well, here is the pictures. At maximum zoom, seen as channels hold strictly defined areas on time. The speed is ~ 5mks / division.
Image
Image
Thanks !
Can you give the exact period time of the first image ?
We can see 6 channels on a single screen so the period will gives us the exact output rate of the YM2612. You said 5mks, you mean 0.005 ms ? = ~200000 / 6 ~ 33333 Hz ? sound strange, i was pretty sure the YM2612 "sampling" rate was ~ 54000 Hz

Anyway your pictures are very interesting, we're always learning about that YM2612 ;)
Last edited by Stef on Sun May 11, 2008 9:29 am, edited 1 time in total.

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

Post by HardWareMan » Sun May 11, 2008 3:59 am

Stef wrote:
HardWareMan wrote:Well, here is the pictures. At maximum zoom, seen as channels hold strictly defined areas on time. The speed is ~ 5mks / division.
Image
Thanks !
Can you give the exact period time of the first image ?
We can see 6 channels on a single screen so the period will gives us the exact output rate of the YM2612. You said 5mks, you mean 0.005 ms ? = ~200000 / 6 ~ 33333 Hz ? sound strange, i was pretty sure the YM2612 "sampling" rate was ~ 54000 Hz
Anyway your pictures are very interesting, we're always learning about that YM2612 ;)
Yes. It's exactly 0.005ms per division. But your math is wrong. We see all 6 channels on screen, so whole screen is exactly shows samplerate. But it has 10 divisions, not 6. So time is 0.005x10=0.05ms or 20kHz, what I told you. And I very interesting with "ladder" defect on signal... It's not amplifier nor filter fault - I was checked it very carefully.
Last edited by HardWareMan on Mon May 12, 2008 11:58 am, edited 1 time in total.

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) » Sun May 11, 2008 8:55 am

I wish I have an oscilloscope.

you need to check MD2 sound too someday, it is a bit different from MD1... the artifacts caused by "ladder effect" are much more quiet.
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 May 13, 2008 1:28 pm

So, any ideas about my info about YM2612 analog output? Will ever somebody repeat this? I mean reproduce this signal @200kHz, then pass through low frequency filter and then downsample too any suitable samplerate for soundcard (for example 44,1kHz/48kHz)? I understand it is hard work and headache, but I think it will be more accurate emulation and very noticeable.

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 May 13, 2008 2:29 pm

I'm able to borrow an oscilloscope from my friend... old analog o-scope, has two 50MHz channels... I'll be able to get it next week (hopefully) after the math exam... I H8 math !!!
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

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

Post by Stef » Fri Jun 06, 2008 11:29 am

Good to have that here :
Stef wrote:
TMorita wrote: he Yamaha DAC isn't very good. There's no FIFO on the DAC so it doesn't generate an interrupt, so you need to load the DAC using a software loop. If your software loop isn't perfect, you get scratchy digitzed sound with lots of clicks and pops.

This is why most digitized sound on the Genesis is of low quality - it's because the Z80 is managing both the FM channels and the DAC, so the DAC is not being loaded at a perfectly spaced intervals.
As far i remembre you can freely control the PWM from the 68000, you can even use it from the Z80 using banked access. I believe Virtua Racing Deluxe is using the Z80 to do real time decompression and sample playback (quality is very bad though).


About the DAC quality on YM2612, in fact it's even worst you think : I wrote a Z80 driver which can normally plays 4 channels of 8 bits signed sample at 16 Khz. I discovered than even with good delays and no interruption on Z80 the DAC quality is really bad :-/ You can see it on this topic :
http://www.spritesmind.net/_GenDev/foru ... .php?t=369

I need to do some tests with 68000, i want to be sure the problem come from the DAC and not from unexpected Z80 delays ;)
TMorita wrote:
Stef wrote: ....
About the DAC quality on YM2612, in fact it's even worst you think : I wrote a Z80 driver which can normally plays 4 channels of 8 bits signed sample at 16 Khz. I discovered than even with good delays and no interruption on Z80 the DAC quality is really bad :-/ You can see it on this topic :
http://www.spritesmind.net/_GenDev/foru ... .php?t=369

I need to do some tests with 68000, i want to be sure the problem come from the DAC and not from unexpected Z80 delays ;)
From my experience dealing with digital audio, "good" delays aren't good enough. You need to have perfect delays. If you're only two clocks late at 4 Mhz loading the DAC with a value, you can hear a pop in the audio. You wouldn't think you can hear it, but you can. The ear is an amazingly sensitive instrument.

Also, you can't run the sampling rate too low, or otherwise you will hear a high-pitched carrier whine. If I remember correctly, there's a low-bandpass audio filter built-in to the production 32x to reduce this. There was a problem with this on the dev boards, and I think on the Doom 32x sound driver, I ran the audio DAC at 2x the sampling rate and fed each value into the DAC twice to eliminate this problem.

Toshi
TmEE co.(TM) wrote:
TMorita wrote:Also, you can't run the sampling rate too low, or otherwise you will hear a high-pitched carrier whine. If I remember correctly, there's a low-bandpass audio filter built-in to the production 32x to reduce this. There was a problem with this on the dev boards, and I think on the Doom 32x sound driver, I ran the audio DAC at 2x the sampling rate and fed each value into the DAC twice to eliminate this problem.

Toshi
I do 2nd DAC write in my MD sound engine, after the delay loop, and it seems to enhance audio quality a little (a small demo, I'm not sure if I'm using the double writes there - http://www.hot.ee/tmeeco3/TMFPLAY.RAR )
I've not touched 32X yet... when I get one, I'll try messing with it... it can't be any worse than doing what I have done on Z80 on plain MD.
Stef wrote:
TMorita wrote: From my experience dealing with digital audio, "good" delays aren't good enough. You need to have perfect delays. If you're only two clocks late at 4 Mhz loading the DAC with a value, you can hear a pop in the audio. You wouldn't think you can hear it, but you can. The ear is an amazingly sensitive instrument.
I'm not sure the delay is the problem as it works perfectly on emulator.
I know emulators aren't perfect but i think the hardware audio circuit has some "features" i'm missing...
Also, you can't run the sampling rate too low, or otherwise you will hear a high-pitched carrier whine. If I remember correctly, there's a low-bandpass audio filter built-in to the production 32x to reduce this. There was a problem with this on the dev boards, and I think on the Doom 32x sound driver, I ran the audio DAC at 2x the sampling rate and fed each value into the DAC twice to eliminate this problem.
That sounds interesting, i remember a discution about the auto decrease effect after a sample output. Sending it ore time to the DAC would probably help, i should definitly give a try, thanks ;)

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

Post by Stef » Fri Jun 06, 2008 11:43 am

I modified my driver, the playback sampling rate is now ~15 Khz but i'm now doing more write to the DAC. Generally i'm sending data at 30 Khz but locally (when i've more free time) it can up to 60 Khz.
I expected a big improvement in quality but afaik the improvement is minor :-/
I wonder if writing too much to the YM2612 can lock the CPU ? or writes are just ignored ? i think i'll fill it as much i can !
Definitly need some tests from the 68000...

Shiru
Very interested
Posts: 786
Joined: Sat Apr 07, 2007 3:11 am
Location: Russia, Moscow
Contact:

Post by Shiru » Fri Jun 06, 2008 12:11 pm

Stef wrote:I wonder if writing too much to the YM2612 can lock the CPU ? or writes are just ignored ?
I suppose that YM2612 works this way: it has register latch which can be written by CPU anytime; YM2612 take value from this register at constant rate and send it to DAC. In this case, if CPU writes data too fast, some of them will be ignored - if there will be two writes between two internal YM2612 reads, only last value will be sent to DAC.

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) » Fri Jun 06, 2008 5:21 pm

On real HW, YM2612 seems to lock up if you play samples over 60KHz. Then you need reset to get it working again. I also think that writes will start getting ignored after some point, but I'm not too sure, since increasing sample rate increases the clarity of sound. The point can about 33KHz, which is the rate what you get when you wait before chip is ready before each write.
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

Nemesis
Very interested
Posts: 791
Joined: Wed Nov 07, 2007 1:09 am
Location: Sydney, Australia

Post by Nemesis » Fri Jun 06, 2008 11:13 pm

A note about that "ladder" effect, I've seen a similar distortion when sampling the PSG output from the MD1, even when taken straight from the chip.

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

Post by HardWareMan » Sat Jun 07, 2008 4:39 pm

Nemesis wrote:A note about that "ladder" effect, I've seen a similar distortion when sampling the PSG output from the MD1, even when taken straight from the chip.
From VDP?

Nemesis
Very interested
Posts: 791
Joined: Wed Nov 07, 2007 1:09 am
Location: Sydney, Australia

Post by Nemesis » Sun Jun 08, 2008 2:43 am

Yes. I soldered a pin to the board partway along a track leading directly from the PSG output on the VDP, and sampled from that. So it's not "straight from the chip", but only a few cm further down circuit, and before any other components. Here's what I got when recording from "Jum's Genny PSG Jukebox (PD).bin":
http://nemesis.hacking-cult.org/MegaDri ... ukebox.rar
And here's the output from my emulator for reference:
http://nemesis.hacking-cult.org/MegaDri ... ukebox.rar


As a sidenote, I've just picked up this soundcard:
http://www.emu.com/products/product.asp ... oduct=9872
It uses an AK5394A ADC, and is one of the few soundcards in the world that can actually record at 192KHz without any upsampling or other such voodoo. Once it arrives, I'll be snagging some ultra high sample rate recordings from the PSG and YM2612.

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

Post by HardWareMan » Sun Jun 08, 2008 4:13 am

Look at difference of signal shape. On screenshot compare same sound (begining of first long melody).
Image
The top sound graphic shows to us a true square waveform. And it is normal for PSG (should be a RC-chain at output to eliminate "decaying buzz" at sharply amplitude change). But on bottom sound graphics we see another picture. The sound form not square, as it should be. Square amplitude is decaying. That distortion can be because a to small capacitor for that input resistance at soundcard. Or too high output resistance of PSG. So, IMHO you just do not agreed PSG output and sound card input.

Nemesis
Very interested
Posts: 791
Joined: Wed Nov 07, 2007 1:09 am
Location: Sydney, Australia

Post by Nemesis » Sun Jun 08, 2008 4:24 am

Yeah sorry, that was probably the wrong waveform to upload. The second one is being generated by my emulator, but I'm experimenting with leakage decay as described by Maxim in SN76489.txt. Obviously my decay is far too extreme in that sample. I've got to run some more tests on the hardware in order to measure the actual decay rate, and I'm waiting for my new soundcard to arrive before I do that.

What I was referring to with the distortion from the recorded input was the way the entire waveform regularly shifts up and down. See how the waveform is "arched" in the first sample? That should just be a flat and fairly even +/- distribution from 0.

Post Reply