Change name from tools to player.
This commit is contained in:
parent
2802e5fbf7
commit
e2a7610470
8 changed files with 24 additions and 42 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -20,5 +20,5 @@ erl_crash.dump
|
||||||
*.ez
|
*.ez
|
||||||
|
|
||||||
# Ignore package tarball (built via "mix hex.build").
|
# Ignore package tarball (built via "mix hex.build").
|
||||||
midi_tools-*.tar
|
midi_player-*.tar
|
||||||
|
|
||||||
|
|
|
@ -1,21 +1,21 @@
|
||||||
# MIDITools
|
# MIDIPlayer
|
||||||
|
|
||||||
**TODO: Add description**
|
**TODO: Add description**
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
If [available in Hex](https://hex.pm/docs/publish), the package can be installed
|
If [available in Hex](https://hex.pm/docs/publish), the package can be installed
|
||||||
by adding `midi_tools` to your list of dependencies in `mix.exs`:
|
by adding `midi_player` to your list of dependencies in `mix.exs`:
|
||||||
|
|
||||||
```elixir
|
```elixir
|
||||||
def deps do
|
def deps do
|
||||||
[
|
[
|
||||||
{:midi_tools, "~> 0.1.0"}
|
{:midi_player, "~> 0.1.0"}
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)
|
Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)
|
||||||
and published on [HexDocs](https://hexdocs.pm). Once published, the docs can
|
and published on [HexDocs](https://hexdocs.pm). Once published, the docs can
|
||||||
be found at [https://hexdocs.pm/midi_tools](https://hexdocs.pm/midi_tools).
|
be found at [https://hexdocs.pm/midi_player](https://hexdocs.pm/midi_player).
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
defmodule MIDITools.Player do
|
defmodule MIDIPlayer do
|
||||||
use GenServer
|
use GenServer
|
||||||
|
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
|
@ -24,9 +24,9 @@ defmodule MIDITools.Player do
|
||||||
The duration makes sure the player plays a (potential) pause after the last
|
The duration makes sure the player plays a (potential) pause after the last
|
||||||
midi command.
|
midi command.
|
||||||
|
|
||||||
See `MIDITools.Event` to create events.
|
See `MIDIPlayer.Event` to create events.
|
||||||
"""
|
"""
|
||||||
@spec generate_schedule([MIDITools.Event.t()], non_neg_integer()) :: :ok
|
@spec generate_schedule([MIDIPlayer.Event.t()], non_neg_integer()) :: :ok
|
||||||
def generate_schedule(events, duration) when duration > 0 do
|
def generate_schedule(events, duration) when duration > 0 do
|
||||||
GenServer.call(__MODULE__, {:generate_schedule, events, duration})
|
GenServer.call(__MODULE__, {:generate_schedule, events, duration})
|
||||||
end
|
end
|
||||||
|
@ -56,7 +56,7 @@ defmodule MIDITools.Player do
|
||||||
end
|
end
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
Pause the player. See `MIDITools.Player.resume/0` for resuming playback.
|
Pause the player. See `MIDIPlayer.Player.resume/0` for resuming playback.
|
||||||
"""
|
"""
|
||||||
@spec pause() :: :ok | {:error, :already_paused | :not_started}
|
@spec pause() :: :ok | {:error, :already_paused | :not_started}
|
||||||
def pause do
|
def pause do
|
||||||
|
@ -209,7 +209,7 @@ defmodule MIDITools.Player do
|
||||||
|
|
||||||
defp convert_events(events) do
|
defp convert_events(events) do
|
||||||
events
|
events
|
||||||
|> Enum.flat_map(&MIDITools.Event.convert/1)
|
|> Enum.flat_map(&MIDIPlayer.Event.convert/1)
|
||||||
|> Enum.reduce(%{}, fn {time, midi}, acc ->
|
|> Enum.reduce(%{}, fn {time, midi}, acc ->
|
||||||
Map.update(acc, time, midi, &<<&1::binary, midi::binary>>)
|
Map.update(acc, time, midi, &<<&1::binary, midi::binary>>)
|
||||||
end)
|
end)
|
|
@ -1,4 +1,4 @@
|
||||||
defmodule MIDITools.Event do
|
defmodule MIDIPlayer.Event do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Several musical events which can be converted to MIDI commands.
|
Several musical events which can be converted to MIDI commands.
|
||||||
All timings are in milliseconds.
|
All timings are in milliseconds.
|
|
@ -1,18 +0,0 @@
|
||||||
defmodule MIDITools do
|
|
||||||
@moduledoc """
|
|
||||||
Documentation for `MIDITools`.
|
|
||||||
"""
|
|
||||||
|
|
||||||
@doc """
|
|
||||||
Hello world.
|
|
||||||
|
|
||||||
## Examples
|
|
||||||
|
|
||||||
iex> MIDITools.hello()
|
|
||||||
:world
|
|
||||||
|
|
||||||
"""
|
|
||||||
def hello do
|
|
||||||
:world
|
|
||||||
end
|
|
||||||
end
|
|
12
mix.exs
12
mix.exs
|
@ -1,20 +1,20 @@
|
||||||
defmodule MIDITools.MixProject do
|
defmodule MIDIPlayer.MixProject do
|
||||||
use Mix.Project
|
use Mix.Project
|
||||||
|
|
||||||
def project do
|
def project do
|
||||||
[
|
[
|
||||||
app: :midi_tools,
|
app: :midi_player,
|
||||||
version: "0.1.0",
|
version: "0.1.0",
|
||||||
elixir: "~> 1.10",
|
elixir: "~> 1.10",
|
||||||
start_permanent: Mix.env() == :prod,
|
start_permanent: Mix.env() == :prod,
|
||||||
deps: deps(),
|
deps: deps(),
|
||||||
|
|
||||||
# Docs
|
# Docs
|
||||||
name: "MIDITools",
|
name: "MIDIPlayer",
|
||||||
source_url: "https://github.com/pizzapim/midi_tools",
|
source_url: "https://github.com/pizzapim/midi_player",
|
||||||
homepage_url: "https://github.com/pizzapim/midi_tools",
|
homepage_url: "https://github.com/pizzapim/midi_player",
|
||||||
docs: [
|
docs: [
|
||||||
main: "MIDITools"
|
main: "MIDIPlayer"
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
defmodule MIDITools.EventTest do
|
defmodule MIDIPlayer.EventTest do
|
||||||
use ExUnit.Case
|
use ExUnit.Case
|
||||||
doctest MIDITools.Event
|
doctest MIDIPlayer.Event
|
||||||
|
|
||||||
alias MIDITools.Event
|
alias MIDIPlayer.Event
|
||||||
|
|
||||||
test "note event" do
|
test "note event" do
|
||||||
assert %Event.Note{channel: 0, tone: 60, start_time: 1, end_time: 1000, velocity: 127} =
|
assert %Event.Note{channel: 0, tone: 60, start_time: 1, end_time: 1000, velocity: 127} =
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
defmodule MIDITools.PlayerTest do
|
defmodule MIDIPlayerTest do
|
||||||
use ExUnit.Case
|
use ExUnit.Case
|
||||||
doctest MIDITools.Player
|
doctest MIDIPlayer
|
||||||
|
|
||||||
alias MIDITools.Player
|
alias MIDIPlayer, as: Player
|
||||||
|
|
||||||
setup do
|
setup do
|
||||||
{:ok, _pid} = Player.start_link()
|
{:ok, _pid} = Player.start_link()
|
||||||
|
@ -10,7 +10,7 @@ defmodule MIDITools.PlayerTest do
|
||||||
end
|
end
|
||||||
|
|
||||||
setup_all do
|
setup_all do
|
||||||
events = Enum.map(1..4, &MIDITools.Event.Note.new(9, 51, &1 * 500, (&1 + 1) * 500, 127))
|
events = Enum.map(1..4, &MIDIPlayer.Event.Note.new(9, 51, &1 * 500, (&1 + 1) * 500, 127))
|
||||||
duration = 2000
|
duration = 2000
|
||||||
[events: events, duration: duration]
|
[events: events, duration: duration]
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue