Re: [hatari-devel] Improved YM2149 sound

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]


On Sunday 06 May 2012 10:49, Nicolas Pomarède wrote:
> On 05/05/2012 22:13, David Savinkoff wrote:
> > Hi,
> >
> > This patch is for more accurate YM2149 sound. Sounds better also.
> > Tested ok, specifically on: Decade demo (quartet screen), Madness demo,
> > Blubber demo, sh11inv demo.
> >
> > Hunk 1) Fixes a typo of mine.
> >
> > Hunk 2) Improved YM2149 math model.
> > Hunk 3) "
> > Hunk 4) "
> > Hunk 5) "
> >
> > Hunk 6) Discard frequencies higher than 80% of nyquist rate.
> > Hunk 7) "
> >
> > Hunk 8) DC level correction for high frequencies 'quartet mode'
> > Hunk 9) "
> >
> > David
> >
> >   	Tone3Voices&= ( Env3Voices | Vol3Voices );
> >
> >   	/* D/A conversion of the 3 volumes into a sample using a precomputed
> > conversion table */ +
> > +	if (stepA == 0&&   (Tone3Voices&  YM_MASK_A)>  1)
> > +		Tone3Voices -= 1;    /* DC level correction for high frequency
> > 'quartet mode' */ +
> > +	if (stepB == 0&&   (Tone3Voices&  YM_MASK_B)>  1<<5)
> > +		Tone3Voices -= 1<<5;
> > +
> > +	if (stepC == 0&&   (Tone3Voices&  YM_MASK_C)>  1<<10)
> > +		Tone3Voices -= 1<<10;
> > +
> >   	sample = ymout5[ Tone3Voices ];			/* 16 bits signed value */
>
> Hello
>
> regarding hunk 8, this means that when StepA == 0, then a volume of 0x14
> for example will become 0x13. What is the math reason leading to
> decrement the voice volume by '1' for quartet mode ?
>
>
> Nicolas
The electronics and math reasoning is:

If one looks at the ST schematic of the YM2149, one sees three sound pins
tied together and attached to a 1000 ohm resistor (1k) that has the other
end grounded. The 1k resistor is also in parallel with a 0.1 microfarad
capacitor (on the Atari ST, not STE or others). The voltage developed
across the 1K resistor is the output voltage which I will call Vout.

The output of the YM2149 is modeled well as a pullup resistor. Thus, the
three sound pins are seen as three computer-controlled, adjustable
pull-up resistors. To emulate the output of the YM2149, one must determine
the resistance values of the YM2149 relative to the 1k resistor, which is
done by the 'math model'. The math model is:

(MaxVol*WARP)/(1.0 + 1.0/(conductance_[i]+conductance_[j]+conductance_[k]))
or
(MaxVol*WARP) / (1.0 + 1.0/( 1/Ra +1/Rb  +1/Rc ))  , Ra = channel A resistance

Note that the first 1.0 in the formula represents the normalized 1k resistor
(1.0 * 1000 ohms = 1k).

Quartet mode represents the output voltage stripped of high frequency
AC component, but DC component remains.
The Quartet math model is:

(MaxVol*WARP) / (2.0 + 1.0/( 1/Ra + 1/Rb  + 1/Rc))
or
(MaxVol*WARP) / (1.0 + 0.5/( 1/Ra + 1/Rb  + 1/Rc))

Note that the 1.0 represents the normalized 1k resistor. 0.5 represents
50% duty cycle for the parallel resistors being summed (this effectively
doubles the pull-up resistance).

One can imagine Quartet mode as similar to Normal mode, but warped
to a lower amplitude (slope and amplitude).

In order to avoid making a look-up table eight times larger than the
current one, I opted to use values from the current table. Using table
values 1 or 2 less give good (and mathematically reasonable) results.

David



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/