perry-rylance / midi-php
Read, build and write MIDI files, tracks and events in PHP
Installs: 1
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/perry-rylance/midi-php
Requires
- php: >=8.2.0
- aeviiq/collection: ^4.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.84
- illuminate/support: ^12.20
- pestphp/pest: ^3.8
- phpstan/phpstan: ^2.1
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 ReadStreamwith your binary data - Instantiate a
new File - Call
readBytespassing in yourReadStream
Creating MIDI data
- Instantiate a
new File - Instantiate a
new Trackand push it to your filestracks - Instantiate any subclasses of
Eventyou need, egNoteOnEvent - Push your events to the tracks
events - Don't forget
EndOfTrackEvent!
Writing MIDI data
- You'll need a
Fileeither read in or created from scratch as described above - Instantiate a
new WriteStream - Call
writeByteson yourFilepassing in yourWriteStream - Use
toBinaryon yourWriteStreamto 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
- With thanks to Recording Blogs, Teragon Audio and Mido for insight into the MIDI spec.
- With thanks to jazz-soft for the test files.
- With thanks to Jeff Boudier for MIDIopsy