YM6 SID-Voice effect

category: music [glöplog]
I've been trying to understand how the SID-Voice special effect support by the YM format is supposed to work. Leonard's documentation isn't very clear on this topic, but based on brief mentions here and there I guessed that it toggles the volume register between two levels (0 and VMAX) at a given frequency (determined by a timer prescaler and timer count). The AY_Emul source code also indicates that this is the case.

But if I implement it this way it doesn't sound right when compared to other YM players. So I decided to log the output from AY_Emul to a WAV file to see what the waveform looks like:

BB Image

The player update rate for this song is the typical 50 Hz, so I've put some labels at every 0.02s with relevant information based on the register contents. "effect = 3" means that the top nybble of R1 is 3, i.e. SID-Voice is used on channel C (which is the channel I logged, the others were muted).

Clearly something is modulating the amplitude in a more advanced manner than just swithing it between two states - but what?.
The envelope generator is supposedly not used when the SID-Voice effect is active (besides, the M bit of the volume register is 0). The second special effect is not active.
added on the 2013-04-27 15:21:41 by mic mic
Don't know, but maybe this can be of help:
atari forum: http://www.atari-forum.com/
dead hacker society forum: http://dhs.nu/bbs-coding/
added on the 2013-04-27 16:50:10 by baah baah
afaik it's just a basic convolution of 2 square-wave signals..
It also works that way in my YM->SID effect player,
OUT(x) = R0(x)*(R1(x+phase_shift)

you also may add phase-scaling on the second waveform for more madness. :)

added on the 2013-04-28 02:20:10 by lsl lsl
Yes, there's nothing more than interferences between two square waves. At the scrale you're looking at it in that screenshot, it will look like PWM modulation, so, zoom closer and look at the actual squarewaves (increase the ay_emul sample rate if you can).
Sure, I know that these are square waves. The part I don't get is why the amplitude starts to gradually increase, almost in the shape of a sine curve, when VMAX changes from C to D at time 0.02. I would've expected the change to take full effect immidiately.
I also don't get why there'd be such a big difference in amplitude between volume C and D. I know that the volume curve is non-linear, but the difference between two adjacent steps isn't _that_ big.
added on the 2013-04-28 09:58:29 by mic mic
Btw, the song is "forsko" by TAO (.ym conversion by Leonard) if that matters.
added on the 2013-04-28 10:25:31 by mic mic
Could it be that the volume ramping is done to avoid clicks? I'm not familiar with the YM chip so I don't know if the real hardware has anti-click/pop circuitry.
added on the 2013-04-28 12:02:37 by trc_wm trc_wm
Well, there's the possibility that the ramp-up is a result of supersampling and/or filtering done by AY_Emul.
However, during periods when the SID-Voice effect is disabled I see no such ramp-up (i.e. volume changes appear to be instantaneous).
added on the 2013-04-28 12:24:50 by mic mic
As I said, you aren't looking at the signal close enough.
The effect relies on interference between the square wave generated by the YM chip itself, and the one generated by toggling the volume register.

If they are at the exact same frequency, you can look at the offset between them. If the offset is 0 (set the volume to MAX just when the YM square wave starts, and set it back to 0 just in the middle of the squarewave, there is no visible effect. If you do the reverse, you hear silence. Between these, you are essentially changing the duty cycle of the square wave. There's nothing more happening at the YM side.

Now, the various filters/amplifiers outside the chip could make this look like different amplitudes. The very narrow pulses are more heavily distorted than the larger ones if you use a low pass filter on the output. I think that's what you're seeing there.
I don't know how AY_emul works but that's the only thing one does for "SID"-emulation with the YM chip at least on the Atari ST. The phase shift comes from the fact that the timers which modulate the volume can not be programmed to be as accurate frequency as the actual oscillator.

On the ST, there's also filtering and amplification in the output. Also the chip shows a high oveshoot and decay in the voltage so the waveform will not look like a perfect pulse wave.
added on the 2013-04-29 10:10:00 by !cube !cube
What YM? YM2203 or YM2608? :D
added on the 2013-04-30 11:09:07 by Exin Exin
YM2149, me thinks.
added on the 2013-05-01 12:28:32 by trc_wm trc_wm