Switchboard SDK
Loading...
Searching...
No Matches
switchboard::SquareGenerator Class Reference

Generates a square wave. More...

#include <SquareGenerator.hpp>

Inheritance diagram for switchboard::SquareGenerator:
switchboard::Generator

Public Member Functions

 SquareGenerator (const float frequency=440.0f)
 SquareGenerator constructor.
 
void setDutyCycle (const float dutyCycle)
 Sets the duty cycle of the generator. Should be between 0.0f and 1.0f.
 
float getDutyCycle () const
 Gets the duty cycle of the generator.
 
- Public Member Functions inherited from switchboard::Generator
 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.
 

Additional Inherited Members

- Protected Member Functions inherited from switchboard::Generator
void stepPhase ()
 
- Protected Attributes inherited from switchboard::Generator
float phase
 
GeneratorType type
 

Detailed Description

Generates a square wave.

Square wave generator

Constructor & Destructor Documentation

◆ SquareGenerator()

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

SquareGenerator constructor.

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

Member Function Documentation

◆ getDutyCycle()

float switchboard::SquareGenerator::getDutyCycle ( ) const

Gets the duty cycle of the generator.

Returns
The duty cycle

◆ setDutyCycle()

void switchboard::SquareGenerator::setDutyCycle ( const float dutyCycle)

Sets the duty cycle of the generator. Should be between 0.0f and 1.0f.

Parameters
dutyCycleThe duty cycle