def write(self, score, beat_horizon, one_to_many): group = self.fp.create_group(score.name) waterfall = [{ "Annotation": { "one_to_many": one_to_many } }, { f"neural.{self.fp.attrs['writer']}.Writer": { "group": group } }] vs.separate(score, waterfall, beat_horizon) self.groups.append(group)
def test_one_to_one(self): waterfall = [ { "Annotation": { "one_to_many": False } } ] assignments = vs.separate(self.score, waterfall, self.beat_horizon) voices = [voice for assignment in assignments for voice in assignment] expected_pairs = [ (voices[0], voices[2]), (voices[1], voices[3]), (voices[2], voices[6]), (voices[3], voices[8]), (voices[6], voices[9]), (voices[7], voices[10]) ] for pair in expected_pairs: with self.subTest(f"({pair[0]}, {pair[1]})"): self.assertTrue(pair[1] in pair[0].right)
def setUp(self): path = os.path.dirname(os.path.abspath(__file__)) sheet = f"{path}/test.musicxml" score = vs.Score(sheet) waterfall = [{"Annotation": {"one_to_many": True}}] beat_horizon = 2 assignments = vs.separate(score, waterfall, beat_horizon) self.voices = [ voice for assignment in assignments for voice in assignment ]
def setUp(self): path = os.path.dirname(os.path.abspath(__file__)) sheet = f"{path}/test.musicxml" score = vs.Score(sheet) waterfall = [{"PseudoPolyphony": {"repeat_limit": 2}}] beat_horizon = 2 assignments = vs.separate(score, waterfall, beat_horizon) self.voices = [ voice for assignment in assignments for voice in assignment ]
def setUp(self): path = os.path.dirname(os.path.abspath(__file__)) score = vs.Score(f"{path}/test.musicxml") network = f"{path}/test.npy" waterfall = [{ "neural.NoteLevel": { "network": network, "assignment_threshold": .7 } }] beat_horizon = 4 assignments = vs.separate(score, waterfall, beat_horizon) self.voices = [ voice for assignment in assignments for voice in assignment ]
def separate(score, parameters, overrides): separators = [] for separator in parameters["separators"]: name = next(iter(separator)) args = separator[name] if overrides: override_args = override[name] for key, value in override_args.items(): args[key] = value separators.append((name, args)) beat_horizon = parameters["beat_horizon"] return vs.separate(score, separators, beat_horizon)
def setUp(self): path = os.path.dirname(os.path.abspath(__file__)) name = self._testMethodName sheet = f"{path}/{name}.musicxml" score = vs.Score(sheet) waterfall = [{"Annotation": {"one_to_many": True}}] beat_horizon = None assignments = vs.separate(score, waterfall, beat_horizon) self.active_voices = vs.ActiveVoices(beat_horizon) for assignment in assignments: self.active_voices.insert(assignment) self.voices = [ voice for assignment in assignments for voice in assignment ]