6#include "signals/hart_signal.hpp"
15template<
typename SampleType>
34 m_signals.push_back (signalA.copy());
35 m_signals.push_back (signalB.copy());
42 m_signals.reserve (other.m_signals.size());
44 for (
const auto& src : other.m_signals)
45 m_signals.emplace_back (src->copy());
51 m_signals (std::move (other.m_signals))
66 m_signals.reserve (other.m_signals.size());
68 for (
const auto& signal : other.m_signals)
69 m_signals.emplace_back (signal->copy());
81 m_signals = std::move (other.m_signals);
86 void prepare (
double sampleRateHz, size_t numOutputChannels, size_t maxBlockSizeFrames)
override
88 for (
auto& signal : m_signals)
89 signal->prepareWithDSPChain (sampleRateHz, numOutputChannels, maxBlockSizeFrames);
94 if (m_signals.empty())
101 m_signals[0]->renderNextBlockWithDSPChain (output);
107 for (size_t i = 1; i < m_signals.size(); ++i)
109 m_signals[i]->renderNextBlockWithDSPChain (buffer);
112 for (size_t channel = 0; channel < output.getNumChannels(); ++channel)
113 for (size_t frame = 0; frame < output.getNumFrames(); ++frame)
114 output[channel][frame] += buffer[channel][frame];
120 for (
auto& signal : m_signals)
121 signal->resetWithDSPChain();
126 s <<
"<MixedSignal: {";
128 for (size_t i = 0; i < m_signals.size(); ++i)
133 m_signals[i]->representWithDSPChain (s);
140 std::vector<std::unique_ptr<
SignalBase<SampleType>>> m_signals;
146template<
typename SampleType,
typename DerivedSignalTypeLHS,
typename DerivedSignalTypeRHS>
148 const Signal<SampleType, DerivedSignalTypeLHS>& lhs,
149 const Signal<SampleType, DerivedSignalTypeRHS>& rhs
153 static_cast<
const DerivedSignalTypeLHS&> (lhs),
154 static_cast<
const DerivedSignalTypeRHS&> (rhs)
161template<
typename SampleType,
typename DerivedSignalTypeLHS,
typename DerivedSignalTypeRHS>
163 const Signal<SampleType, DerivedSignalTypeLHS>& lhs,
164 const Signal<SampleType, DerivedSignalTypeRHS>& rhs
168 static_cast<
const DerivedSignalTypeLHS&> (lhs),
169 -
static_cast<
const DerivedSignalTypeRHS&> (rhs)
Produces a mix of multiple signals.
void renderNextBlock(AudioBuffer< SampleType > &output) override
Renders next block audio for the signal.
void represent(std::ostream &s) const override
Makes a text representation of this Signal for test failure outputs.
MixedSignal(MixedSignal &&other) noexcept
Moves from other MixedSignal.
~MixedSignal()=default
Destructor.
MixedSignal()=default
Default constructor.
MixedSignal & operator=(MixedSignal &&other) noexcept
Moves from other MixedSignal.
MixedSignal & operator=(const MixedSignal &other)
Copies other MixedSignal.
void prepare(double sampleRateHz, size_t numOutputChannels, size_t maxBlockSizeFrames) override
Prepare the signal for rendering.
void reset() override
Resets the Signal to initial state.
MixedSignal(const SignalBase< SampleType > &signalA, const SignalBase< SampleType > &signalB)
Creates a MixedSignals from two existing signals.
MixedSignal(const MixedSignal &other)
Copies other MixedSignal.
Polymorphic base for all signals.
MixedSignal< SampleType > operator-(const Signal< SampleType, DerivedSignalTypeLHS > &lhs, const Signal< SampleType, DerivedSignalTypeRHS > &rhs)
Subtracts one signal from another, resulting in a new mixed signal.
MixedSignal< SampleType > operator+(const Signal< SampleType, DerivedSignalTypeLHS > &lhs, const Signal< SampleType, DerivedSignalTypeRHS > &rhs)
Adds one signal to another, resulting in a new mixed signal.