libremidi_flutter 0.8.0 copy "libremidi_flutter: ^0.8.0" to clipboard
libremidi_flutter: ^0.8.0 copied to clipboard

Cross-platform MIDI device access for Flutter. Supports macOS, iOS, Android, Windows, and Linux with hotplug detection.

libremidi_flutter #

A Flutter wrapper around libremidi, providing cross-platform MIDI device access.

This is not a full-featured MIDI framework, but a stable and predictable wrapper for common control-oriented workflows.

Supports iOS, Android, macOS, Windows, Linux.

Features #

  • MIDI Input / Output
  • Hotplug detection (device connect/disconnect)
  • Control Change, Program Change, Note On/Off, Pitch Bend, Aftertouch, SysEx
  • Device identification across reconnects
  • Device infos
  • Simple API for sending and receiving messages

Installation #

dependencies:
  libremidi_flutter: ^0.8.0

Usage #

import 'package:libremidi_flutter/libremidi_flutter.dart';

Listing devices #

final inputs = LibremidiFlutter.getInputPorts();
final outputs = LibremidiFlutter.getOutputPorts();

for (final port in inputs) {
  print('${port.displayName} - ${port.manufacturer}');
}

Connecting to a device #

final input = LibremidiFlutter.openInput(inputs[0]);
final output = LibremidiFlutter.openOutput(outputs[0]);

Input options #

By default, SysEx messages are received while MIDI clock and active sensing are filtered out.

// Receive MIDI clock (timing) messages
final input = LibremidiFlutter.openInput(port, receiveTiming: true);

// Disable SysEx reception
final input = LibremidiFlutter.openInput(port, receiveSysex: false);

// Receive active sensing messages
final input = LibremidiFlutter.openInput(port, receiveSensing: true);

Sending Control Change (CC) #

output.sendControlChange(channel: 0, controller: 1, value: 64);

Sending Program Change (PC) #

output.sendProgramChange(channel: 0, program: 10);

// With bank select
output.sendBankSelect(channel: 0, bank: 1, program: 10);

Sending Note On/Off #

output.sendNoteOn(channel: 0, note: 60, velocity: 100);
output.sendNoteOff(channel: 0, note: 60);

Sending SysEx #

// With automatic F0/F7 framing
output.sendSysEx(Uint8List.fromList([0x7E, 0x7F, 0x06, 0x01]));

// Already framed (raw send)
output.send(Uint8List.fromList([0xF0, 0x7E, 0x7F, 0x06, 0x01, 0xF7]));

// Or mark as already framed
output.sendSysEx(Uint8List.fromList([0xF0, 0x7E, 0x7F, 0x06, 0x01, 0xF7]), alreadyFramed: true);

Sending Pitch Bend #

// Value is 14-bit (0-16383), center is 8192
output.sendPitchBend(channel: 0, value: 8192);

Sending Aftertouch #

// Channel aftertouch (pressure)
output.sendAftertouch(channel: 0, pressure: 64);

// Polyphonic aftertouch (per-note)
output.sendPolyAftertouch(channel: 0, note: 60, pressure: 64);

Receiving MIDI messages #

input.messages.listen((msg) {
  // isNoteOn/isNoteOff: msg.note, msg.velocity, msg.channel
  // isControlChange: msg.controller, msg.value, msg.channel
  // isProgramChange: msg.data[1], msg.channel
  // isPitchBend: msg.data[1], msg.data[2], msg.channel
  // isAftertouch: msg.data[1], msg.channel
  // isPolyAftertouch: msg.note, msg.data[2], msg.channel
  // isSysEx: msg.data
  if (msg.isControlChange) {
    print('CC ${msg.controller}=${msg.value} ch:${msg.channel}');
  }
});

Hotplug detection #

LibremidiFlutter.onHotplug.listen((_) {
  // Device connected or disconnected - refresh your device list
  final inputs = LibremidiFlutter.getInputPorts();
  final outputs = LibremidiFlutter.getOutputPorts();
});

Disconnecting #

// Disconnect specific ports
LibremidiFlutter.disconnectInput(input);
LibremidiFlutter.disconnectOutput(output);

// Or disconnect all and cleanup
LibremidiFlutter.dispose();

Port properties #

port.displayName    // Full display name
port.portName       // Port name
port.deviceName     // Device name
port.manufacturer   // Manufacturer
port.transportType  // USB, Bluetooth, Software, etc.
port.stableId       // Stable ID for reconnection

Platform requirements #

Platform Minimum Version
iOS 13.0
Android API 31 (Android 12)
macOS 10.15
Windows 10
Linux ALSA

Notes #

  • Focused on control-oriented workflows
  • BLE MIDI requires native platform integration

License #

BSD-2-Clause. See LICENSE for details.

Based on libremidi by Jean-Michaël Celerier.

0
likes
160
points
95
downloads

Publisher

verified publisherbandapps.de

Weekly Downloads

Cross-platform MIDI device access for Flutter. Supports macOS, iOS, Android, Windows, and Linux with hotplug detection.

Repository (GitHub)
View/report issues

Topics

#midi #audio #music #ffi

Documentation

API reference

License

BSD-2-Clause (license)

Dependencies

ffi, flutter, plugin_platform_interface

More

Packages that depend on libremidi_flutter

Packages that implement libremidi_flutter