Example #1
0
 def test_parser(self):
     parser = M.parse.MusicXMLParser()
     for name in SHEETS:
         sheet = parser.parse(get_path('sheets', name))
         attach_tab(sheet)
         layout = LinearTabLayout(sheet)
         layout.layout()
Example #2
0
 def test_parser(self):
     parser = M.parse.MusicXMLParser()
     for name in SHEETS:
         sheet = parser.parse(get_path('sheets', name))
         attach_tab(sheet)
         layout = LinearTabLayout(sheet)
         layout.layout()
Example #3
0
    def test_viewer(self):
        parser = M.parse.MusicXMLParser()
        i = 0

        def quit():
            nonlocal _quit
            _quit = True
            window.close()

        def change_page(delta):
            if delta > 0:
                viewer.layout.next_page()
            elif delta < 0:
                viewer.layout.prev_page()
            viewer.canvas.update_sheet_layout()

        _quit = False
        player = Player()
        for name in SHEETS[:]:
            print('sheet #{}'.format(i))
            i += 1
            viewer = M.viewer.SheetViewer()
            window = ui.Window(width=1000, height=800, resizable=1)
            window.root.children.append(viewer)
            window.add_shortcut(K.chain(K.Q), quit)
            # window.add_shortcut(K.chain(K.RIGHT), change_page, 1)
            # window.add_shortcut(K.chain(K.LEFT), change_page, -1)
            window.add_shortcut(K.chain(K.SHIFT, K.P),
                                lambda: player.pause() or True)
            window.add_shortcut(K.chain(K.P), lambda: player.play() or True)

            sheet = parser.parse(get_path('sheets', name))
            attach_tab(sheet)
            attach_fingerings(sheet)
            import random
            for measure in sheet.iter_measures():
                for note in measure.iter_pitched_notes():
                    note.fingering.finger = random.randint(0, 4)
                    note.fingering.string = random.randint(1, 6)
                    note.fingering.fret = random.randint(0, 15)
            # layout = PagesLayout(sheet)
            layout = LinearLayout(sheet)
            # layout = LinearTabLayout(sheet)
            layout.layout()
            viewer.set_sheet_layout(layout)
            # change_page(0)
            player.set_sheet(sheet)
            viewer.set_player(player)
            player.play()

            pyglet.clock.schedule_interval(viewer.update, 1 / 30)

            window.start()
            player.stop()
            sheet.free()
            if _quit:
                break
Example #4
0
    def test_viewer(self):
        parser = M.parse.MusicXMLParser()
        i = 0
        def quit():
            nonlocal _quit
            _quit = True
            window.close()
        def change_page(delta):
            if delta > 0:
                viewer.layout.next_page()
            elif delta < 0:
                viewer.layout.prev_page()
            viewer.canvas.update_sheet_layout()
        _quit = False
        player = Player()
        for name in SHEETS[:]:
            print('sheet #{}'.format(i))
            i += 1
            viewer = M.viewer.SheetViewer()
            window = ui.Window(width=1000, height=800, resizable=1)
            window.root.children.append(viewer)
            window.add_shortcut(K.chain(K.Q), quit)
            # window.add_shortcut(K.chain(K.RIGHT), change_page, 1)
            # window.add_shortcut(K.chain(K.LEFT), change_page, -1)
            window.add_shortcut(K.chain(K.SHIFT, K.P), lambda: player.pause() or True)
            window.add_shortcut(K.chain(K.P), lambda: player.play() or True)

            sheet = parser.parse(get_path('sheets', name))
            attach_tab(sheet)
            attach_fingerings(sheet)
            import random
            for measure in sheet.iter_measures():
                for note in measure.iter_pitched_notes():
                    note.fingering.finger = random.randint(0, 4)
                    note.fingering.string = random.randint(1, 6)
                    note.fingering.fret = random.randint(0, 15)
            # layout = PagesLayout(sheet)
            layout = LinearLayout(sheet)
            # layout = LinearTabLayout(sheet)
            layout.layout()
            viewer.set_sheet_layout(layout)
            # change_page(0)
            player.set_sheet(sheet)
            viewer.set_player(player)
            player.play()

            pyglet.clock.schedule_interval(viewer.update, 1 / 30)

            window.start()
            player.stop()
            sheet.free()
            if _quit:
                break