This article explains how to record audio from microphone and process the audio sample using DSP algorithms to produce altered audio output. In this article, I am using QAudioInput and QAudioOutput classes to record and play back to the input audio, and used Low pass filter algorithm to reduce noise in input audio. Here, I have tried to explain the low level audio processing using Qt. Here I am not explaining any complex DSP algorithms. It’s just a starting point to a better cross platform audio processing utility. You can implement your own algorithms or any complex algorithms to extend your ideas. I used Qt's audioinput and audio output examples to develop this utility.

Simple Audio Processing Utility Image

Download Source Code

In Qt Creator start a new Qt Widget project. The wizard will create all the necessary files to start a desktop application. To link against the multimedia module, add QT += multimedia line to your AppNamae .pro file: TARGET specify the output file name (TARGET = ApplicationName)TEMPLATE specify its compiled output type. Assign it to an application (TEMPLATE = app) Add all the source and header files are using in your project.Add Form design resources to FORMS += mainwindow.ui.This will create user interface to your application

An audio format specifies how data in an audio stream is arranged,
i.e, how the stream is to be interpreted. The encoding itself is specified by
thecodec()
used for the stream.

In addition to the encoding, QAudioFormat contains other
parameters that further specify how the audio data is arranged. These are the
frequency, the number of channels, the sample size, the sample type, and the
byte order. The following table describes these in more detail.

The readyRead() signal
is emitted once every time new data is available for reading from the device.
It will only be emitted again once new data is available, such as when a new
payload of network data has arrived on your network socket, or when a new block
of data has been appended to your device.

Finally play back the modified audio
samples to speaker. This will play modified audio from microphne to speaker.

//write modified sond sample to
outputdevice for playback audio

m_output->write((char*)outdata,
len);

You can implement your own algorithms
in readMore() function. Here I implemented Low Pass filter
algorithms to reduce noise in input audio. There are lts of complex audio
filtering algorithms are available to produce a perfect audi filtering Low Pass
is the simplest algorthm in that list. Shows how to change the volume in low
level audio processing.

This article explains how to record audio from microphone and
process the audio sample using DSP algorithms. The altered audio can
save or output to a speaker. here I written to the output
device(speaker).

After click on play button speak through the microphone of your system. you can hear your sounds from speaker. Check your systems default audio devices. I used default audio devices for record and play sound samples

TJ

Posted:
08/09/2016

Thanks Arun, yes it works now, what a nice code you wrote.

Is it possible to stream audio from mic on one computer to another computer in the same network? do you have any sample code written in QT for that?

I am truing to run your code, and what I get is just the window that you have a plot of it in this document. When I press "play" nothing happens, can you please explain how the program works? What does it play?