Change name from tools to player.

This commit is contained in:
Pim Kunis 2020-10-12 16:17:36 +02:00
parent 2802e5fbf7
commit e2a7610470
8 changed files with 24 additions and 42 deletions

2
.gitignore vendored
View file

@ -20,5 +20,5 @@ erl_crash.dump
*.ez
# Ignore package tarball (built via "mix hex.build").
midi_tools-*.tar
midi_player-*.tar

View file

@ -1,21 +1,21 @@
# MIDITools
# MIDIPlayer
**TODO: Add description**
## Installation
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
def deps do
[
{:midi_tools, "~> 0.1.0"}
{:midi_player, "~> 0.1.0"}
]
end
```
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
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).

View file

@ -1,4 +1,4 @@
defmodule MIDITools.Player do
defmodule MIDIPlayer do
use GenServer
@moduledoc """
@ -24,9 +24,9 @@ defmodule MIDITools.Player do
The duration makes sure the player plays a (potential) pause after the last
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
GenServer.call(__MODULE__, {:generate_schedule, events, duration})
end
@ -56,7 +56,7 @@ defmodule MIDITools.Player do
end
@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}
def pause do
@ -209,7 +209,7 @@ defmodule MIDITools.Player do
defp convert_events(events) do
events
|> Enum.flat_map(&MIDITools.Event.convert/1)
|> Enum.flat_map(&MIDIPlayer.Event.convert/1)
|> Enum.reduce(%{}, fn {time, midi}, acc ->
Map.update(acc, time, midi, &<<&1::binary, midi::binary>>)
end)

View file

@ -1,4 +1,4 @@
defmodule MIDITools.Event do
defmodule MIDIPlayer.Event do
@moduledoc """
Several musical events which can be converted to MIDI commands.
All timings are in milliseconds.

View file

@ -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
View file

@ -1,20 +1,20 @@
defmodule MIDITools.MixProject do
defmodule MIDIPlayer.MixProject do
use Mix.Project
def project do
[
app: :midi_tools,
app: :midi_player,
version: "0.1.0",
elixir: "~> 1.10",
start_permanent: Mix.env() == :prod,
deps: deps(),
# Docs
name: "MIDITools",
source_url: "https://github.com/pizzapim/midi_tools",
homepage_url: "https://github.com/pizzapim/midi_tools",
name: "MIDIPlayer",
source_url: "https://github.com/pizzapim/midi_player",
homepage_url: "https://github.com/pizzapim/midi_player",
docs: [
main: "MIDITools"
main: "MIDIPlayer"
]
]
end

View file

@ -1,8 +1,8 @@
defmodule MIDITools.EventTest do
defmodule MIDIPlayer.EventTest do
use ExUnit.Case
doctest MIDITools.Event
doctest MIDIPlayer.Event
alias MIDITools.Event
alias MIDIPlayer.Event
test "note event" do
assert %Event.Note{channel: 0, tone: 60, start_time: 1, end_time: 1000, velocity: 127} =

View file

@ -1,8 +1,8 @@
defmodule MIDITools.PlayerTest do
defmodule MIDIPlayerTest do
use ExUnit.Case
doctest MIDITools.Player
doctest MIDIPlayer
alias MIDITools.Player
alias MIDIPlayer, as: Player
setup do
{:ok, _pid} = Player.start_link()
@ -10,7 +10,7 @@ defmodule MIDITools.PlayerTest do
end
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
[events: events, duration: duration]
end