Beispiel #1
0
 def test_raw(self):
     m1 = MidiMessage.noteOn(5, 123, 45)
     data = m1.getRawData()
     size = m1.getRawDataSize()
     self.assertEqual(size, len(data))
     m2 = MidiMessage(data)
     self.assertEqual(m1, m2)
     #
     m1 = MidiMessage.controllerEvent(12, 123, 45)
     data = m1.getRawData()
     size = m1.getRawDataSize()
     self.assertEqual(size, len(data))
     m2 = MidiMessage(data)
     self.assertEqual(m1, m2)
Beispiel #2
0
 def test_raw(self):
     m1 = MidiMessage.noteOn(5, 123, 45)
     data = m1.getRawData()
     size = m1.getRawDataSize()
     self.assertEqual(size, len(data))
     m2 = MidiMessage(data)
     self.assertEqual(m1, m2)
     #
     m1 = MidiMessage.controllerEvent(12, 123, 45)
     data = m1.getRawData()
     size = m1.getRawDataSize()
     self.assertEqual(size, len(data))
     m2 = MidiMessage(data)
     self.assertEqual(m1, m2)
Beispiel #3
0
    def updateValue(self):
        if not self.midimessage:
            return
        channel = self.channelBox.currentIndex() + 1
        if self.typeBox.currentText() == util.ANY_TEXT:
            midi = MidiMessage.allNotesOff(0)
        elif self.typeBox.currentIndex() == 0:
            midi = MidiMessage.noteOn(channel,
                                      self.noteNumBox.currentIndex(),
                                      self.noteVelBox.currentIndex()+1)
        elif self.typeBox.currentIndex() == 1:
            midi = MidiMessage.noteOff(channel,
                                       self.noteNumBox.currentIndex())
        elif self.typeBox.currentIndex() == 2:
            midi = MidiMessage.controllerEvent(channel,
                                               self.ccNumBox.currentIndex(),
                                               self.ccValueBox.currentIndex())
        elif self.typeBox.currentIndex() == 3:
            midi = MidiMessage.aftertouchChange(channel,
                                                self.atNumBox.currentIndex(),
                                                self.atValueBox.currentIndex())
        if self.portBox.currentIndex() == -1:
            portName = None
        else:
            portName = self.portBox.currentText()

        if not self.isInitting:
            self.midimessage.setWildcard('channel',
                                         self.channelBox.currentText() in [util.ANY_TEXT, util.ALL_TEXT], emit=False)
            self.midimessage.setWildcard('type',
                                         self.typeBox.currentText() in [util.ANY_TEXT, util.ALL_TEXT], emit=False)
            self.midimessage.setWildcard('noteNum',
                                         self.noteNumBox.currentText() in [util.ANY_TEXT, util.ALL_TEXT], emit=False)
            self.midimessage.setWildcard('noteVel',
                                         self.noteVelBox.currentText() in [util.ANY_TEXT, util.ALL_TEXT], emit=False)
            self.midimessage.setWildcard('ccNum',
                                         self.ccNumBox.currentText() in [util.ANY_TEXT, util.ALL_TEXT], emit=False)
            self.midimessage.setWildcard('ccValue',
                                         self.ccValueBox.currentText() in [util.ANY_TEXT, util.ALL_TEXT], emit=False)
            self.midimessage.setWildcard('atNum',
                                         self.atNumBox.currentText() in [util.ANY_TEXT, util.ALL_TEXT], emit=False)
            self.midimessage.setWildcard('atValue',
                                         self.atValueBox.currentText() in [util.ANY_TEXT, util.ALL_TEXT], emit=False)
        self.midimessage.setMidi(portName, midi)
Beispiel #4
0
def do_SenderProc(iq, oq, portName):
    DEBUG = 0

    def wait_for(x):
        s = iq.get(block=True, timeout=2)
        if s != x:
            print("%s: OH SHIT (wait_for() %s != %s)" % (__name__, s, x))

    device = RtMidiOut()
    if DEBUG:
        print('%s: OPENING %s' % (__name__, portName))
    device.openVirtualPort(portName)

    oq.put('init')  # the port is open

    wait_for('start')
    total = 0
    # note on
    for i in range(128):
        for j in range(1, 128):
            if DEBUG:
                print("%s: Note %i %i" % (__name__, i, j))
            m = MidiMessage.noteOn(1, i, j)
            device.sendMessage(m)
            wait_for('next')
            total += 1
    # controller
    for i in range(128):
        for j in range(128):
            if DEBUG:
                print("%s: CC %i %i" % (__name__, i, j))
            m = MidiMessage.controllerEvent(1, i, j)
            device.sendMessage(m)
            wait_for('next')
            total += 1

    wait_for('done')
    print('%s: sent %i messages' % (__name__, total))
Beispiel #5
0
def do_SenderProc(iq, oq, portName):
    DEBUG = 0

    def wait_for(x):
        s = iq.get(block=True, timeout=2)
        if s != x:
            print("%s: OH SHIT (wait_for() %s != %s)" % (__name__, s, x))

    device = RtMidiOut()
    if DEBUG:
        print('%s: OPENING %s' % (__name__, portName))
    device.openVirtualPort(portName)

    oq.put('init')  # the port is open

    wait_for('start')
    total = 0
    # note on
    for i in range(128):
        for j in range(1, 128):
            if DEBUG:
                print("%s: Note %i %i" % (__name__, i, j))
            m = MidiMessage.noteOn(1, i, j)
            device.sendMessage(m)
            wait_for('next')
            total += 1
    # controller
    for i in range(128):
        for j in range(128):
            if DEBUG:
                print("%s: CC %i %i" % (__name__, i, j))
            m = MidiMessage.controllerEvent(1, i, j)
            device.sendMessage(m)
            wait_for('next')
            total += 1

    wait_for('done')
    print('%s: sent %i messages' % (__name__, total))
Beispiel #6
0
    def test_eq(self):
        self.assertTrue(
            MidiMessage.noteOn(1, 0, 100) == MidiMessage.noteOn(1, 0, 100))
        self.assertFalse(
            MidiMessage.noteOn(1, 1, 100) == MidiMessage.noteOn(1, 0, 100))

        self.assertFalse(
            MidiMessage.pitchWheel(1, 1) == MidiMessage.noteOn(1, 64, 1))

        self.assertTrue(
            MidiMessage.controllerEvent(1, 100, 1) ==
            MidiMessage.controllerEvent(1, 100, 1))
        self.assertTrue(
            MidiMessage.controllerEvent(1, 100, 2) ==
            MidiMessage.controllerEvent(1, 100, 2))
        self.assertTrue(
            MidiMessage.controllerEvent(1, 100, 3) ==
            MidiMessage.controllerEvent(1, 100, 3))

        self.assertFalse(
            MidiMessage.controllerEvent(1, 101, 1) ==
            MidiMessage.controllerEvent(1, 100, 1))
        self.assertFalse(
            MidiMessage.controllerEvent(1, 102, 2) ==
            MidiMessage.controllerEvent(1, 100, 2))
        self.assertFalse(
            MidiMessage.controllerEvent(1, 103, 3) ==
            MidiMessage.controllerEvent(1, 100, 3))
Beispiel #7
0
    def test_eq(self):
        self.assertTrue(MidiMessage.noteOn(1, 0, 100) == MidiMessage.noteOn(1, 0, 100))
        self.assertFalse(MidiMessage.noteOn(1, 1, 100) == MidiMessage.noteOn(1, 0, 100))

        self.assertFalse(MidiMessage.pitchWheel(1, 1) == MidiMessage.noteOn(1, 64, 1))

        self.assertTrue(MidiMessage.controllerEvent(1, 100, 1) ==
                        MidiMessage.controllerEvent(1, 100, 1))
        self.assertTrue(MidiMessage.controllerEvent(1, 100, 2) ==
                        MidiMessage.controllerEvent(1, 100, 2))
        self.assertTrue(MidiMessage.controllerEvent(1, 100, 3) ==
                        MidiMessage.controllerEvent(1, 100, 3))

        self.assertFalse(MidiMessage.controllerEvent(1, 101, 1) ==
                         MidiMessage.controllerEvent(1, 100, 1))
        self.assertFalse(MidiMessage.controllerEvent(1, 102, 2) ==
                         MidiMessage.controllerEvent(1, 100, 2))
        self.assertFalse(MidiMessage.controllerEvent(1, 103, 3) ==
                         MidiMessage.controllerEvent(1, 100, 3))
Beispiel #8
0
 def send_cc_raw(self, channel, cc, v, label=None):
     if label:
         print('[Virtual] send_cc_raw:', label)
     # see: https://github.com/patrickkidd/pyrtmidi/blob/master/rtmidi/randomout.py
     msg = MidiMessage.controllerEvent(channel, cc, v)
     self.device.sendMessage(msg)