Realtime MIDI input/output, thanks to RtMidi and FFI.

dev-main 2022-01-19 13:37 UTC

This package is auto-updated.

Last update: 2023-09-19 17:24:17 UTC


Php library for realtime MIDI input/output, thanks to RtMidi and FFI.


  • Php 7.4 (for FFI support)
  • RtMidi v4 library compiled on your system.


composer require bviguier/php-rtmidi

On MacOS, you can install RtMidi globally thanks to brew.

brew install rtmidi

⚠️ In Linux, package registries often provide which is the version 3! To compile it manualy:


  • Send midi messages (including system exclusive)
  • Receive midi messages (including system exclusive)
  • Create virtual input or output


If the RtMidi is not globally available on your system, you have to provide its path. By default, PhpRtMidi try to load the library by its standard name, but the name may depend of your OS or your build.

This library doesn't match exactly original RtMidi interfaces, but try to expose a straigthforward developer experience.

$browser = new \bviguier\RtMidi\MidiBrowser();

$input = $browser->openInput('My Input');
$output = $browser->openOutput('My Output');

echo "Midi thru enabled, use Ctr-C to exit…\n";
while (true) {
    if ($msg = $input->pullMessage()) {

Check examples directory to have a better overview of its usage.