diff --git a/lib/midi_tools/event.ex b/lib/midi_tools/event.ex index 47caed5..0a0665a 100644 --- a/lib/midi_tools/event.ex +++ b/lib/midi_tools/event.ex @@ -13,6 +13,14 @@ defmodule MIDITools.Event do end end + defmodule ChangeProgram do + defstruct channel: 0, time: 0, program: 0 + + def new(channel, time, program) do + %__MODULE__{channel: channel, time: time, program: program} + end + end + def convert(%Note{ channel: channel, tone: tone, @@ -24,4 +32,10 @@ defmodule MIDITools.Event do note_off = MIDISynth.Command.note_off(channel, tone) [{start_time, note_on}, {end_time, note_off}] end + + def convert(%ChangeProgram{channel: channel, time: time, program: program}) do + change_program = MIDISynth.Command.change_program(channel, program) + + [{time, change_program}] + end end