|
HART
0.2.0
High level Audio Regression and Testing
|
Polymorphic base for all signals. More...
#include <hart_signal.hpp>
Public Member Functions | |
| SignalBase ()=default | |
| Default constructor. | |
| SignalBase (const SignalBase &other) | |
| Copies other signal. | |
| SignalBase (SignalBase &&other) noexcept | |
| Moves from other signal. | |
| virtual | ~SignalBase ()=default |
| Destructor. | |
| SignalBase & | operator= (const SignalBase &other) |
| Copies from other signal. | |
| SignalBase & | operator= (SignalBase &&other) noexcept |
| Moves from other signal. | |
| virtual bool | supportsNumChannels (size_t) const |
| Tells the host whether this Signal is capable of generating audio for a certain amount of channels. | |
| virtual bool | supportsSampleRate (double) const |
| Tells whether this Signal supports given sample rate. | |
| virtual void | prepare (double sampleRateHz, size_t numOutputChannels, size_t maxBlockSizeFrames)=0 |
| Prepare the signal for rendering. | |
| virtual void | renderNextBlock (AudioBuffer< SampleType > &output)=0 |
| Renders next block audio for the signal. | |
| virtual void | reset ()=0 |
| Resets the Signal to initial state. | |
| virtual std::unique_ptr< SignalBase< SampleType > > | copy () const =0 |
| Returns a smart pointer with a copy of this object. | |
| virtual std::unique_ptr< SignalBase< SampleType > > | move ()=0 |
| Returns a smart pointer with a moved instance of this object. | |
| virtual void | represent (std::ostream &stream) const =0 |
| Makes a text representation of this Signal for test failure outputs. | |
| void | prepareWithDSPChain (double sampleRateHz, size_t numOutputChannels, size_t maxBlockSizeFrames) |
| Prepares the signal and all attached effects in the DSP chain for rendering. | |
| void | renderNextBlockWithDSPChain (AudioBuffer< SampleType > &output) |
| Renders next block audio for the signal and all the effects in the DSP chain. | |
| virtual void | resetWithDSPChain () |
| Resets to Signal and all the effects attached to its DSP chain to initial state. | |
| size_t | getDSPChainSize () const |
| Returns the size of the DSP chain attached to the Signal. | |
| DSPBase< SampleType > * | getDSP (int index=-1) const |
| Access a specific element in the DSP chain. | |
| std::unique_ptr< DSPBase< SampleType > > | popDSP (int index=-1) |
| Extract a specific element in the DSP chain by removing it. | |
Protected Member Functions | |
| void | setNumChannels (size_t numChannels) |
| size_t | getNumChannels () |
Protected Attributes | |
| size_t | m_numChannels = 1 |
| double | m_startTimestampSeconds = 0.0 |
| std::vector< std::unique_ptr< DSPBase< SampleType > > > | m_dspChain |
Polymorphic base for all signals.
Definition at line 27 of file hart_signal.hpp.
|
default |
Default constructor.
|
inline |
Copies other signal.
Definition at line 34 of file hart_signal.hpp.
|
inlinenoexcept |
Moves from other signal.
Definition at line 65 of file hart_signal.hpp.
|
virtualdefault |
Destructor.
|
inline |
Copies from other signal.
Definition at line 78 of file hart_signal.hpp.
|
inlinenoexcept |
Moves from other signal.
Definition at line 116 of file hart_signal.hpp.
|
inlinevirtual |
Tells the host whether this Signal is capable of generating audio for a certain amount of channels.
It is guaranteed that the signal will not receive unsupported number of channels in renderNextBlock(). This method is guaranteed to be called at least once before prepare()
| numChannels | Number of output channels that will need to be filled |
Reimplemented in AudioBufferSignal< SampleType >, WavFile< SampleType >, Silence< SampleType >, SineSweep< SampleType >, SineWave< SampleType >, and WhiteNoise< SampleType >.
Definition at line 136 of file hart_signal.hpp.
|
inlinevirtual |
Tells whether this Signal supports given sample rate.
It is guaranteed to be called before prepare()
| sampleRateHz | sample rate at which the audio should be generated |
Reimplemented in AudioBufferSignal< SampleType >.
Definition at line 143 of file hart_signal.hpp.
|
pure virtual |
Prepare the signal for rendering.
This method is guaranteed to be called after supportsNumChannels() and supportsSampleRate(), but before renderNextBlock(). It is guaranteed that numChannels obeys supportsNumChannels() preferences, same with sampleRateHz and supportsSampleRate(). It is guaranteed that all subsequent renderNextBlock() calls will be in line with the arguments received in this callback.
| sampleRateHz | sample rate at which the audio should be generated |
| numOutputChannels | Number of output channels to be filled |
| maxBlockSizeFrames | Maximum block size in frames (samples) |
Implemented in MixedSignal< SampleType >, AudioBufferSignal< SampleType >, SignalFunction< SampleType >, WavFile< SampleType >, Sawtooth< SampleType >, SineSweep< SampleType >, SineWave< SampleType >, WhiteNoise< SampleType >, Impulse< SampleType >, and Silence< SampleType >.
|
pure virtual |
Renders next block audio for the signal.
Depending on circumstances, this callback will either be called once to generate an entire piece of audio from start to finish, or called repeatedly, one block at a time. This method is guaranteed to be called strictly after prepare(), or not called at all. Number of channels and max block size are guaranteed to be in line with the ones set by prepare() callback. Assume sample rate to always be equal to the one received in the last prepare() callback. All audio blocks except the last one are guaranteed to be equal to maxBlockSizeFrames set in prepare() callback.
| output | Output audio block |
Implemented in AudioBufferSignal< SampleType >, Impulse< SampleType >, MixedSignal< SampleType >, Sawtooth< SampleType >, SignalFunction< SampleType >, Silence< SampleType >, SineSweep< SampleType >, SineWave< SampleType >, WavFile< SampleType >, and WhiteNoise< SampleType >.
|
pure virtual |
Resets the Signal to initial state.
Ideally should be implemented in a way that audio produced after resetting is identical to audio produced after instantiation
Implemented in AudioBufferSignal< SampleType >, Impulse< SampleType >, MixedSignal< SampleType >, Sawtooth< SampleType >, SignalFunction< SampleType >, Silence< SampleType >, SineSweep< SampleType >, SineWave< SampleType >, WavFile< SampleType >, and WhiteNoise< SampleType >.
|
pure virtual |
Returns a smart pointer with a copy of this object.
Implemented in AudioBufferSignal< SampleType >, Signal< SampleType, DerivedSignal >, Signal< SampleType, AudioBufferSignal< SampleType > >, Signal< SampleType, Impulse< SampleType > >, Signal< SampleType, MixedSignal< SampleType > >, Signal< SampleType, Sawtooth< SampleType > >, Signal< SampleType, SignalFunction< SampleType > >, Signal< SampleType, Silence< SampleType > >, Signal< SampleType, SineSweep< SampleType > >, Signal< SampleType, SineWave< SampleType > >, Signal< SampleType, WavFile< SampleType > >, and Signal< SampleType, WhiteNoise< SampleType > >.
|
pure virtual |
Returns a smart pointer with a moved instance of this object.
Implemented in AudioBufferSignal< SampleType >, Signal< SampleType, DerivedSignal >, Signal< SampleType, AudioBufferSignal< SampleType > >, Signal< SampleType, Impulse< SampleType > >, Signal< SampleType, MixedSignal< SampleType > >, Signal< SampleType, Sawtooth< SampleType > >, Signal< SampleType, SignalFunction< SampleType > >, Signal< SampleType, Silence< SampleType > >, Signal< SampleType, SineSweep< SampleType > >, Signal< SampleType, SineWave< SampleType > >, Signal< SampleType, WavFile< SampleType > >, and Signal< SampleType, WhiteNoise< SampleType > >.
|
pure virtual |
Makes a text representation of this Signal for test failure outputs.
It is strongly encouraged to follow python's repr() conventions for returned text - basically, put something like "MyClass(value1, value2)" (with no quotes) into the stream whenever possible, or "<Readable info in angled brackets>" otherwise. Also, use built-in stream manipulators like dbPrecision wherever applicable. Use HART_DEFINE_GENERIC_REPRESENT() to get a basic implementation for this method.
| [out] | stream | Output stream to write to |
Implemented in MixedSignal< SampleType >, AudioBufferSignal< SampleType >, Sawtooth< SampleType >, SignalFunction< SampleType >, SineSweep< SampleType >, SineWave< SampleType >, WavFile< SampleType >, and WhiteNoise< SampleType >.
|
inline |
Prepares the signal and all attached effects in the DSP chain for rendering.
This method is intended to be called by Signal hosts like AudioTestBuilder or Matcher. If you're making something that owns an instance of a Signal and needs it to generate audio, like a custom Matcher, you must call this method before calling renderNextBlockWithDSPChain(). You must also call supportsNumChannels() and supportsSampleRate() before calling this method.
Definition at line 197 of file hart_signal.hpp.
|
inline |
Renders next block audio for the signal and all the effects in the DSP chain.
This method is intended to be called by Signal hosts like AudioTestBuilder or Matcher If you're making something that owns an instance of a Signal and needs it to generate audio, like a custom Matcher, you must call it after calling prepareWithDSPChain().
Definition at line 223 of file hart_signal.hpp.
|
inlinevirtual |
Resets to Signal and all the effects attached to its DSP chain to initial state.
This method is intended to be called by hosts like AudioTestBuilder or Matcher. If you're not making a custom host, you probably don't need this method.
Definition at line 235 of file hart_signal.hpp.
|
inline |
Returns the size of the DSP chain attached to the Signal.
Definition at line 257 of file hart_signal.hpp.
|
inline |
Access a specific element in the DSP chain.
| index | Index of the element. Can be negative. For non-negative values, it's a usual 0-based index. For negative values, it's counted from the end, e.g. "-1" is the last element, "-2" is the second to last etc. |
| hart::IndexError | if the index is out of range |
Definition at line 267 of file hart_signal.hpp.
|
inline |
Extract a specific element in the DSP chain by removing it.
| index | Index of the element. Can be negative. For non-negative values, it's a usual 0-based index. For negative values, it's counted from the end, e.g. "-1" is the last element, "-2" is the second to last etc. |
| hart::IndexError | if the index is out of range |
Definition at line 289 of file hart_signal.hpp.
|
inlineprotected |
Definition at line 310 of file hart_signal.hpp.
|
inlineprotected |
Definition at line 315 of file hart_signal.hpp.
|
protected |
Definition at line 320 of file hart_signal.hpp.
|
protected |
Definition at line 321 of file hart_signal.hpp.
|
protected |
Definition at line 322 of file hart_signal.hpp.