How to catch the event when spectrum of an audio reached a specific height, like triggered event made by a loud sound?
I already have the program of the player, wave form generator, spectrum analyzer, the list box where the time will be recorded. These stuffs are working. Now, I want to add the feature, when you will play the audio file, and it reached the certain threshold or开发者_如何学JAVA the max peak of the spectrum, the time of that current event will be recorded to the list box. I managed to add time in the list box so now, my only problem is how to detect the event. I used FFT in the spectrum analyzer, but I;m stuck on this. How can I do this using my current resources like FFT, waveform generator, spectrum analyzer, etc?
This is what I needed,
- When i play the audio and the sound reached a certain threshold, the current time of the stream will be recorded.
Thank you so much. My dead line will be after 36 hours. Every help will be appreciated. My future depends on this. Good luck to me. :) thanks guys! please give me a sample or the exact thing to do. I'll give you my resources if you need further information to my project. Thanks! God Bless.
P.S. This project requires a snare drum detector. but i dont have much time left so I decided to detect not the snare, but the highest peak of the spectrum, because most of the time, the snare drum generates the highest peak than other instruments like bass, cymbals. Thanks guys!
So long as you can generate a continuously updating spectrum then you just need to iterate through the spectrum after every update and check the magnitudes of the relevant bins. Typically you might overlap each sample window e.g. if your FFT size and sample window size is N = 1024, then you take you first FFT over samples 0..1023, then the next block will 512..1535. This 50% overlap helps to reduce latency in your detection (you can increase the overlap but if you go too far then it may get too compute intensive).
The most straightforward way to detect a snare drum would be to compute the cross-correlation between the input signal and a recording of a snare drum hit. When the cross-correlation is high, you likely have a match.
This will be superior to testing the FFT, since the FFT computes the cross-correlation of the input signal with a pure sine wave.
The approach is called "matched filtering", it's well known in optimal detection theory.
If you just want to see when the signal gets very powerful, you don't need an FFT. You can use Parseval's Theorem that relates the power of the time and frequency domains. This allows you to create an O(1) sliding window energy detector from a moving average of squared samples.
BTW, this is exactly the sort of question that is relevant on the DSP Stack Exchange
精彩评论