Recordings by name, for TuningFork.Kit to find.
TuningFork.Sample.Bank.put(:bell, "sounds/bell.flac", root: :a4)
TuningFork.Sample.Bank.put(:sd, ["sd/one.wav", "sd/two.wav"])
Kit.voice("sd:1", 0.25)
Summary
Functions
Returns a specification to start this module under a supervisor.
Forget every registration.
Register to with the same files as from; nothing happens when from is not registered.
How many files name holds; 0 for a name nobody registered.
The sample registered as name, read from disk or fetched if it has not been yet.
Whether name is registered, loaded or not.
Every registered name, sorted.
Which file of a pitched name plays midi, as {index, note}: the file recorded nearest
the note, and the note it was recorded at; n picks among files sharing that note,
wrapping. nil for a name that is not pitched.
The MIDI note each file of a pitched name was recorded at, in file order; nil for a
name that is not pitched or not registered.
Start fetching every file of name still on the web, in the background.
Register name as one file, a list of files, a map of note names to files, or a sample
already loaded.
Register every entry of a map or keyword of names to files.
Types
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec clear() :: :ok
Forget every registration.
Register to with the same files as from; nothing happens when from is not registered.
@spec count(name()) :: non_neg_integer()
How many files name holds; 0 for a name nobody registered.
@spec fetch(name(), integer(), keyword()) :: {:ok, TuningFork.Sample.t()} | :loading | :error
The sample registered as name, read from disk or fetched if it has not been yet.
index picks one of several files, wrapping round; default the first. :error for a name
nobody registered, and for a file that will not read.
Options
:wait— whether to wait for a file still to be fetched from the web, defaulttrue. Withfalsethe fetch is started in the background and the answer is:loadinguntil it is there; a file on disk is read either way
Whether name is registered, loaded or not.
@spec names() :: [String.t()]
Every registered name, sorted.
@spec nearest(name(), number(), integer()) :: {non_neg_integer(), number()} | nil
Which file of a pitched name plays midi, as {index, note}: the file recorded nearest
the note, and the note it was recorded at; n picks among files sharing that note,
wrapping. nil for a name that is not pitched.
The MIDI note each file of a pitched name was recorded at, in file order; nil for a
name that is not pitched or not registered.
@spec prefetch(name()) :: :ok
Start fetching every file of name still on the web, in the background.
@spec put( name(), file() | [file()] | %{required(String.t()) => file() | [file()]}, keyword() ) :: :ok
Register name as one file, a list of files, a map of note names to files, or a sample
already loaded.
A file is a path or an http(s):// URL, which is fetched into the cache on first use, or
{path, opts} with options of its own for TuningFork.Sample.load!/2 (:loop,
:gain, :root). A
list is read by index with fetch/2, wrapping. A map (%{"C3" => "c3.wav", "Fs3" => [...]})
is a pitched instrument: nearest/3 picks the file for a note, and each note may hold a
list; a note is a name or a MIDI number, fractional when the recording lies between two.
Registering a name again with the same files and options keeps what has been
loaded; different files start it afresh.
Options, for files
:root— the pitch the recording is, asTuningFork.Sample.load!/2takes it
@spec put_all(Enumerable.t()) :: :ok
Register every entry of a map or keyword of names to files.