sfFDN
Loading...
Searching...
No Matches
sfFDN::SineWave Class Reference

A sine wave oscillator. More...

#include <oscillator.h>

Inheritance diagram for sfFDN::SineWave:
[legend]
Collaboration diagram for sfFDN::SineWave:
[legend]

Public Member Functions

 SineWave (float frequency=0.0f, float initial_phase=0.0f)
 Constructs a sine wave oscillator.
 
void ResetPhase ()
 Resets the phase of the sine wave oscillator.
 
void SetFrequency (float frequency)
 Sets the frequency of the sine wave oscillator.
 
void SetAmplitude (float amplitude)
 Sets the amplitude of the sine wave oscillator.
 
float GetAmplitude () const
 Returns the amplitude of the sine wave oscillator.
 
float GetAmplitudeNonBlocking () const noexcept SFFDN_NONBLOCKING
 Returns the amplitude for use from a nonblocking processing path.
 
float GetFrequency () const noexcept SFFDN_NONBLOCKING
 Returns the normalized frequency in cycles per sample.
 
void SetOffset (float offset)
 Sets the DC offset of the sine wave oscillator.
 
float GetOffset () const
 Returns the DC offset of the sine wave oscillator.
 
void SetPhaseOffset (float phase_offset)
 Sets the phase offset of the sine wave oscillator.
 
float GetPhaseOffset () const noexcept SFFDN_NONBLOCKING
 Returns the normalized phase offset in cycles.
 
float NextOut () const noexcept SFFDN_NONBLOCKING
 Returns the next output sample without advancing the phase.
 
float Tick () noexcept SFFDN_NONBLOCKING
 Advances the phase and returns the next output sample.
 
void Generate (std::span< float > output) noexcept SFFDN_NONBLOCKING override
 Fills the output span with generated samples.
 
void Multiply (std::span< const float > input, std::span< float > output) noexcept SFFDN_NONBLOCKING
 Multiply input by the sine wave and store the result in output.
 
void MultiplyAccumulate (std::span< const float > input, std::span< float > output) noexcept SFFDN_NONBLOCKING
 Multiply input by the sine wave and accumulate the result in output.
 
- Public Member Functions inherited from sfFDN::Generator

Additional Inherited Members

- Protected Member Functions inherited from sfFDN::Generator
 Generator (const Generator &)=default
 
Generatoroperator= (const Generator &)=default
 
 Generator (Generator &&) noexcept=default
 
Generatoroperator= (Generator &&) noexcept=default
 

Detailed Description

A sine wave oscillator.

The output of the oscillator is given by: output = (sin(phase) * amplitude) + offset

Constructor & Destructor Documentation

◆ SineWave()

sfFDN::SineWave::SineWave ( float frequency = 0.0f,
float initial_phase = 0.0f )

Constructs a sine wave oscillator.

Parameters
frequencyThe frequency of the sine wave in, normalized [0, 1].
initial_phaseThe initial phase of the sine wave, normalized [0, 1].

The normalized frequency is obtained by dividing the desired frequency in Hz by the sample rate.

Member Function Documentation

◆ Generate()

void sfFDN::SineWave::Generate ( std::span< float > output)
overridevirtualnoexcept

Fills the output span with generated samples.

Implements sfFDN::Generator.

◆ GetAmplitude()

float sfFDN::SineWave::GetAmplitude ( ) const

Returns the amplitude of the sine wave oscillator.

Returns
The amplitude of the sine wave oscillator.

◆ GetOffset()

float sfFDN::SineWave::GetOffset ( ) const

Returns the DC offset of the sine wave oscillator.

Returns
The DC offset of the sine wave oscillator.

◆ Multiply()

void sfFDN::SineWave::Multiply ( std::span< const float > input,
std::span< float > output )
noexcept

Multiply input by the sine wave and store the result in output.

Parameters
inputThe input signal to modulate.
outputThe output signal to store the result.

◆ MultiplyAccumulate()

void sfFDN::SineWave::MultiplyAccumulate ( std::span< const float > input,
std::span< float > output )
noexcept

Multiply input by the sine wave and accumulate the result in output.

Parameters
inputThe input signal to modulate.
outputThe output signal to store the result.

◆ SetAmplitude()

void sfFDN::SineWave::SetAmplitude ( float amplitude)

Sets the amplitude of the sine wave oscillator.

Parameters
amplitudeThe amplitude of the sine wave.

◆ SetFrequency()

void sfFDN::SineWave::SetFrequency ( float frequency)

Sets the frequency of the sine wave oscillator.

Parameters
frequencyThe frequency of the sine wave in, normalized [0, 1].

◆ SetOffset()

void sfFDN::SineWave::SetOffset ( float offset)

Sets the DC offset of the sine wave oscillator.

Parameters
offsetThe offset of the sine wave.

The offset is a scalar value added to the output of the sine wave.

◆ SetPhaseOffset()

void sfFDN::SineWave::SetPhaseOffset ( float phase_offset)

Sets the phase offset of the sine wave oscillator.

Parameters
phase_offsetThe phase offset, normalized [0, 1].

The documentation for this class was generated from the following file: