Pygame.midi: How to detect simultaneous inputs from a synthesizer?

  pygame, python

I’m using a synthesizer, to detect input of notes with pygame.midi

import pygame.midi

def readInput(input_device):

    while True:
        if input_device.poll():
            event = input_device.read(1)[0]
            data = event[0]
            timestamp = event[1]
            note_number = data[1]
            velocity = data[2]
            print(data[2])

            if data[1] == 36 and 40 and 43 and 46: #not working
                 print("chord = Cmaj7")
            else:
                 print(data[2])

if __name__ == '__main__':
    pygame.midi.init()
    my_input = pygame.midi.Input(1)
    readInput(my_input)

notes are working, but how i can detect the simultaneous inputs 36 + 40 + 43+ 46, knowing the input 36=c, 40=e and 43=g anyway to do this ?

Source: Python Questions

LEAVE A COMMENT