MIDIPlayer (MIDIPlayer v0.2.0) View Source
A GenServer for playing a schedule of MIDI commands at predefined times.
Link to this section Summary
Functions
Returns a specification to start this module under a supervisor.
Generate the current schedule defined by the given events.
Get the current schedule of the player.
Pause the player.
Play the current MIDI schedule from the start.
Resume playback on the player after it has been paused.
Set the player on repeat or not.
Start the MIDI player.
Stop the player and cancel the pause.
Link to this section Types
Specs
schedule() :: [{non_neg_integer(), binary()}]
Link to this section Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
Specs
generate_schedule(GenServer.server(), [MIDIPlayer.Event.t()], non_neg_integer()) :: :ok
Generate the current schedule defined by the given events.
The list of events is internally converted to MIDI commands. If multiple events are scheduled on the same time, then they are executed in the same order as in the list. The duration makes sure the player plays a (potential) pause after the last midi command.
See MIDIPlayer.Event
to create events.
Specs
get_schedule(GenServer.server()) :: schedule()
Get the current schedule of the player.
The schedule is a list of tuples of a time in milliseconds and the corresponding bitstream of MIDI commands to be played at that time. The list is guaranteed to be ascending in time.
Specs
pause(GenServer.server()) :: :ok | {:error, :already_paused | :not_started}
Pause the player.
See MIDIPlayer.resume/1
for resuming playback.
Specs
play(GenServer.server()) :: :ok
Play the current MIDI schedule from the start.
Specs
resume(GenServer.server()) :: :ok | {:error, :not_paused}
Resume playback on the player after it has been paused.
Specs
set_repeat(GenServer.server(), boolean()) :: :ok
Set the player on repeat or not.
Specs
start_link(keyword(), GenServer.options()) :: GenServer.on_start()
Start the MIDI player.
Arguments are the same as MIDISynth.start_link/2
.
Specs
stop_playing(GenServer.server()) :: :ok
Stop the player and cancel the pause.