6#include "engine/device_io/ext_port.h"
7#include "gui/dsp/audio_port.h"
8#include "gui/dsp/midi_port.h"
9#include "utils/icloneable.h"
11#define HW_IN_PROCESSOR (AUDIO_ENGINE->hw_in_processor_)
12#define HW_OUT_PROCESSOR (AUDIO_ENGINE->hw_out_processor_)
14namespace zrythm::engine::device_io
19class HardwareProcessor final
20 :
public ICloneable<HardwareProcessor>,
24 using PortFlow = zrythm::dsp::PortFlow;
28 HardwareProcessor () =
default;
30 HardwareProcessor (
bool input,
AudioEngine * engine);
34 bool is_in_active_project ()
const;
84 static constexpr auto kIsInputKey =
"isInput"sv;
85 static constexpr auto kExtAudioPortsKey =
"extAudioPorts"sv;
86 static constexpr auto kExtMidiPortsKey =
"extMidiPorts"sv;
87 static constexpr auto kAudioPortsKey =
"audioPorts"sv;
88 static constexpr auto kMidiPortsKey =
"midiPorts"sv;
89 friend void to_json (nlohmann::json &j,
const HardwareProcessor &p)
94 { kExtMidiPortsKey, p.ext_midi_ports_ },
96 { kMidiPortsKey, p.midi_ports_ },
99 friend void from_json (
const nlohmann::json &j, HardwareProcessor &p);
101 template <
typename T>
103 create_port_for_ext_port (
const ExtPort &ext_port, PortFlow flow);
120 std::vector<utils::Utf8String> selected_audio_ports_;
126 std::vector<std::unique_ptr<ExtPort>> ext_midi_ports_;
132 std::vector<std::unique_ptr<MidiPort>> midi_ports_;
140 quint64 rescan_timeout_id_ = 0;
146extern template std::unique_ptr<MidiPort>
147HardwareProcessor::create_port_for_ext_port (
const ExtPort &, PortFlow);
148extern template std::unique_ptr<AudioPort>
149HardwareProcessor::create_port_for_ext_port (
const ExtPort &, PortFlow);
150extern template Port *
The Port class represents a port in the audio processing graph.
Interface for objects that can be processed in the DSP graph.
void activate(bool activate)
Starts or stops the ports.
AudioEngine * engine_
Pointer to owner engine, if any.
void rescan_ext_ports()
Rescans the hardware ports and appends any missing ones.
T * find_port(const utils::Utf8String &id)
Finds a port from its ID (type + full name).
bool setup_
Whether set up already.
void process(nframes_t nframes)
Processes the data.
bool activated_
Whether currently active.
bool is_input_
Whether this is the processor at the start of the graph (input) or at the end (output).
void init_after_cloning(const HardwareProcessor &other, ObjectCloneType clone_type) override
To be used during serialization.
std::vector< utils::Utf8String > selected_midi_ports_
Ports selected by the user in the preferences to enable.
void setup()
Sets up the ports but does not start them.
utils::Utf8String get_node_name() const override
Returns a human friendly name of the node.
std::vector< std::unique_ptr< AudioPort > > audio_ports_
Ports to be used by Zrythm, corresponding to the external ports.
ExtPort * find_ext_port(const utils::Utf8String &id)
Finds an ext port from its ID (type + full name).
std::vector< std::unique_ptr< ExtPort > > ext_audio_ports_
All known external ports.
Lightweight UTF-8 string wrapper with safe conversions.
uint32_t nframes_t
Frame count.