Re: [hatari-devel] Cracks in the sound (YM+DMA) |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/hatari-devel Archives
]
On Friday 01 March 2013 06:31, Nicolas Pomarède wrote:
> Le 24/02/2013 05:56, David Savinkoff a crit :
> > Hi,
> >
> > dma @ atari-forum noted sound distortion in Hatari:
> > http://www.atari-forum.com/viewtopic.php?fQ&t$669&sid??8b16bc7408e46efabd
> >cc0459add885#p226677
> >
> > I found and solved the problem. YM + DMA sound samples
> > exceeded 16 bits at line 549 in dmaSnd.c (see code):
> >
> > /* DMA and (YM2149 0 dB) mixing */
> > MixBuffer[nBufIdx][0] =MixBuffer[nBufIdx][0] + dma.FrameLeft *
> > -((256*3/4)/2)/4;
> >
> > A solution is to center the YM sound table with sound.c.overflow.diff
> > A side effect of centering the sound table is an audible click when
> > cold-starting hatari (power cycling on a real Atari).
> >
> > I also made a patch to do efficient clipping instead of overflow for
> > LMC1992 distortion.
> >
> > David
>
> Hello
>
> I tried the patch, and it's true the click on the start is not very nice.
>
> Instead of centering the ym sound, can't we just found a maximum value
> for YM_OUTPUT_LEVEL that doesn't create the observed overflow ? Sound
> level will be lower, but the user can still adjust the output volume on
> his PC (ratio between dma and ym would also need to be adjusted when
> mixing both if we lower YM_OUTPUT_LEVEL)
>
> Nicolas
Hi Nicolas,
After having more thought on this, I believe this current patch is the
best because it emulates reality.
The click (or pop) is the same one that happens when you power-cycle
an amplifier (or atari). The only downside here would be for public
performances at high volume (but the DJ is already used to this).
I was actually surprised that the pop doesn't happen when hatari is
reset... The pop happens only when it should. It is a capacitor
charging and is also low pass filtered and DC filtered (thus it has the
right sound). Not having a pop on power-up would be a bug. Bug fixed!
Centering the ym volume table does not affect the sound, it
pre-corrects the dc level (which is continuously centered by the
DC filter anyway).
The ym volume table has values from 0 to 32767 (positive int16_t)
and the 8-bit STe samples are summed at 3/4 volume using values
-12288 to 12192 (signed-8-bit-sample * 128 * 3/4).
32767 + 12192 overflows. The volume would have to be divided by
2 like it was before (STe quieter that the ST).
Fortunately, centering the ym volume table (or subtracting 32768)
is better.
Centering the ym table allows the full 16-bit dynamic range to be
used properly.
The patch is good.
Thank You,
David