views:

16

answers:

1

I'm using Python along with Pygame which uses pyPortMidi for it's midi module, and I'm currently sending NoteOn and NoteOff messages through Midi Yoke to Ableton live, which works great. But I can't seem to figure out how I send CC messages..

Anyone?

The (working) class basically looks like this.

class MidiIO:         
    def __init__(self, device_id = None, inst=0):
        pygame.midi.init()
        pygame.fastevent.init()

        if device_id is None:
            self.output_id = pygame.midi.get_default_output_id()
        else:
            self.output_id = device_id

        self._print_device_info()

        port = self.output_id

        print ("using output_id :%s:" % port)

        self.midi_out = pygame.midi.Output(port, 0)
        self.midi_out.set_instrument(inst)

        self.pressed = False

def midiOut(self, btns, note=60, vel=100):
        if btns == 1:
            if not self.pressed:
                self.midi_out.note_on(note, vel)
                self.pressed = 1

        elif btns == 0:
            self.midi_out.note_off(note)
            self.pressed = 0
+1  A: 

It looks like you would use the write_short method to write raw MIDI packets, or the write method if you want to send several of them at once. So, for example, if you want to send the value 123 on controller 17, that would look like this:

self.midi_out.write_short(0xb0, 17, 123)

The reason you probably didn't notice this in the documentation is that the term "status" is often used in the MIDI protocol to refer to the message type (ie, note on, note off, control change, etc.).

Nik Reiman