[Speex-dev] Patch to make SPEEX_PREPROCESS_GET_AGC_GAIN use dB,
and _SET_AGC_LEVEL use a int32
Thorvald Natvig
speex at natvig.com
Tue Mar 18 10:16:27 PDT 2008
Hi,
The attached patch fixes an incistency in my earlier patch. Whereas the
rest of the AGC ctls are in dB, GET_AGC_GAIN was linear. This patch fixes
that.
It also changes the API for _GET and _SET_AGC_LEVEL to use a int32
instead of a float, meaning we don't need to do a API change when we get
a fixed point AGC.
Best regards,
Thorvald
-------------- next part --------------
--- speex/libspeex/preprocess.c 2008-02-21 15:41:54.000000000 +0100
+++ spx/libspeex/preprocess.c 2008-03-18 18:09:30.000000000 +0100
@@ -1067,14 +1067,14 @@
break;
#ifndef DISABLE_FLOAT_API
case SPEEX_PREPROCESS_SET_AGC_LEVEL:
- st->agc_level = (*(float*)ptr);
+ st->agc_level = (*(spx_int32_t*)ptr);
if (st->agc_level<1)
st->agc_level=1;
if (st->agc_level>32768)
st->agc_level=32768;
break;
case SPEEX_PREPROCESS_GET_AGC_LEVEL:
- (*(float*)ptr) = st->agc_level;
+ (*(spx_int32_t*)ptr) = st->agc_level;
break;
#endif /* #ifndef DISABLE_FLOAT_API */
case SPEEX_PREPROCESS_SET_AGC_INCREMENT:
@@ -1176,7 +1176,7 @@
(*(spx_int32_t*)ptr) = pow(st->loudness, 1.0/LOUDNESS_EXP);
break;
case SPEEX_PREPROCESS_GET_AGC_GAIN:
- (*(spx_int32_t*)ptr) = (spx_int32_t) (st->agc_gain * 100.f);
+ (*(spx_int32_t*)ptr) = floor(.5+8.6858*log(st->agc_gain));
break;
#endif
case SPEEX_PREPROCESS_GET_PSD_SIZE:
More information about the Speex-dev
mailing list