PortMidi v5.1.0 PortMidi
The entry module of portmidi. Through this module you can open and close devices, listen on input devices, or write to output devices.
Summary
Functions
Terminates the GenServer held by the device
argument, and closes the
PortMidi stream. If the type is an input, and listen/2
was called on it,
it also shuts down the listening process. Using the given device
after
calling this method will raise an error
Returns a map with input and output devices, in the form of
PortMidi.Device
structs
Starts a listening process on the given input
, and returns :ok
. After
calling this method, the process with the given pid
will receive MIDI
events in its mailbox as soon as they are emitted from the device
Opens a connection to the input device with name device_name
Opens a connection to the output device with name device_name
Starts the :portmidi
application. Under the hood, starts the
Portmidi.Listeners
GenServer, that holds all the listeners to
input devices
Writes a MIDI event to the given output
device. message
can be a tuple
{status, note, velocity}
, a tuple {{status, note, velocity}, timestamp}
or a list [{{status, note, velocity}, timestamp}, ...]
. Returns :ok
on write
Types
Functions
Specs
close(atom, pid) :: :ok
Terminates the GenServer held by the device
argument, and closes the
PortMidi stream. If the type is an input, and listen/2
was called on it,
it also shuts down the listening process. Using the given device
after
calling this method will raise an error.
Specs
devices :: %{input: [%PortMidi.Device{input: term, interf: term, name: term, opened: term, output: term}, ...], output: [%PortMidi.Device{input: term, interf: term, name: term, opened: term, output: term}, ...]}
Returns a map with input and output devices, in the form of
PortMidi.Device
structs
Specs
listen(pid, pid) :: :ok
Starts a listening process on the given input
, and returns :ok
. After
calling this method, the process with the given pid
will receive MIDI
events in its mailbox as soon as they are emitted from the device.
Specs
open(:input, <<_::0>>) :: {:ok, pid} | {:error, atom}
Opens a connection to the input device with name device_name
.
Returns the pid
to the corresponding GenServer. Use this pid
to call
listen/2
.
If Portmidi can’t open the device, a tuple {:error, reason}
is returned.
Check src/portmidi_shared.c#makePmErrorAtom
for all possible errors.
Specs
open(:output, <<_::0>>, non_neg_integer) ::
{:ok, pid} |
{:error, atom}
Opens a connection to the output device with name device_name
.
Returns the pid
to the corresponding GenServer. Use this pid
to call
write/2
.
If Portmidi can’t open the device, a tuple {:error, reason}
is returned.
Check src/portmidi_shared.c#makePmErrorAtom
for all possible errors.
Starts the :portmidi
application. Under the hood, starts the
Portmidi.Listeners
GenServer, that holds all the listeners to
input devices.
Specs
Writes a MIDI event to the given output
device. message
can be a tuple
{status, note, velocity}
, a tuple {{status, note, velocity}, timestamp}
or a list [{{status, note, velocity}, timestamp}, ...]
. Returns :ok
on write.