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

Analyzes the audio and returns the RMS power of the signal per buffer. It only accepts mono buffers. More...

#include <VUMeterNode.hpp>

Inheritance diagram for switchboard::VUMeterNode:
switchboard::SingleBusAudioSinkNode switchboard::AudioSinkNode switchboard::AudioNode

Public Member Functions

 WASM_EXPORT (VUMeterNode)
 
WASM VUMeterNode ()
 Creates a VUMeterNode instance.
 
WASM ~VUMeterNode ()
 VUMeterNode destructor.
 
WASM void setSmoothingDurationMs (const float smoothingDurationMs)
 Set the window duration on which to average the current levels.
 
WASM const float getSmoothingDurationMs () const
 Returns the window duration on which to average the current levels.
 
WASM const float getLevel () const
 Returns the last buffers RMS value as amplitude.
 
WASM const float getLevelDBFS () const
 Returns the last buffers RMS value as dBFS.
 
WASM const float getPeak () const
 Returns the last buffers peak value as amplitude.
 
WASM const float getPeakDBFS () const
 Returns the last buffers peak value as dBFS.
 
WASM bool setBusFormat (AudioBusFormat &busFormat) override
 Sets bus format.
 
WASM bool consume (AudioBus &bus) override
 Consumes audio data from the given bus.
 
- Public Member Functions inherited from switchboard::SingleBusAudioSinkNode
bool setNumberOfBuses (const uint numberOfBuses) override
 Sets number of buses.
 
bool setBusFormats (AudioBusFormatList &busFormats) override
 Sets bus formats.
 
bool consume (AudioBusList &buses) override
 Consumes audio data from the given buses.
 
- 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 &name)
 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 Attributes inherited from switchboard::AudioNode
std::string type
 
std::vector< std::unique_ptr< Parameter > > parameters
 

Detailed Description

Analyzes the audio and returns the RMS power of the signal per buffer. It only accepts mono buffers.

VUMeterNode class

Member Function Documentation

◆ consume()

bool switchboard::VUMeterNode::consume ( AudioBus & bus)
overridevirtual

Consumes audio data from the given bus.

Should be overridden by subclasses.

Parameters
busThe bus that contain the audio data.
Returns
True if audio was consumed successfully, false otherwise.

Implements switchboard::SingleBusAudioSinkNode.

◆ getLevel()

const float switchboard::VUMeterNode::getLevel ( ) const

Returns the last buffers RMS value as amplitude.

Returns
The last buffers RMS value as amplitude.

◆ getLevelDBFS()

const float switchboard::VUMeterNode::getLevelDBFS ( ) const

Returns the last buffers RMS value as dBFS.

Returns
The last buffers RMS value as dBFS.

◆ getPeak()

const float switchboard::VUMeterNode::getPeak ( ) const

Returns the last buffers peak value as amplitude.

Returns
The last buffers peak value as amplitude.

◆ getPeakDBFS()

const float switchboard::VUMeterNode::getPeakDBFS ( ) const

Returns the last buffers peak value as dBFS.

Returns
The last buffers peak value as dBFS.

◆ getSmoothingDurationMs()

const float switchboard::VUMeterNode::getSmoothingDurationMs ( ) const

Returns the window duration on which to average the current levels.

Returns
The window on which to average the current levels in milliseconds.

◆ setBusFormat()

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

◆ setSmoothingDurationMs()

void switchboard::VUMeterNode::setSmoothingDurationMs ( const float smoothingDurationMs)

Set the window duration on which to average the current levels.

This method is not safe to call while the node is running (the nodes consume method is being called).

This method sets the preferred duration but the actual duration will depend on the current sample rate and number of frames.

It will be chosen to be as close to the preferred as it can be.

Parameters
smoothingDurationMsWindow duration on which to average the current levels.