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

Generates a sine wave with the given frequency and amplitude. More...

#include <SineGeneratorNode.hpp>

Inheritance diagram for switchboard::SineGeneratorNode:
switchboard::SingleBusAudioSourceNode switchboard::AudioSourceNode switchboard::AudioNode

Public Member Functions

 SineGeneratorNode (std::map< std::string, std::any > config)
 Creates a SineGeneratorNode instance.
 
WASM float getFrequency () const
 Gets the current frequency value of the generated sine wave.
 
WASM void setFrequency (const float frequency)
 Sets the frequency of the generated sine wave.
 
WASM float getAmplitude () const
 Gets the current amplitude value of the generated sine wave.
 
WASM void setAmplitude (const float amplitude)
 Sets the amplitude of the generated sine wave.
 
WASM bool setBusFormat (AudioBusFormat &busFormat) override
 Sets bus format.
 
WASM bool produce (AudioBus &bus) override
 Produces audio data in the given bus.
 
- Public Member Functions inherited from switchboard::SingleBusAudioSourceNode
bool setNumberOfBuses (const uint numberOfBuses) override
 Sets number of buses.
 
bool setBusFormats (AudioBusFormatList &busFormats) override
 Sets bus formats.
 
bool produce (AudioBusList &buses) override
 Produces audio data in the given buses.
 
- Public Member Functions inherited from switchboard::AudioSourceNode
- Public Member Functions inherited from switchboard::AudioNode
 AudioNode ()
 AudioNode constructor.
 
virtual ~AudioNode ()=default
 AudioNode virtual destructor.
 
const std::string & getType () const
 Gets the type of the audio node.
 
virtual const std::string getDisplayName () const
 Gets the display name of the audio node.
 
virtual std::vector< std::unique_ptr< Parameter > > & getParameters ()
 Gets the parameters of the audio node.
 
virtual ParametergetParameter (const std::string &id)
 Gets the parameter with the given name.
 

Additional Inherited Members

- Public Attributes inherited from switchboard::AudioNode
std::string name
 The name of the audio node.
 
- Protected Member Functions inherited from switchboard::AudioNode
void initParameters (std::map< std::string, std::any > config)
 Initializes the node parameters from the given configuration values.
 
- Protected Attributes inherited from switchboard::AudioNode
std::string type
 
std::vector< std::unique_ptr< Parameter > > parameters
 

Detailed Description

Generates a sine wave with the given frequency and amplitude.

SineGeneratorNode class.

Constructor & Destructor Documentation

◆ SineGeneratorNode()

switchboard::SineGeneratorNode::SineGeneratorNode ( std::map< std::string, std::any > config)

Creates a SineGeneratorNode instance.

Parameters
configConfiguration map for the node.

Member Function Documentation

◆ getAmplitude()

float switchboard::SineGeneratorNode::getAmplitude ( ) const

Gets the current amplitude value of the generated sine wave.

Returns
The amplitude value.

◆ getFrequency()

float switchboard::SineGeneratorNode::getFrequency ( ) const

Gets the current frequency value of the generated sine wave.

Returns
The frequency value in Hz.

◆ produce()

bool switchboard::SineGeneratorNode::produce ( AudioBus & bus)
overridevirtual

Produces audio data in the given bus.

Should be overridden by subclasses.

Parameters
busThe bus that should be filled with audio data.
Returns
True if audio was produced successfully, false otherwise.

Implements switchboard::SingleBusAudioSourceNode.

◆ setAmplitude()

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

Sets the amplitude of the generated sine wave.

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

◆ setBusFormat()

bool switchboard::SineGeneratorNode::setBusFormat ( AudioBusFormat & busFormat)
overridevirtual

Sets bus format.

Should be overridden by subclasses.

Parameters
busFormatThe bus format to set.
Returns
True if the bus format was set successfully, false otherwise.

Implements switchboard::SingleBusAudioSourceNode.

◆ setFrequency()

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

Sets the frequency of the generated sine wave.

Parameters
frequencyThe new frequency value in Hz.