HART  0.2.0
High level Audio Regression and Testing
Loading...
Searching...
No Matches
hart_dc.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cmath>
4#include <memory>
5
8#include "signals/hart_signal.hpp"
9#include "hart_utils.hpp"
10
11namespace hart
12{
13
14/// @brief Produces a DC signal
15/// @details Regardless of sample rate, assigns each sample to a requested value
16/// @ingroup Signals
17template<typename SampleType>
18class DC:
19 public Signal<SampleType, DC<SampleType>>
20{
21public:
22 /// @brief Creates a DC Signal
23 /// @param dcValueLinear Value to fill the buffers with, in linear domain, signed
24 DC (SampleType dcValueLinear) :
25 m_dcValueLinear (dcValueLinear)
26 {
27 }
28
29 bool supportsNumChannels (size_t /* numChannels */) const override { return true; };
30 void prepare (double /* sampleRateHz */, size_t /* numOutputChannels */, size_t /*maxBlockSizeFrames*/) override {}
31 void reset() override {}
32
33 void renderNextBlock (AudioBuffer<SampleType>& output) override
34 {
35 const size_t numChannels = output.getNumChannels();
36 const size_t numFrames = output.getNumFrames();
37
38 for (size_t channel = 0; channel < numChannels; ++channel)
39 {
40 SampleType* channelData = output[channel];
41
42 for (size_t frame = 0; frame < numFrames; ++frame)
43 channelData[frame] = m_dcValueLinear;
44 }
45 }
46
47 void represent (std::ostream& stream) const override
48 {
49 stream << "DC (" << linPrecision << m_dcValueLinear << ')';
50 }
51
52private:
53 const SampleType m_dcValueLinear;
54};
55
57
58} // namespace hart
Container for audio data.
Produces a DC signal.
Definition hart_dc.hpp:20
void renderNextBlock(AudioBuffer< SampleType > &output) override
Renders next block audio for the signal.
Definition hart_dc.hpp:33
void represent(std::ostream &stream) const override
Makes a text representation of this Signal for test failure outputs.
Definition hart_dc.hpp:47
bool supportsNumChannels(size_t) const override
Tells the host whether this Signal is capable of generating audio for a certain amount of channels.
Definition hart_dc.hpp:29
DC(SampleType dcValueLinear)
Creates a DC Signal.
Definition hart_dc.hpp:24
void prepare(double, size_t, size_t) override
Prepare the signal for rendering.
Definition hart_dc.hpp:30
void reset() override
Resets the Signal to initial state.
Definition hart_dc.hpp:31
Base class for signals.
std::ostream & linPrecision(std::ostream &stream)
Sets number of decimal places for linear (sample) values.
#define HART_SIGNAL_DECLARE_ALIASES_FOR(ClassName)