YM2612 & distorted sound output

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

Moderator: BigEvilCorporation

Post Reply
dazbags66
Newbie
Posts: 5
Joined: Tue May 26, 2020 6:34 pm

YM2612 & distorted sound output

Post by dazbags66 » Wed Jun 10, 2020 7:30 pm

Hi,
Does anyone have any experience to share regarding the output waveforms of the YM2612/YM3438 ?
I've built a hardware synth based around this chip and I'm seeing unexpected distortion on the audio output, even with nothing (other than a scope) attached.

For example, I've turned everything 'off' except operator 1 on channel 1. Algorithm is 7 (all operators in parallel). TL=0 (max volume), AR=15, DR1=14, DR2=14, RR=4. All the other registers for all operators and channels are set to 0 (apart from the TLs which are 127 for minimum volume). So no AM, FM, detune, MULT etc.

With a single operator I would expect the output to be a pure(ish) sine wave, with the amplitude controlled by the envelope, and I've verified this using a VST version of the YM2612 by setting the voice parameters to be the same. And I see a pretty good sine wave.

But the output of my chip looks quite different. The envelope is similar but it looks almost like half-cycle amplitude modulation of a higher frequency sine wave is going on. And if I buffer the output and feed it into an amp it sounds much harsher than a sine tone.

My first thought was that my 'write' function to the chip wasn't correct but I've checked it against online projects. And I can see the envelope change on the scope as I tweak the values. I'm reading the BUSY bit and waiting for that. So I'm reasonably sure I'm writing to the chip correctly.

I've tried two chips now and they both behave more or less the same. Anyone have any ideas please ? Could I just have damaged chips ?

Thanks in advance.
D.

Michel Gerritse
Newbie
Posts: 5
Joined: Sat Apr 25, 2020 7:25 pm
Location: The Netherlands

Re: YM2612 & distorted sound output

Post by Michel Gerritse » Thu Jun 11, 2020 12:13 pm

Just to be sure, did you also disable the feedback for operator 1 ? Could you share a screenshot of the scope output ?

dazbags66
Newbie
Posts: 5
Joined: Tue May 26, 2020 6:34 pm

Re: YM2612 & distorted sound output

Post by dazbags66 » Fri Jun 12, 2020 1:20 pm

Hi,
Assuming I'm writing to the chip correctly then I believe I'm turning feedback off, yes.I I'm writing 0x07 to address 0xB0, so feedback off and algorithm 7 (all operators in parallel). This is for channel 1. All the other channels have the equivalent register set to 0.

VST - envelope
https://imgur.com/gallery/DYzaOYw

VST - sine waves
https://imgur.com/gallery/CO8Ud89

Chip - envelope
https://imgur.com/gallery/fVKL7Ns

Chip - amp mod very fast pulses
https://imgur.com/gallery/fVKL7Ns

Note the envelopes are similar. And that the chip envelope is formed of very fast pulses as seen in the last image.

Edit. Embedding the images didn't seem to work... so apologies for the links.

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

Re: YM2612 & distorted sound output

Post by TmEE co.(TM) » Sun Jun 14, 2020 4:17 pm

YM2612 and YM3438 have pulse train based outputs where all channels are sent sequentially. On 2612 the pulses are very narrow and also have fairly low amplitude while 3438 has much wider and bigger pulses, allowing for better SNR. What you see on your scope is mainly due to aliasing, when you up the sample rate you begin to see the individual pulses.

You need proper filtering on the output to create continuous waveforms on the real chips.
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

dazbags66
Newbie
Posts: 5
Joined: Tue May 26, 2020 6:34 pm

Re: YM2612 & distorted sound output

Post by dazbags66 » Tue Jun 16, 2020 1:11 pm

Ah. I genuinely hadn't realised that! Thanks :D
I will add a LP filter and see how that changes things.

Cheers!
D.

dazbags66
Newbie
Posts: 5
Joined: Tue May 26, 2020 6:34 pm

Re: YM2612 & distorted sound output

Post by dazbags66 » Fri Jun 19, 2020 2:42 pm

@ TmEE co.(TM) - what do you mean by 'proper' filtering? I've tried low-pass filters at various cut off frequencies, and I can get the envelope very similar to the VST version, but it sounds nothing like the VST. If I take the LPF much below 16kHz or so it starts to 'hollow out' envelope. When I zoom in with the scope the pulse train output is at a frequency of about 55kHz, so I would have thought setting the LPF to anything above about 20kHz would be fine.

Whereas the VST sounded very much like it was composed of sine waves i.e. not much harmonic content, all I hear from the chip is the low frequency 'thump'.

I'm beginning to think the two chips (YM3438) I have are damaged in some way...

Thanks for the help btw !
Cheers,
D.

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

Re: YM2612 & distorted sound output

Post by TmEE co.(TM) » Sun Jun 21, 2020 9:02 pm

The output is a pulsetrain, with YMCLK / 144 clocks per sample and 24 clocks per pulse (with differing duty cycle and amplitude for 3438 and 2612). There's harmonic content going into MHz range in there so you need fairly good opamps to deal with it effectively.
The output is also very weak and should be buffered first before you do anything further and you'll need rail to rail opamps if you want to prevent clipping from happening in single rail stuff. If you have negative rail available you can use some nice chip like NJM4580. You can look at the application manual of YM3438 for an output stage reference.
This would also be workable : http://sue.niko.to/ps98/ym3438_sch.png

Output of the real chips is 9 bits and will be very dirty sounding compared to most emulation that do full 16bit output without any trucnations.
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

dazbags66
Newbie
Posts: 5
Joined: Tue May 26, 2020 6:34 pm

Re: YM2612 & distorted sound output

Post by dazbags66 » Tue Jun 30, 2020 7:50 pm

Fantastic! Many thanks.

Post Reply