2020-10-12 14:17:36 +00:00
|
|
|
defmodule MIDIPlayer.EventTest do
|
2020-10-11 16:15:16 +00:00
|
|
|
use ExUnit.Case
|
2020-10-12 14:17:36 +00:00
|
|
|
doctest MIDIPlayer.Event
|
2020-10-11 16:15:16 +00:00
|
|
|
|
2020-10-12 14:17:36 +00:00
|
|
|
alias MIDIPlayer.Event
|
2020-10-11 16:15:16 +00:00
|
|
|
|
|
|
|
test "note event" do
|
|
|
|
assert %Event.Note{channel: 0, tone: 60, start_time: 1, end_time: 1000, velocity: 127} =
|
2020-10-14 11:01:21 +00:00
|
|
|
Event.note(0, 60, 1, 1000, 127)
|
2020-10-11 16:15:16 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
test "change program event" do
|
2020-10-14 13:05:04 +00:00
|
|
|
assert %Event.ChangeProgram{channel: 0, time: 1, program: 40} = Event.change_program(0, 1, 40)
|
2020-10-11 16:15:16 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
test "note event conversion" do
|
2020-10-14 11:01:21 +00:00
|
|
|
note = Event.note(0, 60, 1, 1000, 127)
|
2020-10-11 16:15:16 +00:00
|
|
|
[note_on, note_off] = Event.convert(note)
|
|
|
|
assert {1, <<0x90, 60, 127>>} = note_on
|
|
|
|
assert {1000, <<0x80, 60, 64>>} = note_off
|
|
|
|
end
|
|
|
|
|
|
|
|
test "change program event conversion" do
|
2020-10-14 11:01:21 +00:00
|
|
|
change_program = Event.change_program(0, 1, 40)
|
2020-10-11 16:15:16 +00:00
|
|
|
assert [{1, <<0xC0, 40>>}] = Event.convert(change_program)
|
|
|
|
end
|
|
|
|
end
|