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 » Tue May 06, 2008 4:55 am

I will try to explain some HW "features" of YM2612. As I told, I done some research work with analog part of YM2612 on one russian forum (wich is already dead). You can do this to, using a good oscillograph. YM2612 using time-multiplexed channel mixing. It use 6 "slots" on every cycle. It looks like this:
...(1)-(2)-(3)-(4)-(5)-(6)-(1)-(2)-(3)-(4)-(5)-(6)-(1)-(2)...
Every "(n)" (where n - number of channel) is an analog equivalent of amplitude of single channel. And "-" is gaps, wich 1/2 of Ucc of analog part. And cycle frequency is about of 20kHz. Then goes active Low Frequency filter (on operation amplifier), wich cut off all below about 18-20kHz. But big difference of amplitude between gaps and maximum channel amplitude create strong harmonic frequences, wich depend from amplitude and frequency of every channel. Now, you can imagine, what happens when you using all 6 channels with FM... By the way, becouse only 6 "slots" in output DAC of YM2612, internal "DAC" can be only replace one of FM channel number 6. "DAC" - becouse it is simple register, sets output DAC of YM2612.

I believe that engineers has an strong reason when projected YM2612 to do this terrible analog part (against of 6 separate DACs). Sorry, but now I can not put photos waveforms from oscillograph.

So, using 18kHz samplerate you get big aliasing.
BTW Becouse every channel has that small cycle duty high frequences sounds much better, then in emulators.

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 06, 2008 7:59 am

here's a sample : http://www.hot.ee/tmeeco3/DACTEST.WAV

First I wrote 128 to DAC then wait in a delay looop and then write (128 and delay not in WAV) 255, and it goes to silence in about 160ms
Recorded form my MD2... I have no idea what MD1 does... I didn't check.
That small noise is VDP activity noise, there's no way to get rid of it, unless you cut PSG form the mixer (which is custom in my MD2, no filters or anything, just great sound output).
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 » Tue May 06, 2008 6:36 pm

HardWareMan wrote:I will try to explain some HW "features" of YM2612. As I told, I done some research work with analog part of YM2612 on one russian forum (wich is already dead). You can do this to, using a good oscillograph. YM2612 using time-multiplexed channel mixing. It use 6 "slots" on every cycle. It looks like this:
...(1)-(2)-(3)-(4)-(5)-(6)-(1)-(2)-(3)-(4)-(5)-(6)-(1)-(2)...
Every "(n)" (where n - number of channel) is an analog equivalent of amplitude of single channel. And "-" is gaps, wich 1/2 of Ucc of analog part. And cycle frequency is about of 20kHz. Then goes active Low Frequency filter (on operation amplifier), wich cut off all below about 18-20kHz. But big difference of amplitude between gaps and maximum channel amplitude create strong harmonic frequences, wich depend from amplitude and frequency of every channel. Now, you can imagine, what happens when you using all 6 channels with FM... By the way, becouse only 6 "slots" in output DAC of YM2612, internal "DAC" can be only replace one of FM channel number 6. "DAC" - becouse it is simple register, sets output DAC of YM2612.

I believe that engineers has an strong reason when projected YM2612 to do this terrible analog part (against of 6 separate DACs). Sorry, but now I can not put photos waveforms from oscillograph.

So, using 18kHz samplerate you get big aliasing.
BTW Becouse every channel has that small cycle duty high frequences sounds much better, then in emulators.
I'm a bit septic ot maybe i doesn't understand what you mean.
You said the frequency cycle is ~20Khz, i always though it was ~55 Khz. If it's really 22 Khz then a record at 96 Khz would be revelant about the multiplexed sample. If only the DAC is active then we should obtain something like that (96 Khz) :

_____/\______/\______/\__

but i never observed that type of waveform. I'll do some tests with different samples at different rate.

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

Post by HardWareMan » Wed May 07, 2008 2:32 am

Stef wrote:I'm a bit septic ot maybe i doesn't understand what you mean.
You said the frequency cycle is ~20Khz, i always though it was ~55 Khz. If it's really 22 Khz then a record at 96 Khz would be revelant about the multiplexed sample. If only the DAC is active then we should obtain something like that (96 Khz) :

_____/\______/\______/\__

but i never observed that type of waveform. I'll do some tests with different samples at different rate.
OK. I'll prove you that. Pity, my old screenshots lost and that damn forum died... But I'll do some new.
And one more thing: don't try record output with stupid soundcard. They say "can record at 192kHz" - bullshit. Only 48kHz is maximum what I have got on Audigy. Meanwile it allow record at 192kHz. But on that samplerate (and even on 96kHz) I have got more worse sound than at 44,1kHz! I'm saying about high frequency.

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 May 07, 2008 10:44 am

My Yamaha YMF719 can do 2MBytes of data a second (According to its datasheet - 500KHz 16bit Stereo)... but Windows drivers don't allow anything more than 48KHz... while I could squeeze out 172KHz form its Sound Blaster part in MS-DOS (but only playback, its SB part is 80% compatible, lacking all recording features)... an it sounded GREAT, no audible distortions...
But yeah, all the AC97 HD sound things do only 48KHz, despite they say 192 and such.... just record at 192KHz and you will always see everything in 4 bytes in some WAV editor... ripoff !!!
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 » Wed May 07, 2008 4:47 pm

HardWareMan wrote:
Stef wrote:I'm a bit septic ot maybe i doesn't understand what you mean.
You said the frequency cycle is ~20Khz, i always though it was ~55 Khz. If it's really 22 Khz then a record at 96 Khz would be revelant about the multiplexed sample. If only the DAC is active then we should obtain something like that (96 Khz) :

_____/\______/\______/\__

but i never observed that type of waveform. I'll do some tests with different samples at different rate.
OK. I'll prove you that. Pity, my old screenshots lost and that damn forum died... But I'll do some new.
And one more thing: don't try record output with stupid soundcard. They say "can record at 192kHz" - bullshit. Only 48kHz is maximum what I have got on Audigy. Meanwile it allow record at 192kHz. But on that samplerate (and even on 96kHz) I have got more worse sound than at 44,1kHz! I'm saying about high frequency.
Ok, my sound card isn't able to do more than 48 Khz so i can't see it anyway. Unfortunatly the conclusion is the same, the DAC output is bad whatever we do, i'll try to use the 68k as tomaitheous said but i have very small hopes to see improvements.

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) » Thu May 08, 2008 10:56 am

you just need certain sampling rate, try what sounds the best...
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 » 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...

Post Reply