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
43 void
44 prepare_for_processing (sample_rate_t sample_rate, nframes_t max_block_length)
45 override;
46 void release_resources () override;
47
48private:
49 static constexpr std::string_view kRangeKey = "range";
50 friend void to_json (nlohmann::json &j, const CVPort &p)
51 {
52 to_json (j, static_cast<const Port &> (p));
53 }
54 friend void from_json (const nlohmann::json &j, CVPort &p)
55 {
56 from_json (j, static_cast<Port &> (p));
57 }
58
59public:
63 std::vector<float> buf_;
64
74 std::unique_ptr<RingBuffer<float>> cv_ring_;
75
76private:
77 BOOST_DESCRIBE_CLASS (CVPort, (Port), (), (), ())
78};
79
80} // 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:74
std::vector< float > buf_
Audio-like data buffer.
Definition cv_port.h:63
void release_resources() override
Called to release resources allocated by prepare_for_processing().
void clear_buffer(std::size_t offset, std::size_t nframes) override
Clears the port buffer.
void prepare_for_processing(sample_rate_t sample_rate, nframes_t max_block_length) override
Called to allocate resources required for processing.
Interface for transport.
Definition itransport.h:17
A base class for ports used for connecting processors in the DSP graph.
Definition port.h:30
Lightweight UTF-8 string wrapper with safe conversions.
Definition utf8_string.h:38
uint32_t sample_rate_t
Sample rate.
Definition types.h:61
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:136