2#include <ossia/detail/lockfree_queue.hpp>
3#include <ossia/network/base/device.hpp>
4#include <ossia/network/base/parameter.hpp>
5#include <ossia/network/base/protocol.hpp>
6#include <ossia/network/common/parameter_properties.hpp>
7#include <ossia/network/context_functions.hpp>
8#include <ossia/network/domain/domain.hpp>
9#include <ossia/network/value/value.hpp>
10#include <ossia/protocols/midi/detail/channel.hpp>
12#include <libremidi/api.hpp>
13#include <libremidi/configurations.hpp>
14#include <libremidi/detail/conversion.hpp>
15#include <libremidi/message.hpp>
16#include <libremidi/observer_configuration.hpp>
17#include <libremidi/ump.hpp>
26struct input_configuration;
27struct output_configuration;
30namespace ossia::net::midi
33struct OSSIA_EXPORT midi_info
41 midi_info() =
default;
42 midi_info(
const libremidi::input_port& p,
bool v)
48 midi_info(
const libremidi::output_port& p,
bool v)
55 midi_info(Type t,
const libremidi::port_information& p,
bool v)
63 libremidi::port_information handle{};
67class OSSIA_EXPORT midi_protocol final
69 ,
public Nano::Observer
72 explicit midi_protocol(
73 ossia::net::network_context_ptr, std::string device_name,
74 libremidi::input_configuration&, libremidi::input_api_configuration midi_api);
75 explicit midi_protocol(
76 ossia::net::network_context_ptr, std::string device_name,
77 libremidi::output_configuration&, libremidi::output_api_configuration midi_api);
78 explicit midi_protocol(
79 ossia::net::network_context_ptr, midi_info,
80 libremidi::API api = libremidi::API::UNSPECIFIED);
83 bool set_info(midi_info);
84 midi_info get_info()
const;
86 int64_t get_timestamp() const noexcept;
89 get_midi_port_name(
ossia::net::device_base* dev, const midi_info& info);
91 static std::vector<midi_info> scan(libremidi::API = libremidi::API::UNSPECIFIED);
93 void push_value(const libremidi::message&);
94 void push_value(const libremidi::ump&);
96 void enable_registration();
98 bool learning() const;
99 void set_learning(
bool);
101 libremidi::midi_in* midi_in() const noexcept {
return m_input.get(); }
103 ossia::spsc_queue<libremidi::ump> messages;
106 ossia::net::network_context_ptr m_context;
107 std::unique_ptr<libremidi::midi_in> m_input;
108 std::unique_ptr<libremidi::midi_out> m_output;
110 std::array<midi_channel, 16> m_channels;
113 midi_device* m_dev{};
115 std::atomic_bool m_learning{};
117 friend class midi_device;
118 friend class midi_parameter;
126 void register_parameter(midi_parameter& adrs);
127 void unregister_parameter(midi_parameter& adrs);
135 void midi_callback(
const libremidi::message&);
136 void on_learn(
const libremidi::message& m);
138 libremidi::midi1_to_midi2 to_midi2;
Root of a device tree.
Definition ossia/network/base/device.hpp:58
The node_base class.
Definition node.hpp:48
The parameter_base class.
Definition ossia/network/base/parameter.hpp:48
The protocol_base class.
Definition protocol.hpp:40
The value class.
Definition value.hpp:173
void(* value_callback)(void *, const opp::value &)
container for a value callback
Definition ossia-cpp98.hpp:474
Full information about a parameter.
Definition parameter_data.hpp:61