I capture signal (sound) in 44100hz and I need get response if there is peaks at amplitude, actually. Is this possible? How I can do this in real-time?
3 Answers
On a modern Pentium computer, it is possible to do many algorithms in real-time at 44.1 kHz. I suspect that what you want to do is possible, but what isn't possible is to tell you how to do it without a better explanation of what you are trying to do, which should include a better definition of what you mean by "peaks at amplitude".
-
$\begingroup$ I want capture sound and I want detect sudden changes. For example: when someone play to the piano and press key it will be reflected on the amplitude. This I want to find out. But in all song real-time. $\endgroup$– rbrisudaCommented Dec 16, 2013 at 13:45
In real time you may detect the local maxima but not the global maxima. It is important to you to have a training data, to set some peak levels. You say peaks in amplitude, so I assume you are considering the volume of the sound. Because a sudden note from 2 octaves higher might be another peak. But then you should consider the frequencies, not the volume. In short, without having an assumption for the peak levels, you can't detect peaks in real time. After you have some assumptions search for the peak detection algorithms.
-
$\begingroup$ I mean volume of the sound, because volume reflect the pressed keys on the piano. I know what notes (so their frequencies) will be potentially played (but do not have to). Can it help? if yes how? $\endgroup$– rbrisudaCommented Dec 19, 2013 at 15:45
-
$\begingroup$ I think I don't understand what you are trying to do. You know the notes, so are you trying to find out if they are played or not/or the key is pressed or not, or if the volume of the sound passes a threshold or not? $\endgroup$– melisCommented Dec 19, 2013 at 17:00
-
$\begingroup$ Yes I try to find if key is pressed or not. When we look on the amplitude with key pressed or multi key pressed (simultaneously), the amplitude show peak. So, my idea was to find the peaks, but I do not know if it good idea or there is another way solve this. $\endgroup$– rbrisudaCommented Dec 19, 2013 at 20:03
From your comment it sounds like you may not be looking for "peak detection" per se, but rather detecting when the magnitude of the signal becomes large. Or perhaps even just detecting whether or not there is signal present. If that is the case, then might I suggest simply setting a threshold on the amplitude of the signal?
If peak detection really is what you are after, then you can find the peaks in a signal by taking the derivative of the signal and looking at the zero crossings.