Peak Detection Algorithm of a buffer using Billauer technique


    Feb 20 2016 | 8:14 pm
    Hello everyone and good weekend,
    I am working on a patch for IR analysis and I need to do a peak detection for my recorded Impulse Response (audio file). I need in output also to create different audio files that are windowed version of the original around the peaks. For what I know, the best algorithm is the following from BIllauer: http://www.billauer.co.il/peakdet.html
    As I have almost no knowledge of programming apart for Max, I have no idea of how implement this. I tried to search for peak detection algorithm but I have not find a solution on the forum apart from the zsa components. Not saying it is not useful but I wanted to please ask any of you much more experienced than me if you can help.
    Thank you very much in advance Sero

    • Feb 20 2016 | 11:18 pm
      Sorry for bumping the topic... Forgot to mention that I need the peak detector to be not in real time...I need to analyse a file in buffer... Just to clarify
      And also it can be any algorithm/technique...not only the one mentioned by Billauer
      Thank you
    • Feb 21 2016 | 2:43 am
      not sure if that is fast enough for you... but what about doing it straight forward using maximum~ and index~ - and then putting the DSP into a poly~ up 32 to speed up a bit this realtime process?
      -110
    • Feb 21 2016 | 10:29 am
      Hello Roman,
      thank you for the comment. I would need the process to happen not in real time. The ideal situation would be a peak detection algorithm that gives in output the location of the peaks in ms (or samples) of the file in the buffer. In this case I could use an irnormtrim~ from the HISS library to get different pieces of the buffer file that I then need to combine to some mathematical calculation. I am know stuck to the peak detection, I can do it by visual inspection but it is not ideal.
      I always found difficult to do not real time process in max.
    • Feb 21 2016 | 12:03 pm
      i find the terminology of "peaks" in the matlab article questionable, or lets say... misleading.
      how accurate do you need the results to be? to find those mountain tops a steep band select filter and the meter~ object could be of help.
      remove DC offset, remove HF noise, look for peaks every so window.
      then again, a recorded IR might require frequencies of 30 kHz and above at least for the first 100 milliseconds...
    • Feb 21 2016 | 4:54 pm
      offline processes are much better handled in an external, i.e. in C or Java. as you mentioned "peak detection' i'm not sure if this is what you need, but you could try several transient detection methods in vb.audio~ (vboehm.net/downloads) which is a wrapper around aubio lib (aubio.org) - and works offline.
      Compared to a transient detector, the Billauer algorithm is rather simplistic. I heard that in max7 you can access buffer data from inside javascript, which makes it really easy to implement the algorithm yourself. Or you can try the attached java class, which is a quick implementation of the code from the website.
    • Feb 21 2016 | 7:21 pm
      Hello,
      thank you very much for your responses. I would like to clarify more what I am trying to do in order to leave no misunderstanding (if there is one of course). The paper attached describes my goal. Figure 2 in the paper is what we are talking about regarding the peak detection. the paper refers to a commercial product developed by a company called Marshall Day Acoustics. My goal is to create of version of the software of my own and add some more features as I need them for a project of mine. It is not a commercial project at all and I am willing to share the results to the max community.
      Saying that we are now talking about acoustics Impulse Responses. Not trying to teach anything to you guys that most probably knows ore than me in this, but every peak refer to a reflection made by an element (wall, ceiling or panel) in an enclosure. So these responses have many non linearities in them especially when we refer at the distribution of the energy over time. Due to the non linearities of the measuring system (loudspeaker + microphone) this energy is smeared over time while it should mainly be an almost perfect impulse, there are other factors that due this smear but let's not consider that for the moment.
      At this point I need to identify these peaks in time domain that represents my direct sound and reflection and then I will need to perform an STFT (Short time fourier transform) to move to the frequency domain and analyse the direction of arrivals per time range. All the IR will to be time windowed first and then processed. I understand how to do the rest of the process (at least for the moment) but I am struggling to automate the peak recognition process, which you are kindly helping me on.
      I assume that a transient algorithm is way too complex for this simple task but I might be misleading as unfortunately I do not have a very good knowledge of signal processing. I hope this clarifies more and I will have a look at your suggestion between tonight and tomorrow.
      Thank you very much Always very helpful discussing with you on the forum. :)
    • Feb 21 2016 | 7:22 pm
      Link to the paper as it is too big... http://www.iris.co.nz/media/14459/ISRA2013.pdf
    • Feb 23 2016 | 12:15 am
      Hello again, I hope I have not scared anyone or infringed any forum rules or copyright making clear what I wanted to achieve.
      I have tried the vb.aubio~ as suggested and it is definitely what I would ideally need. But I cannot make it to work to properly detect peaks in Impulse Responses.
      Please see patch below and please use file attached. Patch includes abstractions form the HIRT library by Alex Harker and Pierre AlexandreTremblay, only to perform normalization and trim of the IR file.
      I have tried different algorithms and settings in the vb.audio~ but I struggle to make it work. I can confirm it works with normal audio files (drum fills or voice recording). I am starting to think that it is because the algorithms are designed for normal audio transients and not for something that happen very quickly (Peaks in IR have some few ms distance between them) but I was not able to find any doc on this...Sorry..so it is just a guess.
      I would really appreciate some more help on this. I am ashamed but I thought I have found the solution when I have first opened vb.aubio~. Very nice object though, great work!!!
    • Feb 23 2016 | 12:16 am
      File type not permitted... Another try...Sorry
    • Feb 28 2016 | 5:06 pm
      Well it seems I have done something wrong for real... I have kept studying the issue and found that the amazing set of externals by Alex Harker have the descriptors~ object which can do many things. Among them, it can calculate kurtosis which is a measure of the "peakness".
      the following paper shows a method to use kurtosis to determine the onset times of an acoustic impulse response: http://www.20203dmedia.eu/materials/papers/Usher_JAS0EL172.pdf
      Now using the descriptors~ object, I can find some values that unfortunately do not corresponds to what I can detect by hand on an IR.
      Does anyone have any experience with the AHarker externals? thank you very much in advance
    • Mar 01 2016 | 12:12 pm
      Just to give a final update...as it seems no one is really interested in this... Alex Harker has kindly explained me that his descriptors~ object works in teh freq domain...while I will need something that works in time domain. So it is time for me to learn some lower level programming.
      I will stop bumping this tread. cheers