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: Sun, 11 Sep 2016 20:52:19 -0600 (MDT)
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telus.net; s=neo; t=1473648739; bh=frhVF57OaEsZ76ObW6LYNyOwc3UINKK/XtaeJPr/XsA=; h=Date:From:To:In-Reply-To:References:Subject; b=IIYVUkg8vCViAXf3N+ea3Hu1KMXV6Oz1zTeUwcaGsZvsHWNhWeA+7J10tICNtELTY qdB0zuHXOyAhqSyFWORA9qAbyNaXYDNcIbF4d1+glXxS6EsnMWVxrzGR6oDsYzxzaR 7FRH1deQlJu7I0rapW3DzuZliskfASdaQlY8Mt1Vdb8Xu+kPkqPdJAMcSZnDQNYFXZ yaRtCxlKIkzI3qAgp71d2MITRtxd1loPJUwsYKJouyWzEkKuMsghPunkrmbsB2hhhz 4Lz/Q80/soWLDJOAdIAfFOBGdVRxqe+chUSjT5fFlx03mgWPUt7NdkI7zJAxgM7d7N /dPdiIGswd6vQ==
- Thread-index: wn+XA9JIwfGES9ZGWBedF6e7BQN4Eg==
- Thread-topic: Gain too low in DmaSnd_LowPassFilter for STE ?
----- Nicolas Pomarède wrote:
> Hi
>
> as discussed here
> http://atari-forum.com/viewtopic.php?f=16&t=29615&p=299270#p299270 the
> STE DMA sound samples can't be heard when using an output freq < 50066
> Hz in Hatari (for example, try "salamander : planet latis")
>
> At 50066 Hz you hear the samples, but at 48 kHz you don't hear them
> anymore. This is because 50066 explicitely turn DMA low pass filter OFF
> in the code path.
>
> David, do you think it would be possible to increase the gain in
> DmaSnd_LowPassFilter to hear the samples even when using < 50 kHz output
> freq ?
>
> Note that in this music demo, samples already have a low volume (if you
> just listen to the wav file with Audacity for example), so maybe the
> fact that the sample don't use the full 8 bit range is fooling the
> filter and you get an even lower volume in the end ?
>
> Nicolas
Hi,
I've made another patch. This one was tested with the STE Pacemaker
demo for sound quality. Please test it to your specifications.
--- hatari/src/dmaSnd.c 2016-08-06 10:07:17.000000000 -0700
+++ hatari/src/dmaSnd.c 2016-08-07 18:33:07.142586393 -0700
@@ -510,6 +510,12 @@
return;
}
+ /* DMA Anti-alias filter */
+ if (DmaSnd_DetectSampleRate() > nAudioFrequency)
+ DmaSnd_LowPass = true;
+ else
+ DmaSnd_LowPass = false;
+
/* DMA Audio ON or FIFO not empty yet */
@@ -1259,16 +1265,14 @@
static Sint16 out = 0;
if (DmaSnd_LowPass)
- {
out = lowPassFilter[0] + (lowPassFilter[1]<<1) + in;
- lowPassFilter[0] = lowPassFilter[1];
- lowPassFilter[1] = in;
+ else
+ out = lowPassFilter[1] << 2;
- return out; /* Filter Gain = 4 */
- }else
- {
- return in << 2;
- }
+ lowPassFilter[0] = lowPassFilter[1];
+ lowPassFilter[1] = in;
+
+ return out; /* Filter Gain = 4 */
}
/**
@@ -1280,16 +1284,14 @@
static Sint16 out = 0;
if (DmaSnd_LowPass)
- {
out = lowPassFilter[0] + (lowPassFilter[1]<<1) + in;
- lowPassFilter[0] = lowPassFilter[1];
- lowPassFilter[1] = in;
+ else
+ out = lowPassFilter[1] << 2;
- return out; /* Filter Gain = 4 */
- }else
- {
- return in << 2;
- }
+ lowPassFilter[0] = lowPassFilter[1];
+ lowPassFilter[1] = in;
+
+ return out; /* Filter Gain = 4 */
}
/**
@@ -1404,10 +1406,4 @@
/* Initialize IIR Filter Gain and use as a Volume Control */
lmc1992.left_gain = (microwire.leftVolume * (Uint32)microwire.masterVolume) * (2.0/(65536.0*65536.0));
lmc1992.right_gain = (microwire.rightVolume * (Uint32)microwire.masterVolume) * (2.0/(65536.0*65536.0));
-
- /* Anti-alias filter is not required when nAudioFrequency == 50066 Hz */
- if (nAudioFrequency>50000 && nAudioFrequency<50100)
- DmaSnd_LowPass = false;
- else
- DmaSnd_LowPass = true;
}