Ejemplo n.º 1
0
class Test(XMLTestCase):
    def setUp(self) -> None:
        self.score = TreeScoreTimewise()

    def test_1(self):
        instrument = TreeInstrument(name='banjo', abbreviation='bjo', number=2)
        instrument.standard_clefs = ALTO_CLEF
        sf = SimpleFormat(quarter_durations=[1, 2, 3, 1, 2, 3, 1, 2, 3])
        score = TreeScoreTimewise()
        sf.to_stream_voice(2).add_to_score(score)
        sf.transpose(5)
        sf.to_stream_voice(1).add_to_score(score)
        score.get_score_parts()[0].instrument = instrument

        xml_path = path + '_test_1.xml'
        score.write(xml_path)
        self.assertCompareFiles(xml_path)

    def test_2(self):
        sf = SimpleFormat(quarter_durations=[1, 2, 3, 1, 2, 3, 1, 2, 3],
                          midis=9 * [60 - 5])
        score = TreeScoreTimewise()
        for part_number in range(1, 5):
            sf.to_stream_voice().add_to_score(score, part_number=part_number)

        score_parts = score.get_score_parts()
        score_parts[0].instrument = Violin(1)
        score_parts[1].instrument = Violin(1)
        score_parts[2].instrument = Viola()
        score_parts[3].instrument = Cello()
        xml_path = path + '_test_2.xml'
        score.write(xml_path)
        self.assertCompareFiles(xml_path)

    def test_3(self):
        self.score.add_instrument(Violin(1))
        self.score.add_instrument(Violin(2))
        self.score.add_instrument(Piano())
        xml_path = path + '_test_3.xml'

        self.score.add_measure()
        self.score.write(xml_path)
        self.assertCompareFiles(xml_path)
Ejemplo n.º 2
0
class Test(XMLTestCase):
    def setUp(self) -> None:
        self.score = TreeScoreTimewise()

    def test_1(self):
        # finger tremolo
        xml_path = path + '_test_1.xml'
        durations = [2, 2, 2]
        midis = [60, 62, 63]
        sf = SimpleFormat(quarter_durations=durations, midis=midis)
        for chord in sf.chords:
            chord.add_flag(
                FingerTremoloFlag2(tremolo_chord=TreeChord(midis=[67])))

        sf.to_stream_voice().add_to_score(self.score)
        self.score.write(xml_path)
        self.assertCompareFiles(xml_path)

    def test_2(self):
        # finger tremolo
        xml_path = path + '_test_2.xml'
        durations = [1.5, 1.5, 1.5]
        midis = [60, 62, 63]
        sf = SimpleFormat(quarter_durations=durations, midis=midis)
        for chord in sf.chords:
            chord.add_flag(
                FingerTremoloFlag2(tremolo_chord=TreeChord(midis=[67])))

        sf.to_stream_voice().add_to_score(self.score)
        self.score.write(xml_path)
        self.assertCompareFiles(xml_path)

    def test_3(self):
        # finger tremolo
        xml_path = path + '_test_3.xml'
        durations = [0.25]
        midis = [60]
        sf = SimpleFormat(quarter_durations=durations, midis=midis)
        for chord in sf.chords:
            chord.add_flag(
                FingerTremoloFlag2(tremolo_chord=TreeChord(midis=[67])))

        sf.to_stream_voice().add_to_score(self.score)
        self.score.write(xml_path)
        self.assertCompareFiles(xml_path)

    def test_4(self):
        # finger tremolo
        xml_path = path + '_test_4.xml'
        durations = [0.2, 0.8, 1]
        midis = [60, 62, 63]
        sf = SimpleFormat(quarter_durations=durations, midis=midis)
        for chord in sf.chords:
            chord.add_flag(
                FingerTremoloFlag2(tremolo_chord=TreeChord(midis=[67])))

        sf.to_stream_voice().add_to_score(self.score)
        self.score.write(xml_path)
        self.assertCompareFiles(xml_path)

    def test_5(self):
        # finger tremolo
        self.score.add_instrument(Piano())
        xml_path = path + '_test_5.xml'
        durations = [5, 3]
        midis = [63, 0]
        sf = SimpleFormat(quarter_durations=durations, midis=midis)
        tremolo_chord = TreeChord(midis=[47])
        tremolo_chord.manual_staff_number = 2
        sf.chords[0].add_flag(FingerTremoloFlag2(tremolo_chord=tremolo_chord))
        sf.to_stream_voice().add_to_score(self.score)
        self.score.write(xml_path)
        self.assertCompareFiles(xml_path)

    def test_6(self):
        # noise flag
        xml_path = path + '_test_6.xml'
        durations = [
            0.25, 0.75, 0.5, 0.5, 1, 1.25, 1.5, 2, 2.5, 3, 3.5, 4, 4.5
        ]
        sf = SimpleFormat(quarter_durations=durations)
        for chord in sf.chords:
            chord.add_flag(NoiseFlag2())

        sf.to_stream_voice().add_to_score(self.score)
        self.score.write(xml_path)
        self.assertCompareFiles(xml_path)