Giter VIP home page Giter VIP logo

neos-vr-midi's Introduction

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}")

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.