Add change program event.

This commit is contained in:
Pim Kunis 2020-10-11 12:27:49 +02:00
parent 3947d6fa2a
commit 25830345ef

View file

@ -13,6 +13,14 @@ defmodule MIDITools.Event do
end end
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{ def convert(%Note{
channel: channel, channel: channel,
tone: tone, tone: tone,
@ -24,4 +32,10 @@ defmodule MIDITools.Event do
note_off = MIDISynth.Command.note_off(channel, tone) note_off = MIDISynth.Command.note_off(channel, tone)
[{start_time, note_on}, {end_time, note_off}] [{start_time, note_on}, {end_time, note_off}]
end end
def convert(%ChangeProgram{channel: channel, time: time, program: program}) do
change_program = MIDISynth.Command.change_program(channel, program)
[{time, change_program}]
end
end end