5#include "audio_buffer.h"
17 virtual void Generate(std::span<float> output) = 0;
32 SineWave(
float frequency = 0.0f,
float initial_phase = 0.0f);
76 void Generate(std::span<float> output)
override;
83 void Multiply(std::span<const float> input, std::span<float> output);
94 float phase_increment_;
Base class for oscillators and signal generators.
Definition oscillator.h:11
virtual void Generate(std::span< float > output)=0
Fills the output span with generated samples.
A sine wave oscillator.
Definition oscillator.h:24
void SetOffset(float offset)
Sets the DC offset of the sine wave oscillator.
float GetAmplitude() const
Returns the amplitude of the sine wave oscillator.
float GetOffset() const
Returns the DC offset of the sine wave oscillator.
SineWave(float frequency=0.0f, float initial_phase=0.0f)
Constructs a sine wave oscillator.
void Multiply(std::span< const float > input, std::span< float > output)
Multiply input by the sine wave and store the result in output.
void ResetPhase()
Resets the phase of the sine wave oscillator.
void SetPhaseOffset(float phase_offset)
Sets the phase offset of the sine wave oscillator.
float Tick()
Advances the phase and returns the next output sample.
void Generate(std::span< float > output) override
Fills the output span with generated samples.
void SetAmplitude(float amplitude)
Sets the amplitude of the sine wave oscillator.
void SetFrequency(float frequency)
Sets the frequency of the sine wave oscillator.
void MultiplyAccumulate(std::span< const float > input, std::span< float > output)
Multiply input by the sine wave and accumulate the result in output.
float NextOut() const
Returns the next output sample without advancing the phase.