meinardmueller / synctoolbox

Sync Toolbox - Python package with reference implementations for efficient, robust, and accurate music synchronization based on dynamic time warping (DTW)
https://meinardmueller.github.io/synctoolbox
Other
108 stars 11 forks source link

Define a limit on how far to warp #22

Open xavriley opened 1 year ago

xavriley commented 1 year ago

Firstly, thank you for releasing this library!

I'm working with some data where I know that the midi is roughly well aligned with the audio already, but I want to make an even finer alignment where possible.

Is there a way to restrict the warping so that it yields a path which is always within 50ms of the original timing? (i.e. by limiting the search area) I hope that makes sense but please let me know if I can clarify.

ahnonay commented 1 year ago

Hi Xavier,

thanks for your interest in synctoolbox! Yes, what you are describing makes a lot of sense. It corresponds to applying a narrow Sakoe-Chiba band along the diagonal (see e.g. Section 3.2.2.3 in "Fundamentals of Music Processing", Müller '15; or the corresponding notebook in the FMP notebooks).

This is not currently implemented in synctoolbox. However, you could easily achieve this by putting infinite costs into the local cost matrix outside of the 50ms band. Then, you can use that modified cost matrix for DTW.

Hope this helps! Please don't hesitate to contact us if you want to discuss this further.