7#include "utils/icloneable.h"
8#include "utils/monotonic_time_provider.h"
9#include "utils/ring_buffer.h"
11#include <nlohmann/json_fwd.hpp>
61 Purpose purpose = Purpose::Main);
63 static constexpr size_t AUDIO_RING_SIZE = 65536;
65 [[gnu::hot]]
void process_block (
68 const dsp::TempoMap &tempo_map)
noexcept override;
70 void clear_buffer (std::size_t offset, std::size_t nframes)
override;
72 [[nodiscard]]
auto layout ()
const {
return layout_; }
73 [[nodiscard]]
auto purpose ()
const {
return purpose_; }
74 [[nodiscard]]
auto &buffers ()
const {
return buf_; }
75 [[nodiscard]]
auto &audio_ring_buffers ()
const {
return audio_ring_; }
76 auto num_channels ()
const {
return num_channels_; }
78 void mark_as_requires_limiting () { requires_limiting_ =
true; }
79 auto requires_limiting ()
const {
return requires_limiting_; }
87 float multiplier = 1.f);
92 float multiplier = 1.f);
94 friend void init_from (
96 const AudioPort &other,
101 units::sample_rate_t sample_rate,
106 static constexpr auto kBusLayoutId =
"busLayout"sv;
107 static constexpr auto kPurposeId =
"purpose"sv;
108 static constexpr auto kRequiresLimitingId =
"requiresLimiting"sv;
109 static constexpr auto kChannels =
"channels"sv;
110 friend void to_json (nlohmann::json &j,
const AudioPort &port);
111 friend void from_json (
const nlohmann::json &j, AudioPort &port);
117 uint8_t num_channels_{};
125 bool requires_limiting_{};
130 std::unique_ptr<juce::AudioSampleBuffer> buf_;
141 std::vector<RingBuffer<float>> audio_ring_;
143 BOOST_DESCRIBE_CLASS (
148 (layout_, purpose_, requires_limiting_))
157 static std::pair<utils::Utf8String, utils::Utf8String> get_name_and_symbols (
162 return std::make_pair (
164 fmt::format (
"{} {}", name, left ?
"L" :
"R")),
166 fmt::format (
"{}_{}", symbol, left ?
"l" :
"r")));
Purpose
Purpose of this port.
void add_source_rt(const AudioPort &src, EngineProcessTimeInfo time_nfo, float multiplier=1.f)
Adds the contents of src to this port.
void prepare_for_processing(const graph::GraphNode *node, units::sample_rate_t sample_rate, nframes_t max_block_length) override
Called to allocate resources required for processing.
void release_resources() override
Called to release resources allocated by prepare_for_processing().
BusLayout
Description of the channel layout of this port.
void clear_buffer(std::size_t offset, std::size_t nframes) override
Clears the port buffer.
Convenience factory for L/R audio port pairs.
Represents a node in a DSP graph.
Lightweight UTF-8 string wrapper with safe conversions.
static constexpr Utf8String from_utf8_encoded_string(std::string_view str)
Construct from a std::string_view that we are 100% sure is UTF8-encoded.
uint32_t nframes_t
Frame count.
Common struct to pass around during processing to avoid repeating the data in function arguments.