added a _ctl() call at least to set the sampling rate
authorjm <jm@0101bb08-14d6-0310-b084-bc0e0c8e3800>
Sat, 11 Feb 2006 03:22:41 +0000 (03:22 +0000)
committerjm <jm@0101bb08-14d6-0310-b084-bc0e0c8e3800>
Sat, 11 Feb 2006 03:22:41 +0000 (03:22 +0000)
git-svn-id: http://svn.xiph.org/trunk/speex@10795 0101bb08-14d6-0310-b084-bc0e0c8e3800

include/speex/speex_echo.h
libspeex/mdf.c

index 07e0492..1962a56 100644 (file)
 extern "C" {
 #endif
 
+/** Obtain frame size used by the AEC */
+#define SPEEX_ECHO_GET_FRAME_SIZE 3
+
+/** Set sampling rate */
+#define SPEEX_ECHO_SET_SAMPLING_RATE 24
+/** Get sampling rate */
+#define SPEEX_ECHO_GET_SAMPLING_RATE 25
+
+
 /*struct drft_lookup;*/
 struct SpeexEchoState_;
 
@@ -57,6 +66,15 @@ void speex_echo_cancel(SpeexEchoState *st, short *ref, short *echo, short *out,
 /** Reset the echo canceller state */
 void speex_echo_state_reset(SpeexEchoState *st);
 
+/** Used like the ioctl function to control the echo canceller parameters
+ *
+ * @param state Encoder state
+ * @param request ioctl-type request (one of the SPEEX_ECHO_* macros)
+ * @param ptr Data exchanged to-from function
+ * @return 0 if no error, -1 if request in unknown
+ */
+int speex_echo_ctl(SpeexEchoState *st, int request, void *ptr);
+
 #ifdef __cplusplus
 }
 #endif
index 0e42442..7895927 100644 (file)
@@ -704,3 +704,38 @@ void speex_echo_cancel(SpeexEchoState *st, short *ref, short *echo, short *out,
    }
 }
 
+
+int speex_echo_ctl(SpeexEchoState *st, int request, void *ptr)
+{
+   switch(request)
+   {
+      
+      case SPEEX_ECHO_GET_FRAME_SIZE:
+         (*(int*)ptr) = st->frame_size;
+         break;
+      case SPEEX_ECHO_SET_SAMPLING_RATE:
+         st->sampling_rate = (*(int*)ptr);
+         st->spec_average = DIV32_16(SHL32(st->frame_size, 15), st->sampling_rate);
+#ifdef FIXED_POINT
+         st->beta0 = DIV32_16(SHL32(st->frame_size, 16), st->sampling_rate);
+         st->beta_max = DIV32_16(SHL32(st->frame_size, 14), st->sampling_rate);
+#else
+         st->beta0 = (2.0f*st->frame_size)/st->sampling_rate;
+         st->beta_max = (.5f*st->frame_size)/st->sampling_rate;
+#endif
+         if (st->sampling_rate<12000)
+            st->notch_radius = QCONST16(.9, 15);
+         else if (st->sampling_rate<24000)
+            st->notch_radius = QCONST16(.982, 15);
+         else
+            st->notch_radius = QCONST16(.992, 15);
+         break;
+      case SPEEX_ECHO_GET_SAMPLING_RATE:
+         (*(int*)ptr) = st->sampling_rate;
+         break;
+      default:
+         speex_warning_int("Unknown speex_echo_ctl request: ", request);
+         return -1;
+   }
+   return 0;
+}