Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to process audio in real time?

I have some audio input through microphone. I recorded it in Audacity, it looks something like as shown below.

Audio waveform

I want to process this audio in real time. I mainly want to do this:

  1. See real time audio amplitude vs time graph.

  2. Perform some actions based on event like if a wave pattern is seen similar to some predefined wave pattern, then call a function.
    In the upper half part of the image, you can see four disturbances. I want that whenever this disturbance is seen, the script should call a function, otherwise, when the signal is almost straight, do nothing just keep analyzing signal.

Is there any Python module or C library that can allow me to do this?

like image 710
silverflash Avatar asked Jun 26 '13 15:06

silverflash


People also ask

How audio processing is done?

The electrical signal used in analog devices closely resembles a sound wave, which allows the sound to be processed with the least amount of distortion. In digital audio processing, an audio signal is converted into digital information, often binary code, which can be interpreted by a computer.

What is real time audio?

The transmission of live voice or music. It implies that there is no delay at the receiving side, or at most, imperceptible delays. Although an audio broadcast that is streamed live may be considered real-time audio, there is an intentional, buffered delay at the receiving end.

Can Arduino process audio?

An Arduino is fast enough to sample an audio input with the ADC and recreate the signal on the output DAC at a rate of 44.1 kHz with 12-bits of resolution. However, when recording the sampled audio to SRAM, the sample rate is limited to about 22 kHz because it takes extra time to communicate with the memory chips.


1 Answers

I'd Suggest to get yourself introduced to FFT first, that will make you able to do lot of analysis and control over the processing on your audio at realtime.

1# A forward FFT will give you amplitude within the time-domain, converted from your frequency domain (the audio data itself) 2# Based on the amplitude patterns within the time / frequency - you can decide to call extra thread or function; for example - when you get no amplitude on certain frequency bin or timeslot - do something, skip otherwise.

There are a plenty of opensource C libraries to perform FFT on audio data, like http://aubio.org/ or https://github.com/zaphire/Monocle-Engine/blob/master/Core/Audio/fft.cpp there are a lot more. But be sure to make you understand FFT and sound analysis before you proceed. I've personally not used any of these C libraries - instead did a lot with iOS audio analysis, but the working principals should be similar

like image 162
Arif Avatar answered Sep 30 '22 19:09

Arif