spietras / beeplay

turn your crappy PC into a music player :notes:
MIT No Attribution
3 stars 0 forks source link
beep music shell

beeplay

turn your crappy PC into a music player 🎶

Features

keyplay

You can play notes with your keyboard using keyplay:

./keyplay

Keyboard layout is similar to the one used in FL Studio. By default the play command from sox is used to play notes. See ./keyplay --help for more info.

midiplay

You can play notes from MIDI files:

./midiplay -f file.mid

And also from MIDI devices (like USB Keyboard on port 1):

./midiplay -p 1

Only one track and one channel can be played, by default it's track 0 and channel 1. Also by default the play command from sox is used to play notes. See ./midiplay --help for more info.

Usage as library

Just copy beeplaylib.sh to your project, source it and use the beeplay function to play music.

beeplay reads commands from stdin and starts or stops notes. Available commands are:

You can play multiple different notes at the same time, but you can't play multiple notes of the same frequency.

Because of variety of sound configurations, by default it uses the terminal bell to play notes. However, you can pass your own note-playing function that takes note frequency in Hz. Your function will be repeatedly called, unless something blocks inside it. Some functions are provided by the library.

You should pipe event stream to beeplay. For this purpose, you can use bundled emitter functions, which emit events to stdout. For example emit_midifile emits events from a MIDI file.

Example with default terminal bell:

. beeplaylib.sh

emit_midifile < file.mid | beeplay

Example with custom function:

. beeplaylib.sh

note_beep()
{
    beep -f "$1" -l 999999
}

emit_midifile < file.mid | beeplay note_beep