示例#1
0
    def gen_notes(self):

        prev = [0] * keyboard.numkeys # blank piano

        for x in range(16):
            yield clockwork.sleep(self.tickSpeed)
            self.do_metro()

        self.visible = True
        while self.pos < self.whereToStop:
            state = self.score[self.pos]
            for (e, (was, now)) in enumerate(zip(prev, state)):
                i = e + keyboard.leftmost_key
                if now == PRESS:
                    device.send(NoteOff, i, 0)
                    device.send(NoteOn, i, 32)
                elif (now == UNPRESSED) and (was != UNPRESSED):
                    device.send(NoteOff, i, 0)
            prev = state

            yield clockwork.sleep(self.tickSpeed)
            self.do_metro()

            
            self.pos += 1
            
        # now be quiet, even if selection cuts off mid-note:
        for i in range(keyboard.numkeys):
            device.send(NoteOff, i+keyboard.leftmost_key, 0)

        self.visible = False
        self.playing = None
示例#2
0
    def gen_notes(self):

        prev = [0] * keyboard.numkeys  # blank piano

        for x in range(16):
            yield clockwork.sleep(self.tickSpeed)
            self.do_metro()

        self.visible = True
        while self.pos < self.whereToStop:
            state = self.score[self.pos]
            for (e, (was, now)) in enumerate(zip(prev, state)):
                i = e + keyboard.leftmost_key
                if now == PRESS:
                    device.send(NoteOff, i, 0)
                    device.send(NoteOn, i, 32)
                elif (now == UNPRESSED) and (was != UNPRESSED):
                    device.send(NoteOff, i, 0)
            prev = state

            yield clockwork.sleep(self.tickSpeed)
            self.do_metro()

            self.pos += 1

        # now be quiet, even if selection cuts off mid-note:
        for i in range(keyboard.numkeys):
            device.send(NoteOff, i + keyboard.leftmost_key, 0)

        self.visible = False
        self.playing = None
示例#3
0
 def gen_metro(self):
     while True:
         yield clockwork.sleep(self.tickSpeed)
         self.do_metro()
示例#4
0
 def gen_metro(self):
     while True:
         yield clockwork.sleep(self.tickSpeed)
         self.do_metro()