| Crates.io | e_midi |
| lib.rs | e_midi |
| version | 0.1.11 |
| created_at | 2025-06-20 01:52:00.091465+00 |
| updated_at | 2025-07-10 02:49:48.946658+00 |
| description | An interactive/CLI/library MIDI player with advanced playback options, looping, and scan modes. |
| homepage | https://github.com/davehorner/e_midi/ |
| repository | https://github.com/davehorner/e_midi/ |
| max_upload_size | |
| id | 1719036 |
| size | 455,234 |
e_midi is more than a simple midi player. It currently supports .mid and .xml files. MusicXML support is very alpha and if you're interested, PRs are welcome!
now includes .ogg and .mp3 embedding/playing via rodio. mp4/webm embed but do not play yet.
Sequential Scan: Play segments from each song in order
Random Start Scan: Begin each song segment at a random position
Progressive Scan: Gradually increase segment duration for deeper exploration
Configurable Duration: Set custom scan segment lengths (default: 30 seconds)
Additional Binary:
- e_midi_demo01: Windows-only demo for window focus, resize, and move event integration with e_grid IPC. Useful for testing advanced window event handling and IPC features. Source:
examples/demo_focus_resize_move.rs.To run:
cargo run --bin e_midi_demo01or after building:
target\release\e_midi_demo01.exe
Running after install:
After installing with:
cargo install e_midiyou can run the main player binary directly as
e_midifrom your terminal or command prompt.e_midi_demo01is also installed and should be available for your use.Note: The default
e_midibinary/lib includes the curated MIDI sound effects from themidifolder within the repository, embedded at build time. These static songs are always available, even if you run the binary outside the repository directory.
A feature-rich, interactive MIDI player written in Rust with advanced playback options, looping capabilities, and scan modes.
- e_midi_demo02: Persistent IPC event listener demo. Launches e_midi to play song 0 with IPC enabled, then displays all incoming MIDI note events in real time. Remains running and will display events from any e_midi instance with IPC enabled. Useful for debugging and monitoring event flow. Source:
examples/e_midi_demo02.rs.
- e_midi_ipc_player: Designed to be controlled entirely via inter-process communication. Tt listens for IPC midi events and plays the notes with a changing random voice. run
e_midi_demo02, then start as manye_midi_ipc_playeras you desire; they will all play the same song.
git clone https://github.com/davehorner/e_midi.git
cd e_midi
cargo build --release
cargo run
The application starts with an interactive configuration menu:
The player maintains a unified song index where:
midi/) appear first (indexes 0-N)When playing songs, you can:
🎵 MIDI Player Settings
═══════════════════════
🔄 Loop the entire playlist? (y/N): y
🔄 Loop individual songs? (y/N): n
⏱️ Delay between songs in seconds (default 2, 0 for no delay): 5
🎵 Choose an option:
1: Play a specific song
2: Play all songs
3: Play random song
4: Scan mode (play portions of songs)
Select option (1-4): 4
🔍 Scan Mode Options:
1: Sequential scan (play segments in order)
2: Random start scan (random positions)
3: Progressive scan (increasing duration)
Select scan type (1-3): 3
e_midi provides both interactive and command-line modes. The CLI allows for scripting, automation, and integration with other tools.
Important: Global options must come before the subcommand (e.g., e_midi --delay-between-songs 5 play-random), while subcommand-specific options come after the subcommand (e.g., e_midi scan --mode 2 --duration 45).
An interactive/CLI/library MIDI player with advanced playback options, looping, and scan modes.
Usage: e_midi.exe [OPTIONS] [COMMAND]
Commands:
list List all available songs
play Play a specific song
play-all Play all songs in sequence
play-random Play songs in random order
scan Scan mode - play portions of songs
list-dynamic List only dynamically loaded songs
clear-dynamic Clear all dynamically loaded songs
interactive Run in interactive mode (default)
help Print this message or the help of the given subcommand(s)
Options:
--loop-playlist
Loop the entire playlist continuously
--loop-individual-songs
Loop individual songs
--delay-between-songs <DELAY_BETWEEN_SONGS>
Delay between songs in seconds [default: 0]
--scan-duration <SCAN_DURATION>
Scan segment duration in seconds [default: 30]
--scan-random-start
Start scan segments at random positions
-t, --tui
Use TUI mode with split panels (menu + playback info)
--add-song <ADD_SONGS>
Add MIDI files to the dynamic playlist
--scan-directory <SCAN_DIRECTORIES>
Scan directories and add all MIDI files to the dynamic playlist
-h, --help
Print help
-V, --version
Print version
# List available songs
e_midi list
# Play song at index 5
e_midi play 5
# Play song 3 with custom tempo
e_midi play 3 --tempo 140
# Play specific tracks (1, 3, 5) from song 2
e_midi play 2 --tracks 1,3,5
# Play all songs in sequence
e_midi play-all
# Play songs in random order
e_midi play-random
# Loop the entire playlist
e_midi --loop-playlist play-all
# Loop individual songs with 5-second delays
e_midi --loop-individual-songs --delay-between-songs 5 play-all
# Play song 0 on loop
e_midi --loop-individual-songs play 0
# Sequential scan with default 30-second segments
e_midi scan
# Random position scan with 45-second segments
e_midi scan --mode 2 --duration 45
# Progressive scan (increasing duration)
e_midi scan --mode 3
# Scan with random start positions
e_midi --scan-random-start scan
# Add individual MIDI files
e_midi --add-song song1.mid --add-song song2.mid list
# Scan directory for MIDI files
e_midi --scan-directory /path/to/midi/files list
# List only dynamically loaded songs
e_midi list-dynamic
# Clear all dynamic songs
e_midi clear-dynamic
# Launch with Terminal User Interface
e_midi --tui
# TUI with pre-loaded dynamic songs
e_midi --tui --scan-directory /path/to/midi/files
play CommandPlay a specific song
Usage: e_midi.exe play [OPTIONS] <SONG_INDEX>
Arguments:
<SONG_INDEX> Song index to play
Options:
--tracks <TRACKS> Track numbers to play (comma-separated)
--tempo <TEMPO> Tempo in BPM
-h, --help Print help
scan CommandScan mode - play portions of songs
Usage: e_midi.exe scan [OPTIONS]
Options:
--mode <MODE> Scan mode: 1=sequential, 2=random positions, 3=progressive [default: 1]
--duration <DURATION> Duration of each scan segment in seconds
-h, --help Print help
# Play all songs with logging and 1-second delays
e_midi --delay-between-songs 1 play-all > playback.log 2>&1
# Scan all songs for 10 seconds each
e_midi --scan-duration 10 scan --mode 1
#!/bin/bash
# Play random songs for background music with 2-second delays
while true; do
e_midi --delay-between-songs 2 play-random
sleep 5
done
The e_midi player uses a hybrid approach for managing MIDI content:
.mid, .xml, .musicxml) in the midi/ directory are processed at compile time by build.rsThe player seamlessly handles both types, with static songs providing guaranteed availability and performance, while dynamic songs offer flexibility for expanding the music library.
e_midi includes built-in IPC capabilities using the iceoryx2 framework for lock-free, zero-copy communication:
The IPC system enables e_midi to function as both a standalone player and a component in larger musical ecosystems.
The application processes MIDI files at build time using build.rs. Place your MIDI files in the project directory and they will be automatically processed and embedded.
midir: MIDI I/O operationsmidly: MIDI file parsingrimd: Additional MIDI utilitiesansi_term: Terminal color outputiceoryx2: Lock-free inter-process communicationratatui: Terminal user interface frameworkcrossterm: Cross-platform terminal manipulationEnsure you have a MIDI output device available:
If you encounter build errors:
cargo updatecargo clean && cargo buildThis project is licensed under the MIT License - see the LICENSE file for details.
The midi folder contains a curated set of short, expressive MIDI sound effects (e.g., success, error, alert, coin, powerup) created by David Horner with the assistance of ChatGPT. All files listed in README.MIDI.md are released into the public domain under CC0 1.0 Universal. You may use, modify, and distribute these files freely, even for commercial purposes, without attribution.
The midi folder supports both MIDI (.mid) and MusicXML (.xml, .musicxml) files for static, compiled-in songs.
For details and a full index of available sounds, see README.MIDI.md.
tidalcycles-rs for pattern-based MIDI sequencing and experimental live coding support. This enables advanced rhythmic and melodic pattern playback alongside standard MIDI features.e_midi_demo02 and e_midi_ipc_player binaries for IPC event monitoring and playback