title: Pygame read MIDI input
body: <p>I referenced the <a href="https://www.pygame.org/docs/ref/midi.html" rel="nofollow noreferrer">Pygame MIDI documentation</a> and <a href="https://stackoverflow.com/questions/62983509/pygame-midi-read-pc-program-change-messages">this code</a> to try to get MIDI input to work.
  The MIDI Interface (Avid Eleven Rack) receives MIDI data from my MIDI controller just fine in my audio software (Pro Tools). Using Pygame, however, I can not seem to read any information at all.</p>
  <h2>Source Code</h2>
  <pre><code>import pygame
  from pygame.locals import *
  from pygame import midi
  
  class MidiInput():
      def __init__(self):
          # variables
          self.elevenRackInID = 2
  
          # init methods
          pygame.init()
          pygame.midi.init()
          self.midiInput = pygame.midi.Input(self.elevenRackInID, 100)
  
      def run(self):
          # print(pygame.midi.Input(3, 100))
          # for i in range(10):
              # print(pygame.midi.get_device_info(i), i)
          self.read = self.midiInput.read(100)
          # self.convert = pygame.midi.midis2events(self.read, self.elevenRackInID)
          print(self.read)
  
  test = MidiInput()
  while True:
     test.run()
  
  </code></pre>
  <p>The only thing printed to the console are empty square brackets:</p>
  <pre><code>[]
  </code></pre>
  <h2>Additional Info</h2>
  <p>I just checked again: the input ID is the right one and it is in fact an input.</p>
  <p>&quot;self.midiInput.poll()&quot; returns False. So according to the Pygame documentation there is no data coming in.</p>
  <p>You can see the data, poll and device info below:</p>
  <pre><code>data: [] || poll: False || device info: (b'MMSystem', b'Eleven Rack', 1, 0, 1)
  
  </code></pre>
  <p>A list of all my MIDI devices according to Pygame (with indexes):</p>
  <pre><code>(b'MMSystem', b'Microsoft MIDI Mapper', 0, 1, 0) 0
  (b'MMSystem', b'External', 1, 0, 0) 1
  (b'MMSystem', b'Eleven Rack', 1, 0, 1) 2
  (b'MMSystem', b'Maschine Mikro MK2 In', 1, 0, 0) 3
  (b'MMSystem', b'Microsoft GS Wavetable Synth', 0, 1, 0) 4
  (b'MMSystem', b'External', 0, 1, 0) 5
  (b'MMSystem', b'Eleven Rack', 0, 1, 0) 6
  (b'MMSystem', b'Maschine Mikro MK2 Out', 0, 1, 0) 7
  </code></pre>
  <p>Any help or suggestions are greatly appreciated!</p>