//#define DESTROY_CIRC_BUFFER(b) free((b)->buf)
#define GET_BACKLOG_POS(b) ((b)->lpos - (b)->backlog)
-#define GET_CURRENT_POS(b) ((b)->lpos)
-#define GET_CURRENT_SAMPLE(b) GET_SAMPLE((b), GET_CURRENT_POS((b)))
+#define GET_CURRENT_POS(b) ((b)->pos)
+#define GET_CURRENT_LPOS(b) ((b)->lpos)
+#define GET_CURRENT_SAMPLE(b) GET_SAMPLE((b), GET_CURRENT_LPOS((b)))
#define ADD_SAMPLE(b, s) \
do { \
INC_POS((b)); \
- SET_SAMPLE((b), GET_CURRENT_POS((b)), (s)); \
+ SET_SAMPLE((b), GET_CURRENT_LPOS((b)), (s)); \
} while (0)
#endif
*
* This module detects voicemail beeps using a generalized approach.
*
- * Mofdifications:
- *
- * Piotr Gregor <piotrek.gregor@gmail.com>
- * FS-8808 : code refactor
- * FS-8809 : fix MAP_POPULATE undeclared
- * FS-8810 : fix float-int-float fast arc cosine
- * mapping construction (reuse)
- * FS-8852 : use predefined table length instead
- * of hardcoded computation
- * FS-8853 : enable change of resolution (and size)
- * of fast arc cos table
- * FS-8854 : initialize circular buffer
- * FS-8855 : fix APPEND_SMA_VAL macro and avmd_process
- * callback so that the variance of tone's
- * frequency estimation is correctly
- * calculated
+ * Modifications:
+ * Piotr Gregor <piotrek.gregor@gmail.com>:
+ * FS-8808, FS-8809, FS-8810, FS-8852, FS-8853, FS-8854, FS-8855
*/
#include <switch.h>
/*! Maximum frequency as digital normalized frequency */
#define MAX_FREQUENCY_R(r) ((2.0 * M_PI * MAX_FREQUENCY) / (r))
/* decrease this value to eliminate false positives */
-#define VARIANCE_THRESHOLD (0.001)
+#define VARIANCE_THRESHOLD (0.0001)
#include "amplitude.h"
#include "buffer.h"
/*! \brief FreeSWITCH module loading function.
*
* @author Eric des Courtis
- * @par Changes: Piotr Gregor, 07 Feb 2016 (FS-8809, FS-8810)
+ * @par Modifications: Piotr Gregor
* @return On success SWITCH_STATUS_SUCCES,
* on failure SWITCH_STATUS_TERM.
*/
/*! \brief Process one frame of data with avmd algorithm.
* @author Eric des Courtis
- * @par Modifications: Piotr Gregor (FS-8852, FS-8853, FS-8854, FS-8855)
- * (improved variance estimation calculation)
+ * @par Modifications: Piotr Gregor
* @param session An avmd session.
* @param frame An audio frame.
*/
#define GET_SMA_SAMPLE(b, p) ((b)->data[(p) % (b)->len])
#define SET_SMA_SAMPLE(b, p, v) ((b)->data[(p) % (b)->len] = (v))
-#define GET_CURRENT_SMA_POS(b) ((b)->lpos)
+#define GET_CURRENT_SMA_POS(b) ((b)->pos)
+#define GET_CURRENT_SMA_LPOS(b) ((b)->lpos)
#define INC_SMA_POS(b) \
{ \
{ \
(b)->sma = 0.0; \
(void)memset((b)->data, 0, sizeof(BUFF_TYPE) * (b)->len); \
+ (b)->pos = 0; \
+ (b)->lpos = 0; \
}
/*