Filter :soundfont argument in start_link and pass to MIDISynth
This commit is contained in:
parent
2b38e95436
commit
3485525ba0
3 changed files with 10 additions and 7 deletions
|
@ -55,7 +55,7 @@ Now we are ready to play these events.
|
||||||
First start the player like so:
|
First start the player like so:
|
||||||
|
|
||||||
```elixir
|
```elixir
|
||||||
iex> {:ok, player} = MIDIPlayer.start_link([])
|
iex> {:ok, player} = MIDIPlayer.start_link()
|
||||||
```
|
```
|
||||||
|
|
||||||
Then load the events, and play them!
|
Then load the events, and play them!
|
||||||
|
|
|
@ -12,14 +12,18 @@ defmodule MIDIPlayer do
|
||||||
|
|
||||||
# Client API
|
# Client API
|
||||||
|
|
||||||
|
@midi_synth_args [:soundfont]
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
Start the MIDI player.
|
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()
|
@spec start_link(GenServer.options()) :: GenServer.on_start()
|
||||||
def start_link(args, opts \\ []) do
|
def start_link(opts \\ []) do
|
||||||
GenServer.start_link(__MODULE__, args, opts)
|
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
|
end
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
|
|
@ -10,8 +10,7 @@ defmodule MIDIPlayer.EventTest do
|
||||||
end
|
end
|
||||||
|
|
||||||
test "change program event" do
|
test "change program event" do
|
||||||
assert %Event.ChangeProgram{channel: 0, time: 1, program: 40} =
|
assert %Event.ChangeProgram{channel: 0, time: 1, program: 40} = Event.change_program(0, 1, 40)
|
||||||
Event.change_program(0, 1, 40)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
test "note event conversion" do
|
test "note event conversion" do
|
||||||
|
|
Loading…
Reference in a new issue