https://github.com/geigr/ipymidi
Interactive MIDI in Jupyter
https://github.com/geigr/ipymidi
jupyter midi widgets
Last synced: 10 days ago
JSON representation
Interactive MIDI in Jupyter
- Host: GitHub
- URL: https://github.com/geigr/ipymidi
- Owner: geigr
- License: bsd-3-clause
- Created: 2023-12-12T09:31:43.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-07T18:01:31.000Z (about 2 months ago)
- Last Synced: 2025-04-10T10:51:03.657Z (about 1 month ago)
- Topics: jupyter, midi, widgets
- Language: Python
- Homepage:
- Size: 82 KB
- Stars: 14
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

# IpyMIDI
_Interactive MIDI in Jupyter_
IpyMIDI exposes the Web browsers' [MIDI](https://en.wikipedia.org/wiki/MIDI)
support to Python as [Jupyter widgets](https://ipywidgets.readthedocs.io)
via the [WEBMIDI.js](https://webmidijs.org/) Javascript library. Connect your
MIDI devices (e.g., keyboards, controllers, etc.) and start interacting with
them in Jupyter!**Note: this is very much work in progress (nothing much to see yet)!**
## Usage Example
Create a Jupyter notebook and import the library.
```python
import ipymidi
```Get access to the Web MIDI interface.
```python
midi = ipymidi.get_interface()
```Enable the MIDI interface (your Web browser may ask you the permission to access it).
```python
midi.enable()
```Get the list of all connected MIDI input devices.
```python
midi.inputs
``````
MIDI Inputs (2)
0:
id: 92212230
name: Virtual MIDI
manufacturer: Apple Inc.
connection: open
state: connected
1:
id: -1491552641
name: Arturia KeyStep 37
manufacturer: Arturia
connection: open
state: connected
```Track a specific MIDI event emitted from one input device (e.g., the "noteon"
event emitted from a MIDI keyboard).```python
keyboard = midi.inputs["Arturia KeyStep 37"]
noteon_event = keyboard.add_listener("noteon", ["note_identifier"])
```Use the `noteon_event` object like any other Jupyter widget, e.g., to print in
an output widget the MIDI note that has just been played by the input device.```python
import ipywidgetsoutput = ipywidgets.Output()
@noteon_event.observe
def print_message(change):
output.clear_output()
with output:
print(f"Note {change["owner"].note_identifier} played!")output
```