Electronics > Beginners

sound analyzer for automating quality checks?

<< < (4/10) > >>

engineheat:
I recorded a 1 second clip of audio using pyaudio, sample rate 44100, format=pyaudio.paInt16.

I got 44100 samples, the values ranged from -100 to 100 roughly. I took the max and it's 102. The recording was pretty quiet. Had I made some noise, the values would've been in 5 figures. But anyway...

I took the FFT and plotted it, the max magnitude of the FFT is around 191689.921.

I want the magnitude of the FFT to match the amplitude of the input, if I remember correctly I have to divide FFT values by the number of samples, but that still would not get me anywhere close. I expect to see a max FFT magnitude of 102, what is wrong?

Thanks

rhb:

--- Quote from: engineheat on January 13, 2019, 11:36:41 pm ---
Okay, I think I appreciate your response a lot more now. I first tried to record 1 sec of sound (sample rate =44100) and did DFT on all 44100 samples. The spectrum looked different each time, even as I tried to control the settings the best I can. I then downloaded a FFT spectrum analyzer to my smartphone and it turns out the spectrum is fluctuating quiet a bit.

So if I understand you, I will split the 1 second into ten 100ms chunks, do a DFT on each of those and average the result. I understand this decreases the variance. I do have some background in statistics, it's just the DSP part that I'm weak on. If I have less samples each time, my frequency resolution will be bigger (but this doesn't seem to be an issue), is that right?

Thanks

--- End quote ---

You've got the idea.

There are 3 normalizations used in FFTs.  1/N on the either the forward or the inverse or 1/sqrt(N) on both.  I prefer the latter. Also the exponent can be either +1 or -1 for the forward transform.  The inverse will be the opposite.

I strongly recommend getting a copy of

Random Data
Bendat & Piersol

I started with the 2nd ed, but also have the 3rd and 4th which is the last as Piersol passed away.  You should be able to get a 2nd ed very cheaply and it treats everything you need to deal with very thoroughly.

L_Euler:
Get one of these, or similar and a piezo probe or microphone.  You can use GPIB to automate the testing, pass/fail, and data recording.

engineheat:

--- Quote from: L_Euler on January 14, 2019, 01:09:43 am ---Get one of these, or similar and a piezo probe or microphone.  You can use GPIB to automate the testing, pass/fail, and data recording.

--- End quote ---

Thanks, I'll look into it.

engineheat:

--- Quote from: rhb on January 14, 2019, 12:34:33 am ---
--- Quote from: engineheat on January 13, 2019, 11:36:41 pm ---
Okay, I think I appreciate your response a lot more now. I first tried to record 1 sec of sound (sample rate =44100) and did DFT on all 44100 samples. The spectrum looked different each time, even as I tried to control the settings the best I can. I then downloaded a FFT spectrum analyzer to my smartphone and it turns out the spectrum is fluctuating quiet a bit.

So if I understand you, I will split the 1 second into ten 100ms chunks, do a DFT on each of those and average the result. I understand this decreases the variance. I do have some background in statistics, it's just the DSP part that I'm weak on. If I have less samples each time, my frequency resolution will be bigger (but this doesn't seem to be an issue), is that right?

Thanks

--- End quote ---

You've got the idea.

There are 3 normalizations used in FFTs.  1/N on the either the forward or the inverse or 1/sqrt(N) on both.  I prefer the latter. Also the exponent can be either +1 or -1 for the forward transform.  The inverse will be the opposite.

I strongly recommend getting a copy of

Random Data
Bendat & Piersol

I started with the 2nd ed, but also have the 3rd and 4th which is the last as Piersol passed away.  You should be able to get a 2nd ed very cheaply and it treats everything you need to deal with very thoroughly.

--- End quote ---

Dumb question...you are supposed to average the magnitude of the spectra right? not the FFT (complex numbers)...

anyway, I got a crude version working. I used Python with the Pyaudio package and recorded 10 seconds of sound just for test. Sample rate =44k, each frame is 1024 samples. For each frame I plotted the magnitude, and made a dynamic plot thru the 10 seconds. It actually works. I was able to see the magnitudes change as I made various sound.

However, I also downloaded a FFT analyzer to my smartphone and compared the results as I turned on a motor. The smartphone app is able to display relatively constant spectrum (not much flutuations) right from the start. In my plot, the magnitudes are very high upon turning on the motor, and only "settled" after a couple of seconds.

I wonder why that is. Is it due to my sound card or laptop mic? I tested using another laptop and got similar result. Could it be I recorded in Mono mode? The spectrum changes too much as I move the motor, whereas on the smartphone the spectrum is more stable.

Is it because I didn't use a Window function?

Thanks

Navigation

[0] Message Index

[#] Next page

[*] Previous page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod