Vital
Loading...
Searching...
No Matches
upsampler.cpp
Go to the documentation of this file.
1#include "upsampler.h"
2
3namespace vital {
4
8 Upsampler::Upsampler() : ProcessorRouter(kNumInputs, 1) { }
9
14
22 void Upsampler::process(int num_samples) {
23 const poly_float* audio_in = input(kAudio)->source->buffer;
24 processWithInput(audio_in, num_samples);
25 }
26
35 void Upsampler::processWithInput(const poly_float* audio_in, int num_samples) {
36 poly_float* destination = output()->buffer;
37
38 int oversample_amount = getOversampleAmount();
39
40 for (int i = 0; i < num_samples; ++i) {
41 int offset = i * oversample_amount;
42 for (int s = 0; s < oversample_amount; ++s)
43 destination[offset + s] = audio_in[i];
44 }
45 }
46} // namespace vital
force_inline Input * input(unsigned int index=0) const
Retrieves the Input pointer at a given index.
Definition processor.h:587
force_inline int getOversampleAmount() const
Retrieves the current oversampling factor.
Definition processor.h:334
force_inline Output * output(unsigned int index=0) const
Retrieves the Output pointer at a given index.
Definition processor.h:616
A specialized Processor that manages a directed graph of Processors and ensures correct processing or...
Definition processor_router.h:34
@ kAudio
Input audio signal.
Definition upsampler.h:28
virtual void processWithInput(const poly_float *audio_in, int num_samples) override
Processes a given block of input samples by upsampling them.
Definition upsampler.cpp:35
virtual ~Upsampler()
Destructor.
Definition upsampler.cpp:13
Upsampler()
Constructs an Upsampler.
Definition upsampler.cpp:8
virtual void process(int num_samples) override
Processes a block of audio samples using the already connected input.
Definition upsampler.cpp:22
Contains classes and functions used within the Vital synthesizer framework.
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