Giter VIP home page Giter VIP logo

micropython-midi-library's Introduction

Micropython-midi-library

A complete MIDI I/O library for Micropython devices

To use, simply download the midi.py file and add it to your project. Availability thorugh pip is on the works.

At the current state this library supports all types of MIDI messages via input or output.

Some usage examples are provided in the /examples folder.

Quick Reference

Initializing a MIDI instance object

MIDI_TX = Pin(8)             # Optocoupled MIDI input in general purpose pin 8 (UART1TX)
MIDI_RX = Pin(9)             # MIDI output in general purpose pin 9 (UART1RX)
UART_1 = 1
my_midi = midi.Midi(UART_1, tx=MIDI_TX, rx=MIDI_RX)

Sending MIDI messages

midi_out_circuit

my_midi.send_note_on(midi.CHANNEL[1], midi.NOTE_CODE["C#4"], velocity=100)
my_midi.send_note_off(midi.CHANNEL[1], midi.NOTE_CODE["C#4"])
my_midi.send_control_change(midi.CHANNEL[1], midi.CONTROL_CHANGE_CODE["MODULATION_WHEEL"], value=80)
# (...Other send methods)

Receiving MIDI messages

midi_in_circuit

while True:
    if my_midi.any() > 0:
        my_midi.load_message(my_midi.read(1))
        if my_midi.last_sequence == midi.MIDI_SEQUENCE["NOTE_ON"]:
            channel = my_midi.channel
            note = my_midi.get_parameter("note_on", "note")
            velocity = my_midi.get_parameter("note_on", "velocity")
            # do something with these parameters

        if my_midi.last_sequence == midi.MIDI_SEQUENCE["NOTE_OFF"]:
            channel = my_midi.channel
            note = my_midi.get_parameter("note_off", "note")
            # do something with this parameter
            
        # (...Other receive blocks)

micropython-midi-library's People

Contributors

sensai7 avatar

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.