CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2016
    Posts
    1

    Live audio peak detection from microphone

    Hi,

    I'm a new programmer and I'm looking for some help.

    Here is my problem. I need to detect peaks in a live audio from a pickup microphone and output the exact time to milliseconds or preferably nanoseconds of the peak in a .txt file.

    I have been looking at two possible solutions. The first one was to set up a shell script in linux to record audio increments of 5 seconds via the nohup function and then analyze them in matlab, but the problem here is that the endings and the beginnings of the recorded files are not exactly 5 seconds apart. There is a delay of 50-150 milliseconds when a new file starts recording.

    The second option was to do something similar to what they use for clap light switches, but I have no idea how I would extract the exact time from that. And I also don't know if that would work with a pickup microphone or does it just work with a sound sensor (for Arduino...) like it is shown here.http://en.code-bude.net/2014/12/08/h...using-arduino/

    I want to know if there is a better solution out there. Can I do this in C++ or java, perhaps? Remember, I need to output the exact time in milli- or nanoseconds.

    Thank you guys, much help is appreciated.

  2. #2
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,825

    Re: Live audio peak detection from microphone

    The Arduino sound sensor mentioned just detects a sound so is not really suitable for this purpose. However you can get for the Arduino a microphone module that provides analogue output of the voltage signal of the microphone - effectively giving an analogue output of the audio picked up by the microphone (http://www.amazon.co.uk/XCSOURCE-Mic...o+sound+sensor). This can be connected to an Arduino analogue input port and the value read by an Arduino program. This can be either processed by the code on the Arduino or passed to a computer connected to the Arduino and processed there. This can be done in c++ both on the Arduino and on the PC (it can probably done with java on the PC but I don't use java - the Arduino would be c++). The exact time of the peak would depend upon how quickly the data collection loop can perform on the Arduino and the basic time clock of the connected PC - but I suspect milliseconds rather than nanoseconds.

    IMO this would not be a project for an inexperienced programmer. There may well be a better solution available eg a device that connects direct to a PC - or even specialised hardware to do precisely this.

    Why are you looking to do this? Is this some course project or...?
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured