Esempio n. 1
0
class testPartWithName(Lily):
    def setUp(self):
        self.item = PartNode()
        self.item.addEmptyMeasure(1,1)
        self.item.GetItem().name = "charlotte"
        self.lilystring = ["zerostaffone = \\new Staff \with {\ninstrumentName = \\markup { \n\r \\column { \n\r\r \\line { \"charlotte\" \n\r\r } \n\r } \n } \n }{ % measure 1\n | \n\n }\n\n", "\zerostaffone"]

    def tearDown(self):
        self.item = None
Esempio n. 2
0
class testPartMeasureWithNote(Lily):
    def setUp(self):
        self.item = PartNode()
        self.item.addEmptyMeasure(1,1)
        measure = self.item.getMeasure(1,1)
        note = Note.Note()
        note.pitch = Note.Pitch()
        measure.addNote(note)
        self.lilystring = ["zerostaffone = \\new Staff{ % measure 1\nc'  | \n\n }\n\n", '\\zerostaffone']
Esempio n. 3
0
class testPartMeasureWithNote(Lily):
    def setUp(self):
        self.item = PartNode()
        self.item.addEmptyMeasure(1, 1)
        measure = self.item.getMeasure(1, 1)
        note = Note.Note()
        note.pitch = Note.Pitch()
        measure.addNote(note)
        self.lilystring = [
            "zerostaffone = \\new Staff{ % measure 1\nc'  | \n\n }\n\n",
            '\\zerostaffone'
        ]
Esempio n. 4
0
class testPartWithName(Lily):
    def setUp(self):
        self.item = PartNode()
        self.item.addEmptyMeasure(1, 1)
        self.item.GetItem().name = "charlotte"
        self.lilystring = [
            "zerostaffone = \\new Staff \with {\ninstrumentName = \\markup { \n\r \\column { \n\r\r \\line { \"charlotte\" \n\r\r } \n\r } \n } \n }{ % measure 1\n | \n\n }\n\n",
            "\zerostaffone"
        ]

    def tearDown(self):
        self.item = None
Esempio n. 5
0
class testPartMultiBars(Lily):
    def setUp(self):
        self.item = PartNode()
        self.item.addEmptyMeasure(1,1)
        self.item.addEmptyMeasure(2,1)
        measure2 = self.item.getMeasure(2,1)
        measure = self.item.getMeasure(1,1)
        note = Note.Note()
        note.pitch = Note.Pitch()
        note2 = Note.Note()
        note2.pitch = Note.Pitch()
        measure.addNote(note)
        measure2.addNote(note2)
        self.lilystring = ["zerostaffone = \\new Staff{ % measure 1\nc'  | \n\n % measure 2\nc'  | \n\n }\n\n","\\zerostaffone"]
Esempio n. 6
0
class testPartMultistafftaves(Lily):
    def setUp(self):
        self.item = PartNode()
        self.item.addEmptyMeasure(1,1)
        self.item.addEmptyMeasure(1,2)
        measure1 = self.item.getMeasure(1,1)
        measure2 = self.item.getMeasure(1,2)
        note1 = Note.Note()
        note1.pitch = Note.Pitch()
        note2 = Note.Note()
        note2.pitch = Note.Pitch()
        measure1.addNote(note1)
        measure2.addNote(note2)
        self.lilystring = ["zerostaffone = \\new Staff{ % measure 1\nc'  | \n\n }\n\nzerostafftwo = \\new Staff{ % measure 1\nc'  | \n\n }\n\n", "\\new StaffGroup <<\zerostaffone\n\zerostafftwo>>"]
Esempio n. 7
0
class testPartMultistafftavesWithName(Lily):
    def setUp(self):
        self.item = PartNode()
        self.item.GetItem().name = "Piano"
        self.item.addEmptyMeasure(1,1)
        measure = self.item.getMeasure(1,1)
        note = Note.Note()
        note.pitch = Note.Pitch()
        measure.addNote(note)
        self.item.addEmptyMeasure(1,2)
        measure2 = self.item.getMeasure(1,2)
        note2 = Note.Note()
        note2.pitch = Note.Pitch()
        measure2.addNote(note2)
        self.lilystring = ["zerostaffone = \\new Staff{ % measure 1\nc'  | \n\n }\n\nzerostafftwo = \\new Staff{ % measure 1\nc'  | \n\n }\n\n", "\\new StaffGroup \\with {\ninstrumentName = \markup { \n\r \column { \n\r\r \line { \"Piano\" \n\r\r } \n\r } \n } \n }<<\zerostaffone\n\zerostafftwo>>"]
Esempio n. 8
0
class testPartMultiBars(Lily):
    def setUp(self):
        self.item = PartNode()
        self.item.addEmptyMeasure(1, 1)
        self.item.addEmptyMeasure(2, 1)
        measure2 = self.item.getMeasure(2, 1)
        measure = self.item.getMeasure(1, 1)
        note = Note.Note()
        note.pitch = Note.Pitch()
        note2 = Note.Note()
        note2.pitch = Note.Pitch()
        measure.addNote(note)
        measure2.addNote(note2)
        self.lilystring = [
            "zerostaffone = \\new Staff{ % measure 1\nc'  | \n\n % measure 2\nc'  | \n\n }\n\n",
            "\\zerostaffone"
        ]
Esempio n. 9
0
class testPartMultistafftaves(Lily):
    def setUp(self):
        self.item = PartNode()
        self.item.addEmptyMeasure(1, 1)
        self.item.addEmptyMeasure(1, 2)
        measure1 = self.item.getMeasure(1, 1)
        measure2 = self.item.getMeasure(1, 2)
        note1 = Note.Note()
        note1.pitch = Note.Pitch()
        note2 = Note.Note()
        note2.pitch = Note.Pitch()
        measure1.addNote(note1)
        measure2.addNote(note2)
        self.lilystring = [
            "zerostaffone = \\new Staff{ % measure 1\nc'  | \n\n }\n\nzerostafftwo = \\new Staff{ % measure 1\nc'  | \n\n }\n\n",
            "\\new StaffGroup <<\zerostaffone\n\zerostafftwo>>"
        ]
Esempio n. 10
0
class testPartMultistafftavesWithName(Lily):
    def setUp(self):
        self.item = PartNode()
        self.item.GetItem().name = "Piano"
        self.item.addEmptyMeasure(1, 1)
        measure = self.item.getMeasure(1, 1)
        note = Note.Note()
        note.pitch = Note.Pitch()
        measure.addNote(note)
        self.item.addEmptyMeasure(1, 2)
        measure2 = self.item.getMeasure(1, 2)
        note2 = Note.Note()
        note2.pitch = Note.Pitch()
        measure2.addNote(note2)
        self.lilystring = [
            "zerostaffone = \\new Staff{ % measure 1\nc'  | \n\n }\n\nzerostafftwo = \\new Staff{ % measure 1\nc'  | \n\n }\n\n",
            "\\new StaffGroup \\with {\ninstrumentName = \markup { \n\r \column { \n\r\r \line { \"Piano\" \n\r\r } \n\r } \n } \n }<<\zerostaffone\n\zerostafftwo>>"
        ]
Esempio n. 11
0
class testAddToMeasure(unittest.TestCase):
    def setUp(self):
        self.item = PieceTree.PieceTree()
        self.part = PartNode()
        self.item.AddNode(self.part, index="P1")
        self.part.addEmptyMeasure()
        self.measure = self.part.getMeasure()

    def testAddNote(self):
        note = "3"
        self.measure.addNote(note)
        voice = self.measure.getVoice(1)
        self.assertEqual(voice.GetChild(0).GetItem(), note)

    def testAddDirection(self):
        direction = "2"
        self.measure.addDirection(direction)
        voice = self.measure.getVoice(1)
        self.assertEqual(voice.GetChild(0).GetChild(1).GetItem(), direction)

    def testAddExpression(self):
        exp = "2"
        self.measure.addExpression(exp)
        voice = self.measure.getVoice(1)
        self.assertEqual(voice.GetChild(0).GetChild(0).GetItem(), exp)

    def testAddPlaceholder(self):
        self.measure.addPlaceholder()
        voice = self.measure.getVoice(1)
        self.assertEqual(voice.GetChild(0).GetItem(), None)

    def testAddNoteWithPlaceholderBeforeIt(self):
        note = 2
        self.measure.addNote(note)
        self.measure.index = 0
        self.measure.addPlaceholder()
        voice = self.measure.getVoice(1)
        self.assertEqual(voice.GetChild(0).GetItem(), None)

    def testForward(self):
        self.measure.addNote(1)
        self.measure.Forward(duration=16)
        self.assertEqual(self.measure.index, 2)

    def testBackup(self):
        self.measure.addNote(1)
        self.measure.Backup(duration=15)
        self.assertEqual(self.measure.index, 0)

    def testForwardCreatesAPlaceholder(self):
        self.measure.addNote(1)
        self.measure.Forward(duration=16)
        voice = self.measure.getVoice(1)
        self.assertIsInstance(voice.GetChild(1), NoteNode.NoteNode)

    def testBackupAndAddNote(self):
        self.measure.addNote(1)
        self.measure.Backup(duration=15)
        self.measure.addNote(2)
        voice = self.measure.getVoice(1)
        self.assertEqual(voice.GetChild(0).GetItem(), 2)

    def testAddDirectionThenNode(self):
        dir = 1
        note = 3
        self.measure.addDirection(dir)
        self.measure.addNote(note)
        voice = self.measure.getVoice(1)
        self.assertEqual(voice.GetChild(0).GetItem(), note)

    def testAddDirectionToSecondNote(self):
        dir = 1
        note = 2
        note1 = 3
        self.measure.addNote(note)
        self.measure.addDirection(dir)
        self.measure.addNote(note1)
        voice = self.measure.getVoice(1)
        self.assertEqual(voice.GetChild(1).GetChild(1).GetItem(), dir)

    def testAddChordNote(self):
        note = 2
        note1 = 3
        self.measure.addNote(note)
        self.measure.addNote(note1, chord=True)
        voice = self.measure.getVoice(1)
        self.assertEqual(voice.GetChild(0).GetChild(0).GetItem(), 3)

    def testAddExpressionThenChordNote(self):
        note = 2
        note1 = 3
        exp = 0
        self.measure.addNote(note)
        self.measure.addExpression(exp)
        self.measure.addNote(note1, chord=True)
        voice = self.measure.getVoice(1)
        self.assertEqual(voice.GetChild(0).GetChild(0).GetItem(), 3)

    def testLilyOutputOfPlaceholders(self):
        self.measure.addPlaceholder()
        voice = self.measure.getVoice(1)
        self.assertEqual(voice.GetChild(0).toLily(), "")

    def testLilyOutputOfPlaceholdersWithChildren(self):
        self.measure.addPlaceholder()
        self.measure.addDirection(1)
        voice = self.measure.getVoice(1)
        self.assertEqual(voice.GetChild(0).toLily(), "")
Esempio n. 12
0
class testAddToMeasure(unittest.TestCase):

    def setUp(self):
        self.item = PieceTree.PieceTree()
        self.part = PartNode()
        self.item.AddNode(self.part, index="P1")
        self.part.addEmptyMeasure()
        self.measure = self.part.getMeasure()

    def testAddNote(self):
        note = "3"
        self.measure.addNote(note)
        voice = self.measure.getVoice(1)
        self.assertEqual(voice.GetChild(0).GetItem(), note)

    def testAddDirection(self):
        direction = "2"
        self.measure.addDirection(direction)
        voice = self.measure.getVoice(1)
        self.assertEqual(voice.GetChild(0).GetChild(1).GetItem(), direction)

    def testAddExpression(self):
        exp = "2"
        self.measure.addExpression(exp)
        voice = self.measure.getVoice(1)
        self.assertEqual(voice.GetChild(0).GetChild(0).GetItem(), exp)

    def testAddPlaceholder(self):
        self.measure.addPlaceholder()
        voice = self.measure.getVoice(1)
        self.assertEqual(voice.GetChild(0).GetItem(), None)

    def testAddNoteWithPlaceholderBeforeIt(self):
        note = 2
        self.measure.addNote(note)
        self.measure.index = 0
        self.measure.addPlaceholder()
        voice = self.measure.getVoice(1)
        self.assertEqual(voice.GetChild(0).GetItem(), None)

    def testForward(self):
        self.measure.addNote(1)
        self.measure.Forward(duration=16)
        self.assertEqual(self.measure.index, 2)

    def testBackup(self):
        self.measure.addNote(1)
        self.measure.Backup(duration=15)
        self.assertEqual(self.measure.index, 0)

    def testForwardCreatesAPlaceholder(self):
        self.measure.addNote(1)
        self.measure.Forward(duration=16)
        voice = self.measure.getVoice(1)
        self.assertIsInstance(voice.GetChild(1), NoteNode.NoteNode)

    def testBackupAndAddNote(self):
        self.measure.addNote(1)
        self.measure.Backup(duration=15)
        self.measure.addNote(2)
        voice = self.measure.getVoice(1)
        self.assertEqual(voice.GetChild(0).GetItem(), 2)

    def testAddDirectionThenNode(self):
        dir = 1
        note = 3
        self.measure.addDirection(dir)
        self.measure.addNote(note)
        voice = self.measure.getVoice(1)
        self.assertEqual(voice.GetChild(0).GetItem(), note)

    def testAddDirectionToSecondNote(self):
        dir = 1
        note = 2
        note1 = 3
        self.measure.addNote(note)
        self.measure.addDirection(dir)
        self.measure.addNote(note1)
        voice = self.measure.getVoice(1)
        self.assertEqual(voice.GetChild(1).GetChild(1).GetItem(), dir)

    def testAddChordNote(self):
        note = 2
        note1 = 3
        self.measure.addNote(note)
        self.measure.addNote(note1, chord=True)
        voice = self.measure.getVoice(1)
        self.assertEqual(voice.GetChild(0).GetChild(0).GetItem(), 3)

    def testAddExpressionThenChordNote(self):
        note = 2
        note1 = 3
        exp = 0
        self.measure.addNote(note)
        self.measure.addExpression(exp)
        self.measure.addNote(note1, chord=True)
        voice = self.measure.getVoice(1)
        self.assertEqual(voice.GetChild(0).GetChild(0).GetItem(), 3)

    def testLilyOutputOfPlaceholders(self):
        self.measure.addPlaceholder()
        voice = self.measure.getVoice(1)
        self.assertEqual(voice.GetChild(0).toLily(), "")

    def testLilyOutputOfPlaceholdersWithChildren(self):
        self.measure.addPlaceholder()
        self.measure.addDirection(1)
        voice = self.measure.getVoice(1)
        self.assertEqual(voice.GetChild(0).toLily(), "")