6#include "zrythm-config.h"
8#include "gui/dsp/port.h"
9#include "utils/serialization.h"
10#include "utils/types.h"
13# include "weakjack/weak_libjack.h"
16namespace zrythm::engine::device_io
20enum class AudioBackend : basic_enum_base_type_t;
21enum class MidiBackend : basic_enum_base_type_t;
41 using PortType = zrythm::dsp::PortType;
42 using PortFlow = zrythm::dsp::PortFlow;
50 bool is_in_active_project ()
const override;
81 friend bool operator== (
const ExtPort &a,
const ExtPort &b);
140 static constexpr std::string_view kTypeKey =
"type";
141 static constexpr std::string_view kFullNameKey =
"fullName";
142 static constexpr std::string_view kShortNameKey =
"shortName";
143 static constexpr std::string_view kAlias1Key =
"alias1";
144 static constexpr std::string_view kAlias2Key =
"alias2";
145 static constexpr std::string_view kNumAliasesKey =
"numAliases";
146 static constexpr std::string_view kIsMidiKey =
"isMidi";
147 friend void to_json (nlohmann::json &j,
const ExtPort &port)
150 { kTypeKey, port.type_ },
155 { kNumAliasesKey, port.num_aliases_ },
159 friend void from_json (
const nlohmann::json &j, ExtPort &port)
161 j.at (kTypeKey).get_to (port.type_);
162 j.at (kFullNameKey).get_to (port.full_name_);
163 j.at (kShortNameKey).get_to (port.short_name_);
164 j.at (kAlias1Key).get_to (port.alias1_);
165 j.at (kAlias2Key).get_to (port.alias2_);
166 j.at (kNumAliasesKey).get_to (port.num_aliases_);
167 j.at (kIsMidiKey).get_to (port.is_midi_);
170 friend bool operator== (
const ExtPort &a,
const ExtPort &b)
172 return a.type_ == b.type_ && a.full_name_ == b.full_name_;
178 jack_port_t *
jport_ =
nullptr;
195 int num_aliases_ = 0;
The Port class represents a port in the audio processing graph.
Struct used to identify Ports in the project.
bool get_enabled() const
Checks in the GSettings whether this port is marked as enabled by the user.
bool active_
Whether the port is active and receiving events (for use by hw processor).
int hw_processor_index_
Index in the HW processor (cache for real-time use)
void disconnect(Port *port, int src)
Disconnects the Port from the ExtPort.
bool activate(Port *port, bool activate)
Activates the port (starts receiving data) or deactivates it.
utils::Utf8String get_id() const
Returns a unique identifier (full name prefixed with backend type).
float * get_buffer(nframes_t nframes) const
Returns the buffer of the external port.
void set_port_metadata_from_owner(dsp::PortIdentifier &id, PortRange &range) const override
Function that will be called by the Port to update the identifier's relevant members based on this po...
bool matches_backend() const
Returns if the ext port matches the current backend.
void init_loaded(HardwareProcessor *hw_processor)
Inits the ExtPort after loading a project.
Port * port_
Temporary port to receive data.
void clear_buffer(nframes_t nframes)
Clears the buffer of the external port.
bool pending_reconnect_
Set to true when a hardware port is disconnected.
bool is_midi_
True if MIDI, false if audio.
utils::Utf8String full_name_
Full port name, used also as ID.
utils::Utf8String get_friendly_name() const
Returns a user-friendly display name (eg, to be used in dropdowns).
utils::Utf8String short_name_
Short port name.
utils::Utf8String alias1_
Alias #1 if any.
HardwareProcessor * hw_processor_
Pointer to owner hardware processor, if any.
utils::Utf8String alias2_
Alias #2 if any.
void print() const
Prints the port info.
Lightweight UTF-8 string wrapper with safe conversions.
uint32_t nframes_t
Frame count.