CPJKU / madmom

Python audio and music signal processing library
https://madmom.readthedocs.io
Other
1.35k stars 206 forks source link

Downbeat tracking: support weighting for time signatures #402

Open declension opened 5 years ago

declension commented 5 years ago

Use case

When I'm running DBNDownBeatTrackingProcessor, I'm, passing parameters beats_per_bar=[3, 4, 6] to detect from a mixed bunch over many genres (but mostly pop / rock / soul / dance music).

The vast majority is in common (4) time, with a few 6/8 plus a few "difficult" ones. However, by including especially 6 in this list, I find the processor occasionally misidentifying 4/4 pieces, especially rock (and heavier) as having six beats per downbeat in the output.

Workarounds attempted

Suggestion

Would it be possible to provide weightings or other forms of influencing from the selection of beat per bar given in an array - e.g. just weights=[1,10,2] or similar?

Thanks

superbock commented 5 years ago

Yes, that would be possible. DBNDownBeatTrackingProcessor choses the most likely bar length by comparing the negative log likelihood of the bar lengths in question. So a simple weighting scheme can be applied easily by altering results in line 284 of features.downbeats. Adding a log probability distribution (i.e. results += np.log(weights / np.sum(weights)) should do the trick.

num_tempi is used to limit the number of tempi to be modelled by the DBN in oder to make computation faster and consume less memory. Thus, any number smaller than the equivalent number of frames using a linear spacing for the different tempi usually results in worse performance. E.g. the system uses 100 fps, and you want to detect tempi between 60 and 180 bpm. These tempi have beat intervals of 100 and (~)33 frames respectively. Thus, without this parameter set, the DBN models each interval between these beat lengths, resulting in 67 tempi being modelled. If you limit it to e.g. 40, the system aligns 40 beat intervals logarithmically between these two intervals, skipping certain beat intervals and leading to coarser tempo resolution.

declension commented 5 years ago

Thanks @superbock I'll have a go at working that out. For some reason I'm getting a lot fewer misidentifications now but I guess it's a good thing to have available. Is this something you'd consider in a PR?

superbock commented 5 years ago

Definitely yes!

surajsonee commented 5 years ago

how can i detect bar line or measure line from audio/music? is there any feature available in madmom module?

superbock commented 5 years ago

You can use the downbeat tracking module (features.downbeats) and filter for beat numbers equal to 1.

surajsonee commented 5 years ago

can you please give me an example of code, so that I can understand better. Thanks!

superbock commented 5 years ago

(Almost) all classes come with examples. For a running example, please see bin/DBNDownBeatTracker.

surajsonee commented 5 years ago

okay, Thank you very much!. I want to find the song structure like intro, chorus, verse, bridge and outro. is it possible to get start time and end time these segments? also do we can find the time signature of any song using madmom?

superbock commented 5 years ago

Yes, simply check what the highest beat number is. The output is in the format bear.beat. Please note that DBNDownBeatTracker is not able to moel time signature changes.

surajsonee commented 5 years ago

okay, Thanks! yes but I am not able to find where from chorus and verse start and end. if any example code can you provide will be appreciated.

superbock commented 5 years ago

Please do not edit comments in such a way that the content changes considerably! The comments now read like I was not answering your question at all; but you were asking on how to find the time signature of a song, and I answered that question. Also, please do not use existing issues to ask something completely unrelated to this issue at hand.

But to answer your question: madmom does not contain functionality to discover song structure.

surajsonee commented 5 years ago

okay Thanks!