Switchboard SDK
Loading...
Searching...
No Matches
switchboard::Generator Class Referenceabstract

Provides general interface for signal generators. More...

#include <Generator.hpp>

Inheritance diagram for switchboard::Generator:
switchboard::ImpulseGenerator switchboard::SawtoothGenerator switchboard::SineGenerator switchboard::SquareGenerator switchboard::TriangleGenerator switchboard::WhiteNoiseGenerator

Public Member Functions

 Generator (const float frequency=440.0f)
 Generator constructor.
 
 Generator (const Generator &generator)
 Generator copy constructor.
 
virtual ~Generator ()=default
 Generator destructor.
 
float getFrequency () const
 Gets the current frequency value of the generated signal.
 
void setFrequency (const float frequency)
 Sets the frequency of the generated signal.
 
float getAmplitude () const
 Gets the current amplitude value of the generated signal.
 
void setAmplitude (const float amplitude)
 Sets the amplitude of the generated signal.
 
GeneratorType getType ()
 Gets the type of the Generator.
 
template<typename T >
void generate (T *buffer, const uint numberOfSamples, const uint sampleRate)
 Generates the audio data into a data buffer.
 
template<typename T >
void generate (AudioBuffer< T > &audioBuffer)
 Generates the audio data into an audio buffer.
 

Protected Member Functions

void stepPhase ()
 

Protected Attributes

float phase
 
GeneratorType type
 

Detailed Description

Provides general interface for signal generators.

Generator base class

Constructor & Destructor Documentation

◆ Generator()

switchboard::Generator::Generator ( const float frequency = 440.0f)

Generator constructor.

Parameters
frequencyThe initial frequency in Hz. Default value is 440 Hz.

Member Function Documentation

◆ generate() [1/2]

template<typename T >
void switchboard::Generator::generate ( AudioBuffer< T > & audioBuffer)

Generates the audio data into an audio buffer.

Parameters
audioBufferThe audio buffer.

◆ generate() [2/2]

template<typename T >
void switchboard::Generator::generate ( T * buffer,
const uint numberOfSamples,
const uint sampleRate )

Generates the audio data into a data buffer.

Parameters
bufferThe data buffer.
numberOfSamplesThe number of samples to generate.
sampleRateThe sample rate.

◆ getAmplitude()

float switchboard::Generator::getAmplitude ( ) const

Gets the current amplitude value of the generated signal.

Returns
The amplitude value.

◆ getFrequency()

float switchboard::Generator::getFrequency ( ) const

Gets the current frequency value of the generated signal.

Returns
The frequency value in Hz.

◆ getType()

GeneratorType switchboard::Generator::getType ( )

Gets the type of the Generator.

Returns
The type of the Generator.

◆ setAmplitude()

void switchboard::Generator::setAmplitude ( const float amplitude)

Sets the amplitude of the generated signal.

Parameters
amplitudeThe new amplitude value. Should be between 0 and 1.

◆ setFrequency()

void switchboard::Generator::setFrequency ( const float frequency)

Sets the frequency of the generated signal.

Parameters
frequencyThe new frequency value in Hz.