Filter :soundfont argument in start_link and pass to MIDISynth

This commit is contained in:
Pim Kunis 2020-10-14 15:05:04 +02:00
parent 2b38e95436
commit 3485525ba0
3 changed files with 10 additions and 7 deletions

View file

@ -55,7 +55,7 @@ Now we are ready to play these events.
First start the player like so:
```elixir
iex> {:ok, player} = MIDIPlayer.start_link([])
iex> {:ok, player} = MIDIPlayer.start_link()
```
Then load the events, and play them!

View file

@ -12,14 +12,18 @@ defmodule MIDIPlayer do
# Client API
@midi_synth_args [:soundfont]
@doc """
Start the MIDI player.
Arguments are the same as `MIDISynth.start_link/2`.
The soundfont path can be set with the :soundfont argument.
"""
@spec start_link(keyword(), GenServer.options()) :: GenServer.on_start()
def start_link(args, opts \\ []) do
GenServer.start_link(__MODULE__, args, opts)
@spec start_link(GenServer.options()) :: GenServer.on_start()
def start_link(opts \\ []) do
init_args = Keyword.take(opts, @midi_synth_args)
server_args = Keyword.drop(opts, @midi_synth_args)
GenServer.start_link(__MODULE__, init_args, server_args)
end
@doc """

View file

@ -10,8 +10,7 @@ defmodule MIDIPlayer.EventTest do
end
test "change program event" do
assert %Event.ChangeProgram{channel: 0, time: 1, program: 40} =
Event.change_program(0, 1, 40)
assert %Event.ChangeProgram{channel: 0, time: 1, program: 40} = Event.change_program(0, 1, 40)
end
test "note event conversion" do