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,
37 const dsp::TempoMap &tempo_map) noexcept override;
38
39 void clear_buffer (std::size_t offset, std::size_t nframes) override;
40
41 friend void
42 init_from (CVPort &obj, const CVPort &other, utils::ObjectCloneType clone_type);
43
45 const graph::GraphNode * node,
46 units::sample_rate_t sample_rate,
47 nframes_t max_block_length) override;
48 void release_resources () override;
49
50private:
51 static constexpr std::string_view kRangeKey = "range";
52 friend void to_json (nlohmann::json &j, const CVPort &p)
53 {
54 to_json (j, static_cast<const Port &> (p));
55 }
56 friend void from_json (const nlohmann::json &j, CVPort &p)
57 {
58 from_json (j, static_cast<Port &> (p));
59 }
60
61public:
65 std::vector<float> buf_;
66
76 std::unique_ptr<RingBuffer<float>> cv_ring_;
77
78private:
79 BOOST_DESCRIBE_CLASS (CVPort, (Port), (), (), ())
80};
81
82} // 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:76
std::vector< float > buf_
Audio-like data buffer.
Definition cv_port.h:65
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:131
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