midi_device
Overview
midi_device
is an abstraction which encapsulates the properties and functionality of a MIDI interface. Each MIDI device includes information such as its name, device identifier, and the number of inputs and outputs available.
Declaration
class midi_device
{
public:
using device_list = std::vector<midi_device>;
static device_list list();
std::uint32_t id() const;
std::string name() const;
std::size_t num_inputs() const;
std::size_t num_outputs() const;
};
Expressions
Notation
a
,b
-
Objects of type
midi_device
. md
-
Object of type
midi_device
. id
-
A unique audio device ID integer.
Constructors and Assignment
Expression | Semantics |
---|---|
|
Copy construct from |
|
Assign |
-
There are no public constructors. Instead, see
list()
andget(id)
below. -
midi_device(s)
are lightweight handles that can be cheaply passed by value.
Instantiation
Expression | Semantics | Return Type |
---|---|---|
|
Get the list of available MIDI devices. |
|
-
To get a
midi_device
, first get list of currently available MIDI devices viamidi_device::list()
, then choose, or let the user choose, the one suitable for your needs.
Accessors
Expression | Semantics | Return Type |
---|---|---|
|
Get the unique ID. |
|
|
Get the unique name. |
|
|
Get the number of MIDI inputs. |
|
|
Get the number of MIDI outputs. |
|
Example
List all available MIDI devices:
#include <q_io/midi_device.hpp>
#include <iostream>
#include <string>
namespace q = cycfi::q;
int main()
{
std::cout << "Available MIDI Devices: " << std::endl;
for (auto const& device : q::midi_device::list())
{
std::cout
<< "id: " << device.id() << std:: endl
<< "name: \"" << device.name() << '"' << std:: endl
<< "number of inputs: " << device.num_inputs() << std:: endl
<< "number of outputs: " << device.num_outputs() << std:: endl
;
}
return 0;
}