Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ repos:
rev: v4.4.0
hooks:
- id: check-yaml
args: [--unsafe]
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,8 @@ Default method: `"arzt"`
| `"dixon"` | On-line time warping by Dixon (2005) |
| `"outerhmm"` | Outer-product HMM score follower by Nakamura (2014) |
| `"skf"` | Switching Kalman Filter with hidden tempo by Jiang and Raphael (2020) |
| `"arzt_tempo"` | On-line time warping by Arzt with a tempo model (Arzt and Widmer, 2010) |
| `"arzt_multi_fold"` | Arzt OLTW tracking several unfolded score variants in parallel |

### MIDI (`input_type="midi"`)

Expand Down
1 change: 1 addition & 0 deletions matchmaker/dp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
OnlineTimeWarpingArztEvent,
OnlineTimeWarpingArztFrame,
)
from .oltw_arzt_multi_fold import OnlineTimeWarpingArztMultiFold
from .oltw_dixon import (
OnlineTimeWarpingDixon,
OnlineTimeWarpingDixonEvent,
Expand Down
16 changes: 14 additions & 2 deletions matchmaker/dp/dtw_loop.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ def oltw_arzt_loop(
int window_end,
int input_index,
float min_costs,
int min_index
int min_index,
signed char[:] backpointers = None
):
"""
Cythonized main loop for online time warping.
Expand All @@ -46,6 +47,9 @@ def oltw_arzt_loop(
Minimum costs of current window.
min_index: int
Index of minimum costs of current window.
backpointers: numpy.ndarray or None
Optional array of shape (window_end - window_start,) to record backpointers
(1=vertical, 2=horizontal, 3=diagonal).

Returns
-------
Expand Down Expand Up @@ -84,6 +88,14 @@ def oltw_arzt_loop(
min_dist = min(dist1, dist2, dist3)
global_cost_matrix[score_index + 1, 1] = min_dist

if backpointers is not None:
if dist1 <= dist2 and dist1 <= dist3:
backpointers[idx] = 1
elif dist2 <= dist3:
backpointers[idx] = 2
else:
backpointers[idx] = 3

norm_cost = min_dist / (input_index + score_index + 1.0)

# check if new cell has lower costs and might be current position
Expand All @@ -96,7 +108,7 @@ def oltw_arzt_loop(

update_cost_matrix(global_cost_matrix, N)

return global_cost_matrix, min_index, min_costs
return np.asarray(global_cost_matrix), min_index, min_costs

@cython.boundscheck(False)
@cython.wraparound(False)
Expand Down
Loading
Loading