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