In this image I have a green graph of my initial reading of the audio, then the red is running 'live' and only showing audio that is louder than the initial reading. I want to set an led to trigger when a new sound develops but it must be 'constant' sound longer than a few seconds, so I need a way to not measure intermittent spikes like the red spikes that last milliseconds on the screen. Is there a simple adjustment I can make on the arduinoFFT reading that will only show constant audio and ignore short spikes or is this something I have to add various conditions for in the code?
The raw sound samples should be collected, analyzed, and decisions made before computing and displaying the amplitude spectrum.
Thank you, are you referring to my green graph which is in the 'setup' code or just in general to those readings and the 'live' readings I do?
I was answering the question. To analyze and display only "constant audio", measure the audio, decide whether it is "constant", and if so, calculate the FFT and display the spectrum.
But how do I get the code to decide whether it is constant? There is a lot happening in the area, I need it to be able to calculate which audio is constant.
That is a good question, and to get started, you need to define what "constant" means.
Audio is by definition a rapidly changing signal.
By constant, do you mean "single steady tone for some period of time", "uniform sound volume for some period of time", etc. Obviously, the time period needs to be chosen carefully, as for example, voice audio signals consist of short bursts of sound in between silent periods.
The setting I have this in involves several machines and conveyor belts. I'm trying to detect audio anomalies like a failing bearing as an example. Take simplify the discussion, one conveyer has potatoes falling off the edge into a bin so you hear the 'thud, thud, thud,' above the machinery noise. I want to only show the machinery noise and ignore the potatoes falling into the bin which are only short bursts of sound. I want to only bring on a light when there is a constant noise from the machinery above the existing noise and apart from the intermittent sounds.
Sadly, that is a difficult problem to solve. Our brains are very good at picking out individual features of a complicated collection of sounds, but computers are not.
To detect failing bearings vibrational analysis is often used, with accelerometer sensors mounted directly on motor, gearbox or bearing housings, to reduce the effect of ambient noise.
You also have to have some way of storing and comparing current vibrational measurements with "known good" measurements.
Start by doing internet searches using search phrases like "vibrational analysis to detect machine failure", which will turn up lots of introductory material.
I've been through all of that research including the vibration analysis. The environment I want to monitor is too complex with too many moving parts and water splashing everywhere to mount monitors to all the motors. I want to make a sound analyzer - the interesting thing is that FFT is involved with both sound and vibration analysis and I want to make a vibration analyzer when I am finished this project.
One option I had thought of is to just continually run a 5 second analysis of the 'average audio' and keep comparing it with the first reading. My current device already stores an initial reading which is how I get the 'red' comparison reading.
Otherwise ..... how about a code that does a 2 second reading and reports the lowest audio in each frequency? That will leave out the short spikes, if that's possible? I don't know a lot about coding, ChatGpt has been writing these codes for me
You have taken on an advanced technical challenge!
Some basic principles about sampling and FFT calculations:
-
The length of the audio data sample specifies how many frequency divisions will be in the resulting spectrum. 512 audio samples translates to 256 frequency bins, 1024 samples yields 512 frequency bins, and so on.
-
The audio sampling frequency specifies the range of frequencies in the output. A sample frequency of 16 kHz means that the highest frequency in the input data that can be represented is 8 kHz. This is a hard and fast rule, called the Nyquist limit.
-
The only way to reduce the frequencies present in the calculation is to remove them from the input data using frequency selective filters, and in fact, it is extremely important that audio frequencies higher than half the sample frequency be filtered out, using a low pass filter, before the FFT is calculated. If you don't, the output may be severely aliased, and possibly uninterpretable.
Finally, the FFT is just a data transformation, from time to frequency. It performs no analysis of the underlying data. You will have to write code to perform the actual analysis.
Thanks for the detailed explanation. While doing some more questioning, ChatGpt provided this for me to add 'smoothing':
// Apply smoothing by averaging the current reading with the previous reading
fftResults[i] = (previousFFT[i] * 0.7) + (vReal[i] * 0.3); // Adjust the smoothing factor as needed
previousFFT[i] = fftResults[i]; // Update the previousFFT with the smoothed result
}
Not useful and may actually be nonsense. You will get into trouble relying on the bot.
I'm won't have anything to do with chatGPT code, so good luck!
Why not? It has quietened down the intermittent spikes and given more weight to a constant audio input [me whistling to simulate bearing failure] to bring on the warning led without intermittent spikes over-ruling the constant one in focus.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.