Skip to content
Merged
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
21 changes: 14 additions & 7 deletions matchmaker/matchmaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import numpy as np

import partitura
from partitura.io.exportmidi import get_ppq

from matchmaker.dp import OnlineTimeWarpingArzt, OnlineTimeWarpingDixon
from matchmaker.features.audio import (
FRAME_RATE,
Expand All @@ -27,6 +29,7 @@
GaussianAudioPitchTempoHMM,
PitchHMM,
PitchIOIHMM,
PitchHMM,
)
from matchmaker.prob.outer_product_hmm import OuterProductHMM
from matchmaker.utils.eval import (
Expand Down Expand Up @@ -143,10 +146,10 @@ def __init__(
device_name_or_index: Union[str, int] = None,
sample_rate: int = SAMPLE_RATE,
frame_rate: int = FRAME_RATE,
kwargs=KWARGS,
unfold_score=True,
tempo: Optional[float] = None,
adjust_tempo: bool = False,
kwargs = KWARGS,
unfold_score = True,
):
self.score_file = str(score_file)
self.performance_file = (
Expand Down Expand Up @@ -176,6 +179,7 @@ def __init__(
self.method = method
self.config = kwargs[input_type][self.method]
self.adjust_tempo = adjust_tempo
self.config = kwargs[input_type][method]

# setup score file
if score_file is None:
Expand Down Expand Up @@ -232,12 +236,10 @@ def __init__(
)
elif self.feature_type == "pitch_ioi":
self.processor = PitchIOIProcessor(piano_range=self.config["piano_range"])
elif self.feature_type == "pitchclass":
elif self.feature_type == "pitchclass":
self.processor = PitchClassPianoRollProcessor()
elif self.feature_type == "pianoroll":
self.processor = PianoRollProcessor(piano_range=True)
elif self.feature_type == "pitchclass":
self.processor = PitchClassPianoRollProcessor()
self.processor = PianoRollProcessor(piano_range=self.config["piano_range"])
else:
raise ValueError(f"Invalid feature type `{self.feature_type}`")

Expand All @@ -252,11 +254,16 @@ def __init__(
raise ValueError(
f"Invalid performance file. Expected MIDI file, but got {self.performance_file}"
)

# validate method first
if method is None:
method = DEFAULT_METHODS[self.input_type]
elif method not in AVAILABLE_METHODS:
raise ValueError(f"Invalid method. Available methods: {AVAILABLE_METHODS}")

# setup distance function
if distance_func is None:
distance_func = DEFAULT_DISTANCE_FUNCS[method]

# setup stream device
if self.input_type == "audio":
self.stream = AudioStream(
Expand Down
Loading