Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 10 of 10

Thread: Sound detecting project

  1. #1
    Senior Member
    Join Date
    Jul 2017
    Posts
    120

    Sound detecting project

    First of all i wanted to say i'm new to Teensy.

    Guys please tell me whether below requirements can be successfully achieved by Teensy 3.2 (Also guys keep remember i'm not going to use audio shield because my requirement is to create a small device)

    1) I thought to use - " Adafruit AGC Electret Microphone Amplifier - MAX9814 ". It needs to connect for ADC pin and sample at lower sampling rate (Below 44 KHz, Since my ADC picks signals only upto 3KHz maximum. I'm using a technique of PLL to trigger the Teensey 3.2 and when the signal present at that level it should begin to sample. So no point to use higher sampling rate). So is that possible to change the pre-scalar values of ADC at teensy? If so please post the links for the libraries and share threads.

    2) I needed to implement a DSP filter inside the MCU. so simply i want to make IIR bandpass filer inside the chip. Is their any libraries for teensy 3.2? or else please provide me the links and libraries to refer on. I already found constant values from MATLAB

    3) Next step i want to store all the captured samples on a SD card. (with .wav format) Is that possible ? and what are the libraries which capable of doing that?

    4) Final stage again access SD card and convert .wav files into FFT and analyze frequncy bins. What are the libraries and please share links


    Guys please tell me whether Teensy 3.2 is capable of doing all this steps. And please share all the links and libraries on each particular steps.
    Last edited by Wicky21; 10-03-2017 at 03:00 PM.

  2. #2
    Senior Member
    Join Date
    Apr 2013
    Posts
    1,935
    A teensy can do all these things, how possible that is for you depends on how tight your spec is. A lot of this is done by the audio library

    https://www.pjrc.com/teensy/td_libs_Audio.html

    If your end specs are tweakable enough to accept 44khz sampling you should be able to FFT audio from an ADC pin in real time. If you want to do custom sample rates via your own ADC and roll your own signal processing that will mean looking at the audio library and cutting back, or starting with the ADC library and working up
    https://github.com/pedvide/ADC

    Hardware can certainly do it, but getting to where you want to be may be a convoluted process.

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    27,656
    Quote Originally Posted by Wicky21 View Post
    1) I thought to use - " Adafruit AGC Electret Microphone Amplifier - MAX9814 ".
    This Adafruit mic has been tested and works with a small mod.

    https://forum.pjrc.com/threads/40468...l=1#post126317

    That mod allows that specific Adafruit board to connect directly, which should give you the smallest physical build.

    The MAX9814 can probably also work, but you'll need this circuit to adapt:



    Details here: (right side panel)

    https://www.pjrc.com/teensy/gui/?info=AudioInputAnalog

    2) I needed to implement a DSP filter inside the MCU. so simply i want to make IIR bandpass filer inside the chip. Is their any libraries for teensy 3.2?
    Yes, the audio lib has biquad and state variable filters (both IIR)

    https://www.pjrc.com/teensy/gui/?info=AudioFilterBiquad

    https://www.pjrc.com/teensy/gui/?inf...rStateVariable


    3) Next step i want to store all the captured samples on a SD card. (with .wav format) Is that possible ? and what are the libraries which capable of doing that?
    In Arduino, with Teensy selected in Tools > Boards, click File > Examples > Audio > Recorder.

    4) Final stage again access SD card and convert .wav files into FFT and analyze frequncy bins. What are the libraries and please share links
    The audio lib is set up to the FFT in real time. Check out part 3-2 of the tutorial.

    https://www.pjrc.com/store/audio_tutorial_kit.html

    If you skip parts of this tutorial, please do read or watch the first part about the design tool, and then spend a moment actually looking around in the design tool at the many options it has that aren't demonstrated in the video (especially the ways to get sound in and out other than the audio shield).

  4. #4
    Senior Member
    Join Date
    Jul 2017
    Posts
    120
    [QUOTE=PaulStoffregen;

    The audio lib is set up to the FFT in real time

    [/QUOTE]

    Thanks a lot Paul. One thing i needed to know. could you please explain how FFT algorithm works? Did you have any explanation about how internal fft algorithm works? Because i haven't used it yet. I already used FFT library on arduino and analyzed spectrum. But has no idea how internally it works. So in teensy 3.2 i needed to know what exactly goes on.
    I made MATLAB algorithm to avoid noise by averaging the samples. So in MATLAB if i sent a .wav file directly inside to fft() i get a result like below figure

    Click image for larger version. 

Name:	2.direct_fft_zoom.jpg 
Views:	233 
Size:	65.3 KB 
ID:	10965

    But i made an algorithm to average fft samples. After that outputs looks like below figure

    Click image for larger version. 

Name:	5.FFT_averaging.jpg 
Views:	222 
Size:	210.2 KB 
ID:	10966

    As you can see by doing this technique noises can be cancelled. Is there any mechanism inside fft library?

  5. #5
    Senior Member
    Join Date
    Jul 2017
    Posts
    120
    Paul,

    Is that possible to make an neural network inside teensy?

  6. #6
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    27,656
    Quote Originally Posted by Wicky21 View Post
    could you please explain how FFT algorithm works?
    Did you read the tutorial PDF and/or watch the walkthrough video? I put quite a bit of work into explaining FFT in that tutorial, and Alysia and I actually did the tutorial demo in the video so you can actually see & hear it.

    As for the deeper theory of how FFT computation works, you can find that in many textbooks and website.

  7. #7
    Senior Member
    Join Date
    Jul 2017
    Posts
    120
    Quote Originally Posted by PaulStoffregen View Post
    Did you read the tutorial PDF and/or watch the walkthrough video? I put quite a bit of work into explaining FFT in that tutorial, and Alysia and I actually did the tutorial demo in the video so you can actually see & hear it.

    As for the deeper theory of how FFT computation works, you can find that in many textbooks and website.
    Ya I read the pdf and watched tutorials. I need to know how you implemented the code. I mean deeper level of explanation of created the fft library

  8. #8
    Senior Member
    Join Date
    Jul 2014
    Posts
    3,481
    Quote Originally Posted by Wicky21 View Post
    Ya I read the pdf and watched tutorials. I need to know how you implemented the code. I mean deeper level of explanation of created the fft library
    A small hint: try to understand the source code in the audio library. If you have specific questions, ask on this forum.

  9. #9
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    27,656
    Quote Originally Posted by Wicky21 View Post
    I need to know how you implemented the code.
    The actual FFT computation is done by the arm_math.h library. The audio lib just queues up data, applied the window, lets arm_math's functions do the heavy lifting, and it does some post processing to turn complex numbers to magnitude only.

    You can see the audio lib code here, and also in hardware/teensy/avr/libraries/Audio on your computer.

    https://github.com/PaulStoffregen/Au...ze_fft1024.cpp

    You can see the arm_math code here:

    https://github.com/PaulStoffregen/ar...ree/master/src

    This is as much as I'm going to write for you. If you want more, you can get it from the code.

    Just curious, is this for a school or other academic project?

  10. #10
    Senior Member
    Join Date
    Jul 2017
    Posts
    120
    Quote Originally Posted by PaulStoffregen View Post
    .

    Just curious, is this for a school or other academic project?
    Thanks alot. This is for academic project. I got bunch of information here. Thanks alot. If i have doubts i will ask

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •