Switchboard SDK
|
AudioNode that plays the loaded audio file. More...
#include <AudioPlayerNode.hpp>
Public Member Functions | |
WASM | AudioPlayerNode () |
Creates a AudioPlayerNode instance. | |
WASM | ~AudioPlayerNode () |
AudioPlayerNode destructor. | |
bool | load (const std::string &path, Codec format) |
Loads an entire audio file from the given path to the memory. Stops playback. | |
bool | load (const std::vector< uint8 > &inputData, Codec format) |
Loads encoded audio data. Stops playback. | |
WASM bool | load (AudioBuffer< float > &audioBuffer, bool copyData) |
Loads audio data from an AudioBuffer instance. | |
bool | stream (const std::string &path, Codec format) |
Starts streaming an audio file from the given path. Stops playback. | |
WASM void | play () |
Starts the audio playback. | |
WASM void | pause () |
Pauses the audio playback. | |
WASM void | stop () |
Stops the audio playback. | |
WASM bool | isPlaying () const |
Indicates whether the system is currently playing. | |
WASM bool | isLoopingEnabled () const |
Indicates whether looping of the audio file is enabled. | |
WASM uint | getNumberOfChannels () const |
Gets the number of channels that the audio node will output. Default: 2 (stereo) | |
WASM void | setNumberOfChannels (const uint numberOfChannels) |
Sets the number of channels that the audio node will output. | |
WASM uint | getSourceSampleRate () const |
Gets the sample rate of the current audio source. SAMPLE_RATE_UNDEFINED is returned if there is none. | |
WASM uint | getSourceNumberOfChannels () const |
Gets the number of channels of the current audio source. NUM_CHANNELS_UNDEFINED is returned if there is none. | |
WASM void | setLoopingEnabled (bool loopingEnabled) |
Indicates whether looping of the audio file is enabled. | |
WASM double | getPosition () const |
WASM double | getDuration () const |
WASM void | setPosition (double position) |
double | getStartPosition () const |
void | setStartPosition (double startPosition) |
double | getEndPosition () const |
void | setEndPosition (double endPosition) |
bool | setBusFormat (AudioBusFormat &busFormat) override |
Sets bus format. | |
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::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 Parameter * | getParameter (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 |
AudioNode that plays the loaded audio file.
AudioPlayerNode class.
double switchboard::AudioPlayerNode::getDuration | ( | ) | const |
The duration of the currently playing media.
double switchboard::AudioPlayerNode::getEndPosition | ( | ) | const |
Indicates the current end position of the playback.
uint switchboard::AudioPlayerNode::getNumberOfChannels | ( | ) | const |
Gets the number of channels that the audio node will output. Default: 2 (stereo)
double switchboard::AudioPlayerNode::getPosition | ( | ) | const |
Indicates the current position of the playback head.
uint switchboard::AudioPlayerNode::getSourceNumberOfChannels | ( | ) | const |
Gets the number of channels of the current audio source. NUM_CHANNELS_UNDEFINED is returned if there is none.
uint switchboard::AudioPlayerNode::getSourceSampleRate | ( | ) | const |
Gets the sample rate of the current audio source. SAMPLE_RATE_UNDEFINED is returned if there is none.
double switchboard::AudioPlayerNode::getStartPosition | ( | ) | const |
Indicates the current start position of the playback.
bool switchboard::AudioPlayerNode::isLoopingEnabled | ( | ) | const |
Indicates whether looping of the audio file is enabled.
bool switchboard::AudioPlayerNode::isPlaying | ( | ) | const |
Indicates whether the system is currently playing.
bool switchboard::AudioPlayerNode::load | ( | AudioBuffer< float > & | audioBuffer, |
bool | copyData ) |
Loads audio data from an AudioBuffer instance.
audioBuffer | The audio buffer containing the audio data. |
copyData | When set to true, the audio data from the audio buffer will be copied and stored in the AudioPlayerNode instance. |
bool switchboard::AudioPlayerNode::load | ( | const std::string & | path, |
Codec | format ) |
Loads an entire audio file from the given path to the memory. Stops playback.
path | The path to the audio file to load. |
format | The audio recording format. |
bool switchboard::AudioPlayerNode::load | ( | const std::vector< uint8 > & | inputData, |
Codec | format ) |
Loads encoded audio data. Stops playback.
inputData | Vector containing the encoded audio data. |
format | The audio encoding format. |
|
overridevirtual |
Produces audio data in the given bus.
Should be overridden by subclasses.
bus | The bus that should be filled with audio data. |
Implements switchboard::SingleBusAudioSourceNode.
|
overridevirtual |
Sets bus format.
Should be overridden by subclasses.
busFormat | The bus format to set. |
Implements switchboard::SingleBusAudioSourceNode.
void switchboard::AudioPlayerNode::setEndPosition | ( | double | endPosition | ) |
Sets the ending position of the playback. Only takes effect after audio is loaded.
endPosition | The desired position in seconds. |
void switchboard::AudioPlayerNode::setLoopingEnabled | ( | bool | loopingEnabled | ) |
Indicates whether looping of the audio file is enabled.
loopingEnabled | True when it is enabled, false when it is not. |
void switchboard::AudioPlayerNode::setNumberOfChannels | ( | const uint | numberOfChannels | ) |
Sets the number of channels that the audio node will output.
numberOfChannels | The new number of channels setting. |
void switchboard::AudioPlayerNode::setPosition | ( | double | position | ) |
Sets the playback head to the desired position.
position | The desired position in seconds. |
void switchboard::AudioPlayerNode::setStartPosition | ( | double | startPosition | ) |
Sets the starting position of the playback. Only takes effect after audio is loaded.
startPosition | The desired position in seconds. |
bool switchboard::AudioPlayerNode::stream | ( | const std::string & | path, |
Codec | format ) |
Starts streaming an audio file from the given path. Stops playback.
Using this method, instead of load, is more memory efficient as it does not load the entire audio file to memory. However, seeking the audio might take longer.
path | The path to the audio file to stream. |
format | The audio recording format. |