| Re: [hatari-devel] Gain too low in DmaSnd_LowPassFilter for STE ? | 
[ Thread Index | 
Date Index
| More lists.tuxfamily.org/hatari-devel Archives
] 
- To: hatari-devel@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [hatari-devel] Gain too low in DmaSnd_LowPassFilter for STE ?
- From: David Savinkoff <dsavnkff@xxxxxxxxx>
- Date: Mon, 8 Aug 2016 11:06:03 -0600 (MDT)
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telus.net; s=neo;	t=1470675963; bh=1Q1N/1JjuB4zZqfYSnXbkj2VHvVQ55EhoXy2lzMkSHs=;	h=Date:From:To:In-Reply-To:References:Subject;	b=KTMO0UNdIPWPtmWNwDiJGe11WfdbtCuhJiWc2wH6ZzDRq6G6cSEPpip7athoTlL5E	 a6XyFM6reEYtoCpkzSuXCJgt6I9m0qj3qEmA9ZBpfsNChJxO8cFcbSQJKGDvY4XJgq	 VXtgP3M6G6vQwGAmnIzeWMunArvhqQxHXMELIE1+dDeJVy6LZKyK714VN39sIfUQDA	 EwJrBo/rmwo8KC6w1qFcxMUdPQIOsOeckoYqqjFzOHxAXPs4/nBLFlXuafB/6FE/tr	 IM2n2xw6vgavh1zXMs2I3q9x/kWJixfS+7AD0lWQ+rnNnAwN9Oe0tgHmgafc0/741K	 HA7f6I1AyOl3Q==
- Thread-index: RhvnqSvjCVCiig6sLqxwQrjlZNqo3Q==
- Thread-topic: Gain too low in DmaSnd_LowPassFilter for STE ?
----- 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