Skip to main content

A package that wraps Pygame midi for simplified use

Project description

Midi Wrapper

This package contains classes that wrap the Pygame Midi class to allow selection of a midi input device, and simple polling of said device with predefined classes to help interpret the signals.

This implementation is limited in that it is only polling for one event per poll instead of multiple events, as such it will pull one at a time.

Polling for multiple events in one frame may be supported in future.

Usage

from pygame import midi
from midi_wrapper import MidiMenu, MidiDevice

# Boiler plate midi initialization for pygame midi
midi.init()

if (midi == None):
	print("Error initializing midi.")
	exit(-1)

# Initialize the menu to start device selection, then pass to device to get reference
midi_menu = MidiMenu(midi)
midi_device = MidiDevice(midi, midi_menu)

# Bog standard polling loop
while True:
	# Returns None if no events received or a MidiData type if an event is found
	midi_data = midi_device.poll_device()

	if midi_data != None:
		midi_event = midi_data.event
		print(f"Clock: {midi_data.clock} :: Name: {midi_event.name} :: Channel: {midi_event.channel} :: Data: {midi_event.data}")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

midi-wrapper-SnooperXP-0.0.5.tar.gz (4.1 kB view hashes)

Uploaded Source

Built Distribution

midi_wrapper_SnooperXP-0.0.5-py3-none-any.whl (5.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page