Re: [hatari-devel] Gain too low in DmaSnd_LowPassFilter for STE ?

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


----- Nicolas Pomarède wrote:
> Le 08/08/2016 à 03:43, David Savinkoff a écrit :
> > Hi,
> >
> > Here is a patch that may solve the problem (untested).
> >
> 
> Hi
> 
> didn't test it, but code looks wrong to me : when "n==0", 
> monobyte/leftbyte/rightbyte can be uninitialised, so you will feed low 
> pass filter with random values (depends on stack content)
> 
The initial sample condition is taken care of in the same function.
Thus n==0 is not a problem. See code snippet.
/**/
void DmaSnd_GenerateSamples(int nMixBufIdx, int nSamplesToGenerate)
{
....
			if ( DmaInitSample )
			{
				MonoByte = DmaSnd_FIFO_PullByte ();
				dma.FrameLeft  = DmaSnd_LowPassFilterLeft( (Sint16)MonoByte );
				dma.FrameRight = DmaSnd_LowPassFilterRight( (Sint16)MonoByte );
				DmaInitSample = false;
			}
....
/* dmaSnd patch here */
....
			if ( DmaInitSample )
			{
				LeftByte = DmaSnd_FIFO_PullByte ();
				RightByte = DmaSnd_FIFO_PullByte ();
				dma.FrameLeft  = DmaSnd_LowPassFilterLeft( (Sint16)LeftByte );
				dma.FrameRight = DmaSnd_LowPassFilterRight( (Sint16)RightByte );
				DmaInitSample = false;
			}
....
/* and dmaSnd patch here */
....
}
/**/
I think the patch will fix the problem for the condition where the DMA
has a lower sample rate than the host system.
eg. DMA = 25033 samples/sec + Host = 44100 samples/sec
Currently the last sample is repeated by DmaSnd_GenerateSamples()
without advancing the filter by 1 iteration. This lowers the filter rate
(and cutoff frequency to the 'lower' DMA rate temporarily) *a bug*

Please try the patch, and if there are no gross problems, test it for
sound improvements.

Thank you,
David Savinkoff




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