# audio signal analysis for comparing two signal

Status
Not open for further replies.

#### atmelAVR91

##### Member level 4
I want to do audio signal analysis for comparing two signal.

I think Radix-2 FFT decimation-in-frequency algorithm is good enough.
Please correct me if I am incorrect.

I want to do this on 8bit micro controller with internal 10bit ADC.

Thanks

#### rsrinivas

i think 8 bit isn't sufficient, u may lose precision

#### atmelAVR91

##### Member level 4
CPU core is 8 bit
precision is depends upon Math library I guess !

#### Drago

##### Member level 3
Yo will use FFT as a frequency representation of the two signals. How exactly you are planning to compare them (what measure)? . Does the system should be realtime ? What is the sampling frequency compared to the benchmarks of the CPU?

#### atmelAVR91

##### Member level 4
thanks drago

sampling frequency is 100/125 KHz
CPU is running @ 50 MHz ( MIPS )
system is non real time
I am planing to compare two signal within 1% accuarcy

#### Drago

##### Member level 3
If it is not a realtime system, the cpu doesn't mather, shurely it will do it ... someday .
The sampling frequency is ok. Did you decide what frequency resolution you need? Therefore what is the FFT length?
"1%" is a relative measure, i.e. What you are going to compare the signal to? If you just subtract the frequencies of the two spectrums, you may be confused by a random high magnitude peak.
You should read about the measures, for example squared average distance, and then to compare the value with a predefined threshold. Ofcource you may use some sofisticated technics like neural netowrks or hidden markow models.
Remember there is much more noise that you expect

P.S. If you are planning to use the source code posted be Jools, keep in mind that the twiddle array W is with a double percision. Implementing a floating point arithmetics into a cpu withou an FPU unit is quite a slow solution.

#### atmelAVR91

##### Member level 4
thanks drago,

I am comparing sound captured from microphone with stored sample sound
I am comparing sound generated from mechnical machine.
I am doing this to analysis the life of mechnical parts

( stored sample sound is captured when machine was brand new )

#### Drago

##### Member level 3
The problem is quite clear now.
1. Are you shure that you have a mirophone with a frequency band up to 50/75 kHz ?
I think your problem is not very difficult if you have enough experimental data. This mean a number of recording of a broken(old) parts and the same for a brand new. I suppose each of the details should have specific spectrum. Therefore you should consider a weighted spectrum distance, because each piece will generate some specific frequencies. You only have to identify them and to make the weights.
I suggest you to make the complete experiment using Matlab (there is plenty of build-in functions like fft, etc.). Use recordings take a look of the spectrum, check diferent classification technics (or just measures with a treshold). When you are completely shure about the method and its results then you can go and implement it.
Since the sound is a random event (even when generated by the same source) in your case is better to calculate several consecutive spectrums and to average them.

P.S. I just saw a book fo you

### atmelAVR91

Points: 2

#### atmelAVR91

##### Member level 4
thanks drago

can you please explain "weighted spectrum distance" in details and how to calculate in uC C software

is it different than FFT DIF

#### Drago

##### Member level 3
let us say that a sum of squared distance is:
s=sum( (X(1)-Y(1))^2 +(X(2)-Y(2))^2 + (X(3)-Y(3))^2 ....)
where X and Y are the FFT representations of the two signals x an y
but if you realize that frequency bin 2 is very important you may define a whetighting function like:
W=[0.1 0.9 0.1 ....]
which mean that frequencies 1 and 3 are not so important. Then the sum of weighted square distance should become like:
s=sum( W(1)*(X(1)-Y(1))^2 +W(2)*(X(2)-Y(2))^2 + W(3)*(X(3)-Y(3))^2 ....)
... It was a long time ago since I was working with MCU's. But if we speak about ANSI C, just replace the bracets "(" with "[" and SUM with FOR
P.S. you may normalize the sum with a SQRT and 1/N, but it is not absolutely neccessary since you are going to qompare the value with a threshold

### atmelAVR91

Points: 2

#### atmelAVR91

##### Member level 4
drago

I don't understand what is FFT representations ?
X and Y are the FFT representations of the two signals x an y

and how to calculate W[] weights

do you have FFT radix DIF algorithum ?

drago

FFT c code posted by Jools is (DIT) decimation in time or
(DIF) decimation in frequency

#### Drago

##### Member level 3
FFT representation means:
X=FFT{x}
where:
x time domain signal
X frequency domain signal, or spectrum
the Spectrum is a frequency representation of the time domain signal.
I'm not quite shure about the english therms. you shoud check some DSP book to be completely shure.
The weights W are choosen by you. Experimentally or based on some theory. They are just numbers between 0 and 1 and generally they mean that the non-important frequencies are suppressed.
Mainly I'm using Matlab where you may choose between many spectrum estimation technics, FFT, DCT, etc. I never needed to choose the radix, because this can result in a different cpu load (not important when developing the algorithm). When I'm programming a DSP in C I use a general FFT radix 2 algorithm from the TI's library optimized for TMS320C6711. You may obtain it too from their website.

P.S. it doesn't mattter in which domain is the decimation you will need a bit reversal procedure anyway.

ITU-R Recommendation BS. 1387-1: “Method for objective measurements of perceived audio quality,” 2001.

ITU-R.BS.1387-1.pdf

Try to find in internet

#### Drago

##### Member level 3
Very nice paper vadkur. I find it very usefull for me, but it is speech related.
atmelAVR91 wants to process a different kind of sounds where filter banks, or human perception does not fit to the paradigm. A sound created by a mashine will have very specific spectra and he has to find a way to make a decision based only on few very narrowband peaks I suppose. Using a critical band can make the information very fuzzy.

If you have read the paper in details, do you think you can define an objective measures between two classes (not two vectors)?

#### atmelAVR91

##### Member level 4
I am unable to find it

ITU-R Recommendation BS. 1387-1: “Method for objective measurements of perceived audio quality,” 2001.

ITU-R.BS.1387-1.pdf

Status
Not open for further replies.