Exemplo n.º 1
0
    def test(self):
        from alsamidi import modifyevent

        data = (1, 60, 127, 0, 10)
        event = (5, 1, 0, 0, (1, 0), (0, 0), (0, 0), data)
        modified_data = (15, 72, 127, 0, 10)
        modified_event = (5, 1, 0, 250, (2, 0), (2, 0), (3, 0), modified_data)
        self.assertEqual(modified_event, modifyevent(event, timedelta=1,
                ch=15, dest=(3, 0), source=(2, 0), queue=250, keydelta=12))
Exemplo n.º 2
0
def retrieveinput():
    "Retrieve received events."
    global incoming, waitingforsplit, split
    p = select.poll()
    p.register(fd, select.POLLIN)
    while vivo:
        p.poll(5000)
        while alsaseq.inputpending():
            entrante = alsaseq.input()
            nota = entrante[7][1]
            type = entrante[0]
            if type in rechazados:
                continue  # discard obnoxious Clavinova events
            elif type == alsaseq.SND_SEQ_EVENT_ECHO:
                drums(ritmos[nritmo], tempo, compases)
                continue
            ev = alsamidi.modifyevent(entrante, ch=1)
            if waitingforsplit:
                split = nota
                waitingforsplit = 0
                print(nota)
                continue  # discard note
            if not split:
                alsaseq.output(entrante)
                alsaseq.output(ev)
                incoming.append(ev)
                incoming.append(entrante)
            elif nota > split:
                alsaseq.output(entrante)
                incoming.append(entrante)
            else:
                alsaseq.output(ev)
                incoming.append(ev)
            print(len(incoming), "incoming")

    print("Ending retrieveinput()")
Exemplo n.º 3
0
def retrieveinput():
    'Retrieve received events.'
    global incoming, waitingforsplit, split
    p = select.poll()
    p.register(fd, select.POLLIN)
    while vivo:
        p.poll(5000)
        while alsaseq.inputpending():
            entrante = alsaseq.input()
            nota = entrante[7][1]
            type = entrante[0]
            if type in rechazados:
                continue  # discard obnoxious Clavinova events
            elif type == alsaseq.SND_SEQ_EVENT_ECHO:
                drums(ritmos[nritmo], tempo, compases)
                continue
            ev = alsamidi.modifyevent(entrante, ch=1)
            if waitingforsplit:
                split = nota
                waitingforsplit = 0
                print(nota)
                continue  # discard note
            if not split:
                alsaseq.output(entrante)
                alsaseq.output(ev)
                incoming.append(ev)
                incoming.append(entrante)
            elif nota > split:
                alsaseq.output(entrante)
                incoming.append(entrante)
            else:
                alsaseq.output(ev)
                incoming.append(ev)
            print(len(incoming), 'incoming')

    print('Ending retrieveinput()')