Finding the strongest beat in a sound wave using autocorrelation

Click For Summary

Discussion Overview

The discussion revolves around the use of autocorrelation to identify the strongest beats in a sound wave, specifically in the context of a piano piece played at a steady tempo. Participants explore the theoretical underpinnings of autocorrelation, its relationship to rhythm and periodicity, and alternative methods for beat detection.

Discussion Character

  • Exploratory
  • Technical explanation
  • Conceptual clarification
  • Debate/contested

Main Points Raised

  • One participant expresses confusion about how the autocorrelation function relates to identifying beats, noting that their initial results do not reflect the expected tempo of the piece.
  • Another participant suggests that a clear sine wave can be observed in the autocorrelation function, which corresponds to a hidden sine wave in the original signal.
  • There is a proposal to analyze short-term RMS values and apply FFT to detect low-frequency energy variations that may indicate beats.
  • One participant questions the connection between a time signal's periodicity, its autocorrelation function, and its Fourier transform, particularly in relation to rhythm.
  • Another participant mentions that the autocorrelation function may not reveal rhythm unless there are consistent rhythmic repeats from the same instrument.
  • Concerns are raised about the effectiveness of autocorrelation for complex audio signals, such as those from a complete piano piece, suggesting that short data windows might yield better insights.
  • Some participants recommend looking into "beat detection" as a related problem and mention resources for further exploration.

Areas of Agreement / Disagreement

Participants express varying levels of understanding and agreement regarding the effectiveness of autocorrelation for beat detection. There is no consensus on the best approach, and multiple competing views on the relationship between autocorrelation, rhythm, and pitch are present.

Contextual Notes

Limitations include the complexity of audio signals, the potential ineffectiveness of autocorrelation for certain types of music, and the need for further exploration of specific examples to clarify theoretical concepts.

Who May Find This Useful

This discussion may be of interest to those involved in digital signal processing, music analysis, and audio engineering, particularly in the context of beat detection and rhythm analysis.

wildetudor
Messages
22
Reaction score
0
Hi everyone,

I have a sound wave representing a piano piece played at a steady tempo, and would like to get a graph of the saliency of each beat (essentially, a probability distribution for how strong each possible tempo is). I understand that this is done by plotting the autocorrelation function, however I don't quite understand why a graph of r coefficients against each possible lag value (which is, as far as I understand, the deffinition of an autocorrelogram) would have anything to do with beats.

The following Matlab code produces a graph that doesn't in any way suggest anything to do with the actual steady beat of the piece (60 BPM):

Code:
[y,Fs] = wavread('d:\bach.wav');
[r,lags]=xcorr(y,'coeff');  
plot(lags,r)

Clearly I'm understanding autocorrelation wrongly. For instance, in this very simple example, the frequency of the sine hidden in noise is nowhere visible from the autocorrelation graph - or is it? Furthermore, that frequency would actually be the pitch of the sound, and not any rhythm-related measure!

The MIR toolbox for Matlab has a function specifically for finding the tempo of a waveform - however what I'm after now is understanding these things at a theoretical level.

Anticipated thanks for any clarifications!
 
Engineering news on Phys.org
wildetudor said:
For instance, in this very simple example, the frequency of the sine hidden in noise is nowhere visible from the autocorrelation graph - or is it?
You can see a clear sine wave in the autocorrelation function, which corresponds to a "hidden" sine wave in the original function with a period of ~10.

Furthermore, that frequency would actually be the pitch of the sound, and not any rhythm-related measure!
Can you find the time steps where the frequency in the signal changes? An autocorrelation of that should help.
Alternatively, search for steps in the autocorrelation function, this could help as well.
 
Problem with music is that it can be very subtle. However, to find an 'obvious beat', why not find the short term RMS values (Energy with time) of a long passage and FFT that to find low frequency (sub Hz) energy variations. Some pre-filtering could identify components like cymbal strikes or bass drum beats. (Sound to light 'disco' boxes do this quite well)
 
Thanks for your replies! I'm afraid I still don't fully understand, though, the link between a time signal's (waveform's) periodicity and its autocorrelation function; and, I could also add, the link between the signal's autocorrelation function and its Fourier transform (the latter of which I understand how it relates to pitch but not to rhythm)
 
wildetudor said:
Thanks for your replies! I'm afraid I still don't fully understand, though, the link between a time signal's (waveform's) periodicity and its autocorrelation function; and, I could also add, the link between the signal's autocorrelation function and its Fourier transform (the latter of which I understand how it relates to pitch but not to rhythm)

The rhythm would correspond to peaks in level (rectified and integrated?) and the rate at which they repeat. That's why I included the idea of "sub Hz".

I am not sure that the ACF would necessarily reveal the rhythm unless there were rhythmic repeats of the same instrument producing a note that was somehow phase consistent? It could be worth while trying with some actual examples of music.
 
Thanks, that's quite helpful, I'll play around with it in Matlab on my own a bit to facilitate intuition :)
 
The autocorrelation for the audio of a complete piano piece probably won't show anything useful.

If you calculate autocorrelations for short "windows" of the data, you might be able to see the CHANGES in frequency content at the start of each new note. But even a single note on a piano is far from being a simple sine wave, and most piano music has several notes at different pitches sounding at the same time, so this isn't going to be easy to see.

There are a few commercial computer programs that claim to be able to convert an audio recording into music notation, for example http://www.neuratron.com/audioscore.htm, but they don't work very well for anything except very simple audio, like a single instrument that can only play one note at a time.

But it is possible ... http://www.ted.com/talks/john_walker_re_creates_great_performances.html
 
If your task is to find a reliable method using DSP and not a brain, it will fall over for some examples, I'm sure. It would depend on how good it needs to be. Good luck and have fun.
 
better look up "beat detection" which is a similar problem to pitch detection. i would suggest googling jean larouche beat detection without quotes and reading any number of documents this guy wrote.

it ain't an easy problem.
 

Similar threads

  • · Replies 31 ·
2
Replies
31
Views
5K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 1 ·
Replies
1
Views
1K
Replies
22
Views
5K
  • · Replies 6 ·
Replies
6
Views
6K
  • · Replies 7 ·
Replies
7
Views
9K
  • · Replies 1 ·
Replies
1
Views
7K
  • · Replies 1 ·
Replies
1
Views
7K
Replies
1
Views
6K