Vital
Loading...
Searching...
No Matches
feedback.cpp
Go to the documentation of this file.
1#include "feedback.h"
2
3#include "processor_router.h"
4
5namespace vital {
6
7 void Feedback::process(int num_samples) {
9
10 const poly_float* audio_in = input(0)->source->buffer;
11 for (int i = 0; i < num_samples; ++i) {
12 buffer_[buffer_index_] = audio_in[i];
14 }
15 }
16
17 void Feedback::refreshOutput(int num_samples) {
18 poly_float* audio_out = output(0)->buffer;
19 int index = (kMaxBufferSize + buffer_index_ - num_samples) % kMaxBufferSize;
20 for (int i = 0; i < num_samples; ++i) {
21 audio_out[i] = buffer_[index];
22 index = (index + 1) % kMaxBufferSize;
23 }
24 }
25} // namespace vital
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
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
force_inline Input * input(unsigned int index=0) const
Retrieves the Input pointer at a given index.
Definition processor.h:587
bool inputMatchesBufferSize(int input=0)
Checks whether the buffer size of a particular input matches the size needed by this Processor.
Definition processor.cpp:42
force_inline Output * output(unsigned int index=0) const
Retrieves the Output pointer at a given index.
Definition processor.h:616
#define VITAL_ASSERT(x)
Definition common.h:11
Contains classes and functions used within the Vital synthesizer framework.
constexpr int kMaxBufferSize
Maximum buffer size for processing.
Definition common.h:39
Declares the ProcessorRouter class, which manages a graph of Processors and their dependencies.
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