diff options
author | Gerald Begumisa <ben_g@users.sourceforge.net> | 2009-01-12 21:23:34 +0000 |
---|---|---|
committer | Gerald Begumisa <ben_g@users.sourceforge.net> | 2009-01-12 21:23:34 +0000 |
commit | 66a503098b38b2ee2c6f58cf8b3548ef003ea99b (patch) | |
tree | 1b782bf3b7bbf0f4a3d8522c0e147141a2be609f /orkbasecxx/filters | |
parent | 650105c2e53d80741292d2752cb48b3d9625ca09 (diff) |
Modified the AudioGain filter and: Implemented change on gain calculation; Corrected sample range error; Changed configuration variables from AudioGain, AudioGainChannel1 and AudioGainChannel2 to AudioGainDb, AudioGainChannel1Db and AudioGainChannel2Db
git-svn-id: https://oreka.svn.sourceforge.net/svnroot/oreka/trunk@593 09dcff7a-b715-0410-9601-b79a96267cd0
Diffstat (limited to 'orkbasecxx/filters')
-rw-r--r-- | orkbasecxx/filters/audiogain/AudioGain.cpp | 46 |
1 files changed, 17 insertions, 29 deletions
diff --git a/orkbasecxx/filters/audiogain/AudioGain.cpp b/orkbasecxx/filters/audiogain/AudioGain.cpp index 59fec5d..0976b98 100644 --- a/orkbasecxx/filters/audiogain/AudioGain.cpp +++ b/orkbasecxx/filters/audiogain/AudioGain.cpp @@ -77,46 +77,34 @@ void AudioGainFilter::AudioChunkIn(AudioChunkRef& inputAudioChunk) short* outputBuffer = (short*)m_outputAudioChunk->CreateBuffer(outputDetails);
short* inputBuffer = (short*)inputAudioChunk->m_pBuffer;
int sample = 0;
+ double multiplier, multiplier1, multiplier2;
+
+ multiplier = 0.0;
+ multiplier1 = 0.0;
+ multiplier2 = 0.0;
+
+ multiplier = pow(10, (CONFIG.m_audioGainDb / 20.0));
+ multiplier1 = pow(10, (CONFIG.m_audioGainChannel1Db / 20.0));
+ multiplier2 = pow(10, (CONFIG.m_audioGainChannel2Db / 20.0));
for(i = 0; i < r_samples; i++) {
sample = inputBuffer[i];
- if(CONFIG.m_audioGain != 0)
+ if(CONFIG.m_audioGainDb != 0)
{
- if(CONFIG.m_audioGain < 0)
- {
- sample = (int)((double)sample / sqrt(fabs(CONFIG.m_audioGain)));
- }
- else
- {
- sample = (int)((double)sample * sqrt(fabs(CONFIG.m_audioGain)));
- }
+ sample = sample * multiplier;
}
- if(CONFIG.m_audioGainChannel1 != 0)
+ if(CONFIG.m_audioGainChannel1Db != 0)
{
if(outputDetails.m_channel == 1)
{
- if(CONFIG.m_audioGainChannel1 < 0)
- {
- sample = (int)((double)sample / sqrt(fabs(CONFIG.m_audioGainChannel1)));
- }
- else
- {
- sample = (int)((double)sample * sqrt(fabs(CONFIG.m_audioGainChannel1)));
- }
+ sample = sample * multiplier1;
}
}
- if(CONFIG.m_audioGainChannel2 != 0)
+ if(CONFIG.m_audioGainChannel2Db != 0)
{
if(outputDetails.m_channel == 2)
{
- if(CONFIG.m_audioGainChannel2 < 0)
- {
- sample = (int)((double)sample / sqrt(fabs(CONFIG.m_audioGainChannel2)));
- }
- else
- {
- sample = (int)((double)sample / sqrt(fabs(CONFIG.m_audioGainChannel2)));
- }
+ sample = sample * multiplier2;
}
}
@@ -124,9 +112,9 @@ void AudioGainFilter::AudioChunkIn(AudioChunkRef& inputAudioChunk) {
sample = -32768;
}
- if(sample > 32768)
+ if(sample > 32767)
{
- sample = 32768;
+ sample = 32767;
}
outputBuffer[i] = sample;
|