Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
cv_port.h
1// SPDX-FileCopyrightText: © 2024-2025 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#pragma once
5
6#include "dsp/port.h"
7#include "utils/icloneable.h"
8#include "utils/ring_buffer.h"
9
10namespace zrythm::dsp
11{
12
21class CVPort final
22 : public QObject,
23 public Port,
25 public PortConnectionsCacheMixin<CVPort>
26{
27 Q_OBJECT
28 QML_ELEMENT
29 QML_UNCREATABLE ("")
30
31public:
32 CVPort (utils::Utf8String label, PortFlow flow);
33
34 [[gnu::hot]] void process_block (
35 EngineProcessTimeInfo time_nfo,
36 const dsp::ITransport &transport) noexcept override;
37
38 void clear_buffer (std::size_t offset, std::size_t nframes) override;
39
40 friend void
41 init_from (CVPort &obj, const CVPort &other, utils::ObjectCloneType clone_type);
42
44 const graph::GraphNode * node,
45 units::sample_rate_t sample_rate,
46 nframes_t max_block_length) override;
47 void release_resources () override;
48
49private:
50 static constexpr std::string_view kRangeKey = "range";
51 friend void to_json (nlohmann::json &j, const CVPort &p)
52 {
53 to_json (j, static_cast<const Port &> (p));
54 }
55 friend void from_json (const nlohmann::json &j, CVPort &p)
56 {
57 from_json (j, static_cast<Port &> (p));
58 }
59
60public:
64 std::vector<float> buf_;
65
75 std::unique_ptr<RingBuffer<float>> cv_ring_;
76
77private:
78 BOOST_DESCRIBE_CLASS (CVPort, (Port), (), (), ())
79};
80
81} // namespace zrythm::dsp
Control Voltage port.
Definition cv_port.h:26
std::unique_ptr< RingBuffer< float > > cv_ring_
Ring buffer for saving the contents of the audio buffer to be used in the UI instead of directly acce...
Definition cv_port.h:75
std::vector< float > buf_
Audio-like data buffer.
Definition cv_port.h:64
void release_resources() override
Called to release resources allocated by prepare_for_processing().
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 clear_buffer(std::size_t offset, std::size_t nframes) override
Clears the port buffer.
Interface for transport.
Definition itransport.h:17
A base class for ports used for connecting processors in the DSP graph.
Definition port.h:30
Represents a node in a DSP graph.
Definition graph_node.h:129
Lightweight UTF-8 string wrapper with safe conversions.
Definition utf8_string.h:38
uint32_t nframes_t
Frame count.
Definition types.h:58
Common struct to pass around during processing to avoid repeating the data in function arguments.
Definition types.h:133