perry-rylance/midi-php

Read, build and write MIDI files, tracks and events in PHP

1.0.1 2025-08-25 10:24 UTC

This package is auto-updated.

Last update: 2025-08-25 10:26:59 UTC


README

A package for reading and writing MIDI files and streams in PHP.

Usage

Reading MIDI data

  • Get your data into a binary string
  • Instantiate a new ReadStream with your binary data
  • Instantiate a new File
  • Call readBytes passing in your ReadStream

Creating MIDI data

  • Instantiate a new File
  • Instantiate a new Track and push it to your files tracks
  • Instantiate any subclasses of Event you need, eg NoteOnEvent
  • Push your events to the tracks events
  • Don't forget EndOfTrackEvent!

Writing MIDI data

  • You'll need a File either read in or created from scratch as described above
  • Instantiate a new WriteStream
  • Call writeBytes on your File passing in your WriteStream
  • Use toBinary on your WriteStream to get the binary data

Development

-dev containers with XDebug are provided and will stay open once started.

Testing

All tests can be run with cross-version-tests.sh.

Tests can be run on specific versions by starting the respective containers.

Credits