MIDI Interface API Reference¶
Auto-generated API documentation for the MIDI interface.
MIDIInterface¶
MIDIInterface(port_name='FLStudio_MIDI')
¶
Interface for MIDI communication using mido library.
Initialize MIDI interface.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
port_name
|
str
|
Name of the MIDI port to connect to |
'FLStudio_MIDI'
|
Source code in src/fruityloops_mcp/midi_interface.py
is_connected
property
¶
Check if MIDI ports are connected.
connect()
¶
Connect to MIDI ports.
Returns:
| Type | Description |
|---|---|
bool
|
True if connection successful, False otherwise |
Source code in src/fruityloops_mcp/midi_interface.py
disconnect()
¶
Disconnect from MIDI ports.
Source code in src/fruityloops_mcp/midi_interface.py
send_note_on(note, velocity=64, channel=0)
¶
Send MIDI note on message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
note
|
int
|
MIDI note number (0-127) |
required |
velocity
|
int
|
Note velocity (0-127) |
64
|
channel
|
int
|
MIDI channel (0-15) |
0
|
Returns:
| Type | Description |
|---|---|
bool
|
True if message sent successfully, False otherwise |
Source code in src/fruityloops_mcp/midi_interface.py
send_note_off(note, velocity=64, channel=0)
¶
Send MIDI note off message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
note
|
int
|
MIDI note number (0-127) |
required |
velocity
|
int
|
Note velocity (0-127) |
64
|
channel
|
int
|
MIDI channel (0-15) |
0
|
Returns:
| Type | Description |
|---|---|
bool
|
True if message sent successfully, False otherwise |
Source code in src/fruityloops_mcp/midi_interface.py
send_control_change(control, value, channel=0)
¶
Send MIDI control change message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
control
|
int
|
Control number (0-127) |
required |
value
|
int
|
Control value (0-127) |
required |
channel
|
int
|
MIDI channel (0-15) |
0
|
Returns:
| Type | Description |
|---|---|
bool
|
True if message sent successfully, False otherwise |
Source code in src/fruityloops_mcp/midi_interface.py
send_program_change(program, channel=0)
¶
Send MIDI program change message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
program
|
int
|
Program number (0-127) |
required |
channel
|
int
|
MIDI channel (0-15) |
0
|
Returns:
| Type | Description |
|---|---|
bool
|
True if message sent successfully, False otherwise |
Source code in src/fruityloops_mcp/midi_interface.py
send_pitch_bend(pitch, channel=0)
¶
Send MIDI pitch bend message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pitch
|
int
|
Pitch bend value (-8192 to 8191) |
required |
channel
|
int
|
MIDI channel (0-15) |
0
|
Returns:
| Type | Description |
|---|---|
bool
|
True if message sent successfully, False otherwise |
Source code in src/fruityloops_mcp/midi_interface.py
list_ports()
¶
List available MIDI ports.
Returns:
| Type | Description |
|---|---|
dict[str, list[str]]
|
Dictionary with 'input' and 'output' keys containing lists of port names |
Source code in src/fruityloops_mcp/midi_interface.py
__enter__()
¶
Usage Examples¶
Basic Usage¶
from fruityloops_mcp.midi_interface import MIDIInterface
# Create interface
midi = MIDIInterface(port_name="FLStudio_MIDI")
# Connect
if midi.connect():
# Send a note
midi.send_note_on(60, 100)
# ... wait ...
midi.send_note_off(60)
# Disconnect
midi.disconnect()
Context Manager¶
with MIDIInterface(port_name="FLStudio_MIDI") as midi:
# Automatically connects
midi.send_note_on(60, 100)
# ...
# Automatically disconnects
Checking Connection Status¶
Listing Ports¶
midi = MIDIInterface()
ports = midi.list_ports()
print("Input ports:", ports["input"])
print("Output ports:", ports["output"])
Method Details¶
send_note_on¶
Send a MIDI note on message.
Parameters:
- note (int): MIDI note number (0-127)
- velocity (int): Note velocity (0-127), default=64
- channel (int): MIDI channel (0-15), default=0
Returns:
- bool: True if successful, False otherwise
Example:
send_note_off¶
Send a MIDI note off message.
Parameters:
- note (int): MIDI note number (0-127)
- velocity (int): Release velocity (0-127), default=64
- channel (int): MIDI channel (0-15), default=0
Returns:
- bool: True if successful, False otherwise
send_control_change¶
Send a MIDI control change message.
Parameters:
- control (int): Controller number (0-127)
- value (int): Controller value (0-127)
- channel (int): MIDI channel (0-15), default=0
Returns:
- bool: True if successful, False otherwise
Example:
send_program_change¶
Send a MIDI program change message.
Parameters:
- program (int): Program number (0-127)
- channel (int): MIDI channel (0-15), default=0
Returns:
- bool: True if successful, False otherwise
send_pitch_bend¶
Send a MIDI pitch bend message.
Parameters:
- pitch (int): Pitch bend value (-8192 to 8191)
- channel (int): MIDI channel (0-15), default=0
Returns:
- bool: True if successful, False otherwise
Error Handling¶
Methods return False on error and log warnings/errors. Check return values: