Commit f2c22840 authored by jm's avatar jm

Thorvald Natvig: The attached patch fixes an inconsistancy 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 an
int32 instead of a float, meaning we don't need to do a API change when we get
a fixed point AGC.


git-svn-id: http://svn.xiph.org/trunk/speex@14611 0101bb08-14d6-0310-b084-bc0e0c8e3800
parent 6fbeb990
......@@ -1067,14 +1067,14 @@ int speex_preprocess_ctl(SpeexPreprocessState *state, int request, void *ptr)
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 @@ int speex_preprocess_ctl(SpeexPreprocessState *state, int request, void *ptr)
(*(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:
......
......@@ -20,8 +20,8 @@ int main()
speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_DENOISE, &i);
i=0;
speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_AGC, &i);
f=8000;
speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_AGC_LEVEL, &f);
i=8000;
speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_AGC_LEVEL, &i);
i=0;
speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_DEREVERB, &i);
f=.0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment