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

Generates a sine wave modulated by an ADSR envelope. More...

#include <SynthNode.hpp>

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

Public Member Functions

WASM SynthNode ()
 Creates a SynthNode 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 void setAttackSeconds (float attackSeconds)
 Sets the attack time of the generated envelope.
 
WASM float getAttackSeconds () const
 Gets the current attack time of the generated envelope.
 
WASM void setDecaySeconds (float decaySeconds)
 Sets the decay time of the generated envelope.
 
WASM float getDecaySeconds () const
 Gets the current decay time of the generated envelope.
 
WASM void setReleaseSeconds (float releaseSeconds)
 Sets the release time of the generated envelope.
 
WASM float getReleaseSeconds () const
 Gets the current release time of the generated envelope.
 
WASM void setPeakLevel (float peakLevel)
 Sets the peak level of the generated envelope (the level reached by attack).
 
WASM float getPeakLevel () const
 Gets the current peak level of the generated envelope (the level reached by attack).
 
WASM void setSustainLevel (float sustainLevel)
 Sets the sustain level of the generated envelope.
 
WASM float getSustainLevel () const
 Gets the current sustain level of the generated envelope.
 
WASM void trigger ()
 Trigger the synth.
 
WASM void release ()
 Release the synth.
 
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 modulated by an ADSR envelope.

SynthNode class.

Member Function Documentation

◆ getAttackSeconds()

float switchboard::SynthNode::getAttackSeconds ( ) const

Gets the current attack time of the generated envelope.

Returns
The attack time in seconds.

◆ getDecaySeconds()

float switchboard::SynthNode::getDecaySeconds ( ) const

Gets the current decay time of the generated envelope.

Returns
The decay time in seconds.

◆ getFrequency()

float switchboard::SynthNode::getFrequency ( ) const

Gets the current frequency value of the generated sine wave.

Returns
The frequency value in Hz.

◆ getPeakLevel()

float switchboard::SynthNode::getPeakLevel ( ) const

Gets the current peak level of the generated envelope (the level reached by attack).

Returns
The peak level in the range of 0.0..1.0.

◆ getReleaseSeconds()

float switchboard::SynthNode::getReleaseSeconds ( ) const

Gets the current release time of the generated envelope.

Returns
The release time in seconds.

◆ getSustainLevel()

float switchboard::SynthNode::getSustainLevel ( ) const

Gets the current sustain level of the generated envelope.

Returns
The sustain level in the range of 0.0..1.0.

◆ produce()

bool switchboard::SynthNode::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.

◆ release()

void switchboard::SynthNode::release ( )

Release the synth.

The generator will stop generating sound.

◆ setAttackSeconds()

void switchboard::SynthNode::setAttackSeconds ( float attackSeconds)

Sets the attack time of the generated envelope.

Parameters
attackSecondsThe new attack time value in seconds.

◆ setBusFormat()

bool switchboard::SynthNode::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.

◆ setDecaySeconds()

void switchboard::SynthNode::setDecaySeconds ( float decaySeconds)

Sets the decay time of the generated envelope.

Parameters
decaySecondsThe new decay time value in seconds.

◆ setFrequency()

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

Sets the frequency of the generated sine wave.

Parameters
frequencyThe new frequency value in Hz.

◆ setPeakLevel()

void switchboard::SynthNode::setPeakLevel ( float peakLevel)

Sets the peak level of the generated envelope (the level reached by attack).

Parameters
peakLevelThe new peak level value in the range of 0.0..1.0.

◆ setReleaseSeconds()

void switchboard::SynthNode::setReleaseSeconds ( float releaseSeconds)

Sets the release time of the generated envelope.

Parameters
releaseSecondsThe new release time value in seconds.

◆ setSustainLevel()

void switchboard::SynthNode::setSustainLevel ( float sustainLevel)

Sets the sustain level of the generated envelope.

Parameters
sustainLevelThe new sustain level value in the range of 0.0..1.0.

◆ trigger()

void switchboard::SynthNode::trigger ( )

Trigger the synth.

The synth will start to generate sound.