Skip to content

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

Notifications You must be signed in to change notification settings

b-viguier/PhpRtMidi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PhpRtMidi

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

Requirements

  • Php >=7.4 (for FFI support)
  • RtMidi v6 library compiled on your system.

Installation

composer require bviguier/php-rtmidi

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

brew install rtmidi

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

Features

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

Usage

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 on your OS or your build. You can also use LIB_RTMIDI_PATH environment variable to provide the path to the library.

This library doesn't match exactly original RtMidi interfaces, but try to expose a straightforward 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()) {
        $output->send($msg);
    }
    usleep(100);
}

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

About

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

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages