4 ms·
If you’re going to do autocorrelation, why not just do it on the audio signal? Why go through all the trouble of doing a FFT on the input signal and extracting
by klodolph 7y ago
If you’re going to do autocorrelation, why not just do it on the audio signal? Why go through all the trouble of doing a FFT on the input signal and extracting notes first?
Just to give more details—you can do autocorrelation using the FFT. Autocorrelation is done by calculating the convolution of a signal with a reversed copy of itself. Convolution in the time domain is multiplication in the frequency domain. So you take the FFT, do a pointwise multiplication, and then reverse FFT. The loop points will be spikes in the result.
There are some additional factors you will likely want to consider, like windowing, but this is a much more straightforward way to do things.
(As an aside, I would probably put the G in the third measure on the left hand.)
- MadWombat 7y ago> If you’re going to do autocorrelation, why not just do it on the audio signal? Because audio signal is very sparse. On a decent quality file you have 41K or 48K samples per second and you need a window of at least half a second to pick a looping point.
- klodolph 7y agoAudio signals are not sparse at all, unless you are using a definition of “sparse” that I’m unfamiliar with. I also don’t understand your complaint about the looping point, or window size. If you don’t understand how autocorrelation works, I can provide some pseudocode to demonstrate the technique. This is not an esoteric or unusual way of finding a looping point.
- MadWombat 7y agoI might be misusing "sparse". What I meant was that in a sufficiently high sample rate music, there are a lot of samples between notes and a lot of the samples are noise and garbage. I do understand how autocorrelation works, to a reasonable degree. And that is the reason for the DFT. We are talking music, so we care about the frequencies more than about the immediate sample value. And the window is important because autocorrelating over individual data points is useless, sound signals are noisy and you get a lot of randomness. Also, I tried the code provided on a few pieces I thought would be appropriate and it didn't do a very good job. I might run a few experiments.
- klodolph 7y ago> We are talking music, so we care about the frequencies more than about the immediate sample value. The frequencies and the sample values are just two different ways at looking at the same data. > And the window is important because autocorrelating over individual data points is useless, sound signals are noisy and you get a lot of randomness. I’m not sure what you mean by “individual data points”. The autocorrelation is computed for an entire signal, not for any individual data point. Talking about an individual data point in the input doesn’t make much sense. Autocorrelation is not especially susceptible to noise. > Also, I tried the code provided on a few pieces I thought would be appropriate and it didn't do a very good job. I might run a few experiments. Try doing just a simple autocorrelation instead. This will work for the use cases described (looped samples of music), you will see a large spike in the autocorrelation for the loop point. For music which repeats but is not looped, you can do some preprocessing e.g. to find envelopes and do autocorrelation on that.
- MadWombat 7y ago> you will see a large spike in the autocorrelation for the loop point Why? All I can hope for is to pick the max autocorrelation value, but why would I see a spike?
- alanbernstein 7y agoThat is the exact intended purpose of the autocorrelation