Vital
Loading...
Searching...
No Matches
feedback.h
Go to the documentation of this file.
1#pragma once
2
3#include "processor.h"
4#include "utils.h"
5
6namespace vital {
7
26 class Feedback : public Processor {
27 public:
33 Feedback(bool control_rate = false) : Processor(1, 1, control_rate), buffer_index_(0) {
35 }
36
40 virtual ~Feedback() { }
41
42 Processor* clone() const override { return new Feedback(*this); }
43
49 virtual void process(int num_samples) override;
50
59 virtual void refreshOutput(int num_samples);
60
66 force_inline void tick(int i) {
67 buffer_[i] = input(0)->source->buffer[i];
68 }
69
70 protected:
73
74 JUCE_LEAK_DETECTOR(Feedback)
75 };
76
77 namespace cr {
86 class Feedback : public ::vital::Feedback {
87 public:
88 Feedback() : ::vital::Feedback(true), last_value_(0.0f) { }
89
97 void process(int num_samples) override {
98 last_value_ = input()->at(0);
99 }
100
101 Processor* clone() const override { return new cr::Feedback(*this); }
102
108 void refreshOutput(int num_samples) override {
109 output()->buffer[0] = last_value_;
110 }
111
117 void reset(poly_mask reset_mask) override {
118 last_value_ = 0.0f;
119 output()->buffer[0] = last_value_;
120 }
121
122 protected:
124 };
125 } // namespace cr
126} // namespace vital
A processor that buffers and replays audio, providing a feedback loop mechanism.
Definition feedback.h:26
virtual void process(int num_samples) override
Processes a block of samples, storing them into an internal buffer.
Definition feedback.cpp:7
virtual void refreshOutput(int num_samples)
Refreshes the output with previously stored samples.
Definition feedback.cpp:17
Feedback(bool control_rate=false)
Constructs a Feedback processor.
Definition feedback.h:33
Processor * clone() const override
Clones this Processor for polyphonic expansion. Must be overridden by subclasses.
Definition feedback.h:42
poly_float buffer_[kMaxBufferSize]
Internal buffer to store samples for feedback.
Definition feedback.h:71
int buffer_index_
Current write index in the buffer.
Definition feedback.h:72
virtual ~Feedback()
Virtual destructor.
Definition feedback.h:40
force_inline void tick(int i)
Processes a single sample, storing it in the internal buffer.
Definition feedback.h:66
Base class for all signal-processing units in Vital.
Definition processor.h:212
force_inline Input * input(unsigned int index=0) const
Retrieves the Input pointer at a given index.
Definition processor.h:587
force_inline Output * output(unsigned int index=0) const
Retrieves the Output pointer at a given index.
Definition processor.h:616
A control-rate variant of the Feedback processor.
Definition feedback.h:86
void refreshOutput(int num_samples) override
Updates the output with the last stored value.
Definition feedback.h:108
Feedback()
Definition feedback.h:88
void reset(poly_mask reset_mask) override
Resets the internal state of the feedback processor.
Definition feedback.h:117
Processor * clone() const override
Clones this Processor for polyphonic expansion. Must be overridden by subclasses.
Definition feedback.h:101
poly_float last_value_
The last value stored, used as feedback for control signals.
Definition feedback.h:123
void process(int num_samples) override
Processes the control input for a given number of samples (usually 1).
Definition feedback.h:97
#define force_inline
Definition common.h:23
force_inline void zeroBuffer(mono_float *buffer, int size)
Zeros a mono buffer (standard array).
Definition poly_utils.h:570
Contains classes and functions used within the Vital synthesizer framework.
constexpr int kMaxBufferSize
Maximum buffer size for processing.
Definition common.h:39
Declares the Processor class and related structures for handling audio processing in a polyphonic con...
force_inline poly_float at(int i) const
Returns the sample at index i from the source buffer.
Definition processor.h:141
const Output * source
The output from which this input reads samples.
Definition processor.h:134
poly_float * buffer
Pointer to the output buffer.
Definition processor.h:110
Represents a vector of floating-point values using SIMD instructions.
Definition poly_values.h:600
Represents a vector of integer values using SIMD instructions.
Definition poly_values.h:56
Provides various utility functions, classes, and constants for audio, math, and general-purpose opera...