summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntti S. Lankila <alankila@gmail.com>2010-09-02 00:16:41 +0300
committerAntti S. Lankila <alankila@gmail.com>2010-09-02 00:40:50 +0300
commita2284ac53742d74a27f041339f6528afe5f87e50 (patch)
tree3bf45686c6f4c5c3e1f608bba5efc799ae34922f
parent57e7bb29dcf918b965b5676c9b80426d1f9a7139 (diff)
downloadframeworks_base-a2284ac53742d74a27f041339f6528afe5f87e50.zip
frameworks_base-a2284ac53742d74a27f041339f6528afe5f87e50.tar.gz
frameworks_base-a2284ac53742d74a27f041339f6528afe5f87e50.tar.bz2
Make Headphone DSP with just 1 biquad
Subtracting the left and right channels could be argued to separate the center channel from the left/right channel and the DSP therefore gets applied to panned sounds only. This halves the cost of the filtering and eliminates the bass boost issue that bs2b compensates for with a highboost filter. I also adjusted the delay-to-level spatial filter to try to get slightly more consistent perception of panning across the frequency spectrum.
-rw-r--r--libs/audioflinger/AudioDSP.cpp25
-rw-r--r--libs/audioflinger/AudioDSP.h2
2 files changed, 7 insertions, 20 deletions
diff --git a/libs/audioflinger/AudioDSP.cpp b/libs/audioflinger/AudioDSP.cpp
index b1c1719..d6b85ca 100644
--- a/libs/audioflinger/AudioDSP.cpp
+++ b/libs/audioflinger/AudioDSP.cpp
@@ -334,10 +334,6 @@ EffectTone::EffectTone()
}
EffectTone::~EffectTone() {
- for (int32_t i = 0; i < 4; i ++) {
- delete &mFilterL[i];
- delete &mFilterR[i];
- }
}
void EffectTone::configure(const float samplingFrequency) {
@@ -402,10 +398,6 @@ EffectHeadphone::EffectHeadphone()
EffectHeadphone::~EffectHeadphone()
{
- delete &mReverbDelayL;
- delete &mReverbDelayR;
- delete &mLowpassL;
- delete &mLowpassR;
}
void EffectHeadphone::configure(const float samplingFrequency) {
@@ -414,8 +406,7 @@ void EffectHeadphone::configure(const float samplingFrequency) {
mReverbDelayL.setParameters(mSamplingFrequency, 0.030f);
mReverbDelayR.setParameters(mSamplingFrequency, 0.030f);
/* the -3 dB point is around 650 Hz, giving about 300 us to work with */
- mLowpassL.setHighShelf(800.0f, mSamplingFrequency, -12.0f, 0.72f);
- mLowpassR.setHighShelf(800.0f, mSamplingFrequency, -12.0f, 0.72f);
+ mLowpass.setHighShelf(850.0f, mSamplingFrequency, -10.0f, 0.72f);
/* Rockbox has a 0.3 ms delay line (13 samples at 44100 Hz), but
* I think it makes the whole effect sound pretty bad so I skipped it! */
}
@@ -469,14 +460,13 @@ void EffectHeadphone::process(int32_t* inout, int32_t frames)
dataL += dryL;
dataR += dryR;
- /* Lowpass filter to estimate head shadow. */
- dataL = mLowpassL.process(dataL >> fixedPointDecimals);
- dataR = mLowpassR.process(dataR >> fixedPointDecimals);
+ /* Lowpass filter difference to estimate head shadow. */
+ int32_t diff = mLowpass.process((dataL - dataR) >> fixedPointDecimals);
/* 28 bits */
- /* Mix right-to-left and vice versa. */
- inout[0] += dataR >> 1;
- inout[1] += dataL >> 1;
+ /* Mix difference between channels. */
+ inout[0] = dataL - (diff >> 1);
+ inout[1] = dataR + (diff >> 1);
inout += 2;
}
}
@@ -507,9 +497,6 @@ AudioDSP::AudioDSP()
AudioDSP::~AudioDSP()
{
- delete &mCompression;
- delete &mTone;
- delete &mHeadphone;
}
void AudioDSP::configure(const float samplingRate)
diff --git a/libs/audioflinger/AudioDSP.h b/libs/audioflinger/AudioDSP.h
index e1b0933..a962ba7 100644
--- a/libs/audioflinger/AudioDSP.h
+++ b/libs/audioflinger/AudioDSP.h
@@ -120,7 +120,7 @@ class EffectHeadphone : public Effect {
Delay mReverbDelayL, mReverbDelayR;
int32_t mDelayDataL, mDelayDataR;
- Biquad mLowpassL, mLowpassR;
+ Biquad mLowpass;
public:
EffectHeadphone();