Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Downbeat tracking: support weighting for time signatures #402

Open
declension opened this issue Dec 9, 2018 · 12 comments · May be fixed by #408
Open

Downbeat tracking: support weighting for time signatures #402

declension opened this issue Dec 9, 2018 · 12 comments · May be fixed by #408

Comments

@declension
Copy link
Contributor

declension commented Dec 9, 2018

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

  • I've tried fiddling with max / min BPMs - not much help
  • I've tried altering the number of tempi e.g. [40, 100, 40] in the hope that this would weight the probability of, but this felt like it was perhaps harming the downbeat detection overall - is that right? Which parameters need models to be retrained etc?

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
Copy link
Collaborator

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
Copy link
Contributor Author

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
Copy link
Collaborator

Definitely yes!

declension added a commit to declension/madmom that referenced this issue Jan 10, 2019
 * Optional parameter, implicitly defaults to ones for the array
 * Clean up the handling of lengths into the constructor, it was getting verbose
 * Check weights don't sum to zero, to avoid divide-by-zero pain.
 * Weight the HMM results in log space by normalised weight values, as suggested by @superbock
 * Add new test to prove that (sufficient, but arbitrary) weighting to 3-time (over 4-time)
   does indeed return 3-time beats results.

This fixes CPJKU#402.
@declension declension linked a pull request Jan 10, 2019 that will close this issue
@surajsonee
Copy link

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

@superbock
Copy link
Collaborator

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

@surajsonee
Copy link

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

@superbock
Copy link
Collaborator

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

@surajsonee
Copy link

surajsonee commented Sep 29, 2019

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
Copy link
Collaborator

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
Copy link

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
Copy link
Collaborator

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
Copy link

okay Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants