Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect repetition in sound file

I really have no idea if what I'm thinking is feasible, but what the heck.

I have some MP3s of game music. This game music was rendered from a Tracker format, which means that at some point the track loops back to an earlier point, so it's like this:

Intro---|Main loop-------------------|Main loop-------------------|Main loop fade|

Or in "regex" form:

/^\p{Intro}(\p{Main_0}\p{Main_1}\p{Main_2})+\p{Main_0}\p{Main_1_fading}$/

I hope this communicates what's going on!

Basically, I want to know if I can detect the start and end of the main loop based on repetition of the waveform. The idea being that since they are rendered from a tracker format, the waveform should be exactly the same between loops, even after having been "baked" in MP3 format.

If this is possible, how might I go about finding such a repeating loop? The goal is to programmatically extend these looping tracks to repeat more times, so I don't have to do it manually.

At this stage I'm simply looking for general algorithms to approach the problem. I can work out how to read an MP3 file's waveform, process it and save a new one without difficulty, what I need help with here is how to find a repeating portion of the waveform. Does anyone have any wisdom to impart?

like image 217
Niet the Dark Absol Avatar asked Oct 19 '22 23:10

Niet the Dark Absol


1 Answers

Finding the max. peaks of the autocorrelation-function should help you finding repetitions in a signal.

like image 135
Frank Zalkow Avatar answered Oct 30 '22 16:10

Frank Zalkow