Пример #1
0
    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)
Пример #2
0
    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)
Пример #3
0
    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
        ]
Пример #4
0
    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
        ]
Пример #5
0
    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
        ]
Пример #6
0
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)
Пример #7
0
    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
        ]