PortMidi v5.1.2 PortMidi View Source
The entry module of portmidi. Through this module you can open and close devices, listen on input devices, or write to output devices.
Link to this section 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
Link to this section Types
message() View Source
timestamp()
View Source
timestamp() :: byte()
timestamp() :: byte()
Link to this section Functions
close(device_type, device) View Source
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.
devices() View Source
Returns a map with input and output devices, in the form of
PortMidi.Device structs
listen(input, pid) View Source
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.
open(atom, device_name) View Source
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.
open(atom, device_name, latency \\ 0)
View Source
open(:output, <<_::0>>, non_neg_integer()) :: {:ok, pid()} | {:error, atom()}
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.
start(type, args) View Source
Starts the :portmidi application. Under the hood, starts the
Portmidi.Listeners GenServer, that holds all the listeners to
input devices.
write(output, message) View Source
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.