aboutsummaryrefslogtreecommitdiffstats
path: root/src/common/includes/Audio
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2019-04-11 22:53:00 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2019-04-11 22:56:43 +0200
commit0ba699511c136e0215fd2f75e2800be920221497 (patch)
tree93ada6042e058a9d0dcf074246b6c58fb282cdf7 /src/common/includes/Audio
parent7c7cd71c56808610be6af41dbeb09637026414bb (diff)
downloadglutte-o-matic-0ba699511c136e0215fd2f75e2800be920221497.tar.gz
glutte-o-matic-0ba699511c136e0215fd2f75e2800be920221497.tar.bz2
glutte-o-matic-0ba699511c136e0215fd2f75e2800be920221497.zip
Rework tone detector
- Send buffer pointers from ISR to userspace - Use ADC interrupt to fetch data, not TIM6 - Increase size of buffer and do double-buffering - Implement DTMF detectors - Compare relative results instead of using absolute thresholds - Add an IIR averaging filter on the results
Diffstat (limited to 'src/common/includes/Audio')
-rw-r--r--src/common/includes/Audio/audio_in.h9
-rw-r--r--src/common/includes/Audio/tone.h5
2 files changed, 7 insertions, 7 deletions
diff --git a/src/common/includes/Audio/audio_in.h b/src/common/includes/Audio/audio_in.h
index 3bc543c..a543a69 100644
--- a/src/common/includes/Audio/audio_in.h
+++ b/src/common/includes/Audio/audio_in.h
@@ -28,10 +28,11 @@
#include "FreeRTOS.h"
#define AUDIO_IN_RATE 8000
-#define AUDIO_IN_BUF_LEN 32
+#define AUDIO_IN_BUF_LEN 400
-void audio_in_initialize(int rate);
+void audio_in_initialize(void);
-// Fill the buffer with AUDIO_IN_BUF_LEN samples.
-void audio_in_get_buffer(int16_t *buffer /*of length AUDIO_IN_BUF_LEN*/ );
+// After calling this function, *buffer will point to new audio data.
+// Returns the number of times filling the internal buffer failed.
+int32_t audio_in_get_buffer(int16_t **buffer /*of length AUDIO_IN_BUF_LEN*/ );
diff --git a/src/common/includes/Audio/tone.h b/src/common/includes/Audio/tone.h
index 861a472..b8a7f72 100644
--- a/src/common/includes/Audio/tone.h
+++ b/src/common/includes/Audio/tone.h
@@ -30,18 +30,17 @@
#define TONE_BUFFER_LEN AUDIO_IN_BUF_LEN
-#define TONE_N 100
+#define TONE_N 400
struct tone_detector {
float coef;
float Q1;
float Q2;
- float threshold;
int num_samples_analysed;
};
-void tone_init(int threshold);
+void tone_init(void);
/* Return 1 when 1750 detected, 0 otherwise */
int tone_1750_status(void);