From 25830345efb788f7d4d71be70b2fcd8fc6d4175e Mon Sep 17 00:00:00 2001 From: Pim Kunis Date: Sun, 11 Oct 2020 12:27:49 +0200 Subject: [PATCH] Add change program event. --- lib/midi_tools/event.ex | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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