aboutsummaryrefslogtreecommitdiffstats
path: root/src/common/includes
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/includes')
-rw-r--r--src/common/includes/Audio/audio.h2
-rw-r--r--src/common/includes/Audio/audio_in.h40
-rw-r--r--src/common/includes/Audio/tone.h52
3 files changed, 93 insertions, 1 deletions
diff --git a/src/common/includes/Audio/audio.h b/src/common/includes/Audio/audio.h
index 7aeb6e9..d48cbe5 100644
--- a/src/common/includes/Audio/audio.h
+++ b/src/common/includes/Audio/audio.h
@@ -32,7 +32,7 @@ void audio_stop_dma(void);
// Initialize and power up audio hardware. Use the above defines for the parameters.
// Can probably only be called once.
-void audio_initialize(int plln,int pllr,int i2sdiv,int i2sodd, int rate);
+void audio_initialize(int plln, int pllr, int i2sdiv, int i2sodd, int rate);
// Power up and down the audio hardware.
void audio_put_codec_in_reset(void);
diff --git a/src/common/includes/Audio/audio_in.h b/src/common/includes/Audio/audio_in.h
new file mode 100644
index 0000000..86c93b2
--- /dev/null
+++ b/src/common/includes/Audio/audio_in.h
@@ -0,0 +1,40 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2018 Maximilien Cuony
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+*/
+
+#ifndef __AUDIO_IN_H__
+#define __AUDIO_IN_H__
+
+#include <stdio.h>
+#include "FreeRTOS.h"
+
+#define AUDIO_IN_BUF_LEN 2048
+#define AUDIO_IN_RATE 8000
+
+int16_t * audio_in_buffer;
+
+void audio_in_initialize(int rate);
+void audio_in_initialize_plateform(int rate);
+void audio_in_buffer_ready(void);
+
+#endif
diff --git a/src/common/includes/Audio/tone.h b/src/common/includes/Audio/tone.h
new file mode 100644
index 0000000..1398ca5
--- /dev/null
+++ b/src/common/includes/Audio/tone.h
@@ -0,0 +1,52 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2018 Maximilien Cuony
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+*/
+
+#ifndef __TONE_H_
+#define __TONE_H_
+
+#include <stdio.h>
+#include "Audio/audio_in.h"
+
+#define TONE_BUFFER_LEN AUDIO_IN_BUF_LEN
+
+#define TONE_N 100
+
+struct tone_detector {
+ float coef;
+ float Q1;
+ float Q2;
+ float threshold;
+};
+
+static struct tone_detector detector_1750;
+
+
+void init_tones(void);
+void init_tone(struct tone_detector* detector, int freq, int threshold);
+void detect_tones(int16_t * buffer);
+
+int TONE_1750_DETECTED = 0;
+
+
+#endif