HART  0.2.0
High level Audio Regression and Testing
Loading...
Searching...
No Matches
hart_bypass.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "dsp/hart_dsp.hpp"
4#include "hart_utils.hpp" // HART_DEFINE_GENERIC_REPRESENT()
5
6namespace hart
7{
8
9/// @brief Bypasses the audio
10/// @details Just copies the inout data to the output, as in "true bypass".
11/// Useful for cases where you just want to render the signal to the output buffer as-is.
12/// Selecting specific channels, like `.atChannels()` will result in only the selected
13/// channels being bypassed (copied), while the rest of them will be untouched in the
14/// output buffer. The data in those un-selected channels might end up being un-initialised.
15/// It probably doesn't make sense to use this specific "effect" on a subset of channels,
16/// but it's still supported, just to be in line with existing HART API.
17/// @tparam SampleType Type of audio sample data, typically `float` or `double`.
18template <typename SampleType>
19class Bypass :
20 public DSP<SampleType, Bypass<SampleType>>
21{
22public:
23 void prepare (double /* sampleRateHz */, size_t /* numInputChannels */, size_t /* numOutputChannels */, size_t /* maxBlockSizeFrames */) override
24 {
25 }
26
27 void process (const AudioBuffer<SampleType>& input, AudioBuffer<SampleType>& output, const EnvelopeBuffers& /* envelopeBuffers */, ChannelFlags channelsToProcess) override
28 {
29 hassert (input.getNumChannels() == output.getNumChannels());
30 hassert (input.getNumFrames() == output.getNumFrames());
31
32 const size_t numChannels = input.getNumChannels();
33 const size_t numFrames = input.getNumFrames();
34
35 for (size_t channel = 0; channel < numChannels; ++channel)
36 {
37 if (channelsToProcess[channel] == false)
38 continue;
39
40 const SampleType* inputData = input[channel];
41 SampleType* outputData = output[channel];
42
43 for (size_t frame = 0; frame < numFrames; ++frame)
44 outputData[frame] = inputData[frame];
45 }
46 }
47
48 void setValue (int /* paramId */, double /* value */)
49 {
50 // Doesn't support any settable parameters
52 }
53
54 bool supportsChannelLayout (size_t numInputChannels, size_t numOutputChannels) const
55 {
56 return numInputChannels == numOutputChannels;
57 }
58
62};
63
65
66} // namespace hart
Bypasses the audio.
void setValue(int, double)
Sets DSP value.
void process(const AudioBuffer< SampleType > &input, AudioBuffer< SampleType > &output, const EnvelopeBuffers &, ChannelFlags channelsToProcess) override
Processes the audio.
void prepare(double, size_t, size_t, size_t) override
Prepare for processing.
bool supportsChannelLayout(size_t numInputChannels, size_t numOutputChannels) const
Tells the runner (host) whether this effect supports a specific i/o configuration.
A set of boolean flags mapped to each audio channel.
std::bitset< m_maxChannels >::reference operator[](size_t channel)
Access the flag value for a specific channel.
Base for DSP effects.
Definition hart_dsp.hpp:345
#define HART_DSP_COPYABLE(ClassName)
Implements a generic hart::DSP::copy() method.
Definition hart_dsp.hpp:602
#define HART_DSP_MOVABLE(ClassName)
Implements a generic hart::DSP::move() method.
Definition hart_dsp.hpp:610
#define hassert(condition)
Triggers a HartAssertException if the condition is false
#define hassertfalse
Triggers a HartAssertException
#define HART_DEFINE_GENERIC_REPRESENT(ClassName)
Defines a basic string representation of your class.
#define HART_DSP_DECLARE_ALIASES_FOR(ClassName)
Definition hart_dsp.hpp:619