fm.liveswitch.AudioBuffer Class Reference

An audio buffer. More...

Public Member Functions

void applyGain (double gain)
 Applies gain to this instance. More...
 
 AudioBuffer (fm.liveswitch.DataBuffer dataBuffer, fm.liveswitch.AudioFormat format)
 Initializes a new instance of the fm.liveswitch.AudioBuffer class. More...
 
 AudioBuffer (fm.liveswitch.DataBuffer[] dataBuffers, fm.liveswitch.AudioFormat format)
 Initializes a new instance of the fm.liveswitch.AudioBuffer class. More...
 
double calculateLevel ()
 Calculates the level of this instance. More...
 
fm.liveswitch.AudioBuffer clone ()
 Clones this instance. More...
 
double getGain ()
 Gets the gain. More...
 
boolean getGeneratedByPlc ()
 Gets a value indicating whether this buffer contains data generated by packet loss concealment (PLC). More...
 
boolean getIsDtmf ()
 Gets a value indicating whether this buffer has DTMF data. More...
 
boolean getIsL16 ()
 Gets a value indicating whether this buffer has L16 audio. More...
 
boolean getIsMuted ()
 Gets a value indicating whether this instance has been muted. More...
 
boolean getIsOpus ()
 Gets a value indicating whether this buffer has Opus audio. More...
 
boolean getIsPcm ()
 Gets a value indicating whether this buffer has raw PCM audio. More...
 
boolean getIsPcma ()
 Gets a value indicating whether this buffer has PCMA audio. More...
 
boolean getIsPcmu ()
 Gets a value indicating whether this buffer has PCMU audio. More...
 
boolean mute ()
 Mutes this instance. More...
 
void setGeneratedByPlc (boolean value)
 Sets a value indicating whether this buffer contains data generated by packet loss concealment (PLC). More...
 
String toJson ()
 Serializes this instance to JSON. More...
 
- Public Member Functions inherited from fm.liveswitch.Dynamic
java.util.HashMap< String, Object > getDynamicProperties ()
 Gets all dynamic properties on this instance. More...
 
Object getDynamicValue (String key)
 Gets a property value from the local cache. More...
 
void setDynamicValue (String key, Object value)
 Sets a property value in the local cache. More...
 
boolean unsetDynamicValue (String key)
 Removes a property value from the local cache. More...
 

Static Public Member Functions

static fm.liveswitch.AudioBuffer createSilence (int duration, int clockRate, int channelCount)
 Creates a silent audio buffer with the specified duration, clock rate, and channel count. More...
 
static fm.liveswitch.AudioBuffer createSilence (int duration, fm.liveswitch.AudioConfig config)
 Creates a silent audio buffer with the specified duration and configuration. More...
 
static fm.liveswitch.AudioBuffer createSound (long timestamp, int duration, int clockRate, int channelCount)
 Creates an audio buffer with the specified duration, clock rate, and channel count, a frequency of 440Hz, and an amplitude of 16,384. More...
 
static fm.liveswitch.AudioBuffer createSound (long timestamp, int duration, int clockRate, int channelCount, float frequency)
 Creates a silent audio buffer with the specified duration, clock rate, channel count, and frequency, and an amplitude of 16,384. More...
 
static fm.liveswitch.AudioBuffer createSound (long timestamp, int duration, int clockRate, int channelCount, float frequency, int amplitude)
 Creates a silent audio buffer with the specified duration, clock rate, channel count, frequency, and amplitude. More...
 
static fm.liveswitch.AudioBuffer createSound (long timestamp, int duration, fm.liveswitch.AudioConfig config)
 Creates an audio buffer with the specified duration and configuration, a frequency of 440Hz, and an amplitude of 16,384. More...
 
static fm.liveswitch.AudioBuffer createSound (long timestamp, int duration, fm.liveswitch.AudioConfig config, float frequency)
 Creates a silent audio buffer with the specified duration, configuration, and frequency, and an amplitude of 16,384. More...
 
static fm.liveswitch.AudioBuffer createSound (long timestamp, int duration, fm.liveswitch.AudioConfig config, float frequency, int amplitude)
 Creates a silent audio buffer with the specified duration, configuration, frequency, and amplitude. More...
 
static fm.liveswitch.AudioBuffer fromJson (String audioBufferJson)
 Deserializes an instance from JSON. More...
 
static fm.liveswitch.AudioBuffer[] fromJsonArray (String audioBuffersJson)
 Deserializes an array of instances from JSON. More...
 
static int getMinimumBufferLength (int duration, int clockRate, int channelCount)
 Gets the minimum data buffer length for a given duration, clock rate, and channel count. More...
 
static int getMinimumBufferLength (int duration, fm.liveswitch.AudioConfig config)
 Gets the minimum data buffer length for a given duration and configuration. More...
 
static String toJson (final fm.liveswitch.AudioBuffer audioBuffer)
 Serializes an instance to JSON. More...
 
static String toJsonArray (fm.liveswitch.AudioBuffer[] audioBuffers)
 Serializes an array of instances to JSON. More...
 

Protected Member Functions

 AudioBuffer ()
 Initializes a new instance of the fm.liveswitch.AudioBuffer class. More...
 
fm.liveswitch.AudioBuffer createInstance ()
 Creates a new instance. More...
 
- Protected Member Functions inherited from fm.liveswitch.Dynamic
 Dynamic ()
 
- Protected Member Functions inherited from fm.liveswitch.Serializable
boolean getIsDirty ()
 Gets a value indicating whether this instance is dirty. More...
 
 Serializable ()
 Initializes a new instance of the fm.liveswitch.Serializable class. More...
 
void setIsDirty (boolean value)
 Sets a value indicating whether this instance is dirty. More...
 

Detailed Description

An audio buffer.

Constructor & Destructor Documentation

◆ AudioBuffer() [1/3]

fm.liveswitch.AudioBuffer.AudioBuffer ( )
protected

Initializes a new instance of the fm.liveswitch.AudioBuffer class.

◆ AudioBuffer() [2/3]

fm.liveswitch.AudioBuffer.AudioBuffer ( fm.liveswitch.DataBuffer  dataBuffer,
fm.liveswitch.AudioFormat  format 
)

Initializes a new instance of the fm.liveswitch.AudioBuffer class.

Parameters
dataBufferThe data buffer.
formatThe format.

◆ AudioBuffer() [3/3]

fm.liveswitch.AudioBuffer.AudioBuffer ( fm.liveswitch.DataBuffer[]  dataBuffers,
fm.liveswitch.AudioFormat  format 
)

Initializes a new instance of the fm.liveswitch.AudioBuffer class.

Parameters
dataBuffersThe data buffers.
formatThe format.

Member Function Documentation

◆ applyGain()

void fm.liveswitch.AudioBuffer.applyGain ( double  gain)

Applies gain to this instance.

Parameters
gainThe gain.

◆ calculateLevel()

double fm.liveswitch.AudioBuffer.calculateLevel ( )

Calculates the level of this instance.

◆ clone()

fm.liveswitch.AudioBuffer fm.liveswitch.AudioBuffer.clone ( )

Clones this instance.

◆ createInstance()

fm.liveswitch.AudioBuffer fm.liveswitch.AudioBuffer.createInstance ( )
protected

Creates a new instance.

Reimplemented in fm.liveswitch.PacketizedAudioBuffer.

◆ createSilence() [1/2]

static fm.liveswitch.AudioBuffer fm.liveswitch.AudioBuffer.createSilence ( int  duration,
fm.liveswitch.AudioConfig  config 
)
static

Creates a silent audio buffer with the specified duration and configuration.

Parameters
durationThe duration in milliseconds.
configThe configuration.

◆ createSilence() [2/2]

static fm.liveswitch.AudioBuffer fm.liveswitch.AudioBuffer.createSilence ( int  duration,
int  clockRate,
int  channelCount 
)
static

Creates a silent audio buffer with the specified duration, clock rate, and channel count.

Parameters
durationThe duration in milliseconds.
clockRateThe clock rate.
channelCountThe channel count.

◆ createSound() [1/6]

static fm.liveswitch.AudioBuffer fm.liveswitch.AudioBuffer.createSound ( long  timestamp,
int  duration,
fm.liveswitch.AudioConfig  config 
)
static

Creates an audio buffer with the specified duration and configuration, a frequency of 440Hz, and an amplitude of 16,384.

Parameters
timestampThe starting time of this buffer relative to the clock rate.
durationThe duration in milliseconds.
configThe configuration.

◆ createSound() [2/6]

static fm.liveswitch.AudioBuffer fm.liveswitch.AudioBuffer.createSound ( long  timestamp,
int  duration,
fm.liveswitch.AudioConfig  config,
float  frequency 
)
static

Creates a silent audio buffer with the specified duration, configuration, and frequency, and an amplitude of 16,384.

Parameters
timestampThe starting time of this buffer relative to the clock rate.
durationThe duration in milliseconds.
configThe configuration.
frequencyThe frequency.

◆ createSound() [3/6]

static fm.liveswitch.AudioBuffer fm.liveswitch.AudioBuffer.createSound ( long  timestamp,
int  duration,
fm.liveswitch.AudioConfig  config,
float  frequency,
int  amplitude 
)
static

Creates a silent audio buffer with the specified duration, configuration, frequency, and amplitude.

Parameters
timestampThe starting time of this buffer relative to the clock rate.
durationThe duration in milliseconds.
configThe configuration.
frequencyThe frequency.
amplitudeThe amplitude.

◆ createSound() [4/6]

static fm.liveswitch.AudioBuffer fm.liveswitch.AudioBuffer.createSound ( long  timestamp,
int  duration,
int  clockRate,
int  channelCount 
)
static

Creates an audio buffer with the specified duration, clock rate, and channel count, a frequency of 440Hz, and an amplitude of 16,384.

Parameters
timestampThe starting time of this buffer relative to the clock rate.
durationThe duration in milliseconds.
clockRateThe clock rate.
channelCountThe channel count.

◆ createSound() [5/6]

static fm.liveswitch.AudioBuffer fm.liveswitch.AudioBuffer.createSound ( long  timestamp,
int  duration,
int  clockRate,
int  channelCount,
float  frequency 
)
static

Creates a silent audio buffer with the specified duration, clock rate, channel count, and frequency, and an amplitude of 16,384.

Parameters
timestampThe starting time of this buffer relative to the clock rate.
durationThe duration in milliseconds.
clockRateThe clock rate.
channelCountThe channel count.
frequencyThe frequency.

◆ createSound() [6/6]

static fm.liveswitch.AudioBuffer fm.liveswitch.AudioBuffer.createSound ( long  timestamp,
int  duration,
int  clockRate,
int  channelCount,
float  frequency,
int  amplitude 
)
static

Creates a silent audio buffer with the specified duration, clock rate, channel count, frequency, and amplitude.

Parameters
timestampThe starting time of this buffer relative to the clock rate.
durationThe duration in milliseconds.
clockRateThe clock rate.
channelCountThe channel count.
frequencyThe frequency.
amplitudeThe amplitude.

◆ fromJson()

static fm.liveswitch.AudioBuffer fm.liveswitch.AudioBuffer.fromJson ( String  audioBufferJson)
static

Deserializes an instance from JSON.

Parameters
audioBufferJsonThe audio buffer JSON.

◆ fromJsonArray()

static fm.liveswitch.AudioBuffer [] fm.liveswitch.AudioBuffer.fromJsonArray ( String  audioBuffersJson)
static

Deserializes an array of instances from JSON.

Parameters
audioBuffersJsonThe audio buffers JSON.

◆ getGain()

double fm.liveswitch.AudioBuffer.getGain ( )

Gets the gain.

◆ getGeneratedByPlc()

boolean fm.liveswitch.AudioBuffer.getGeneratedByPlc ( )

Gets a value indicating whether this buffer contains data generated by packet loss concealment (PLC).

◆ getIsDtmf()

boolean fm.liveswitch.AudioBuffer.getIsDtmf ( )

Gets a value indicating whether this buffer has DTMF data.

◆ getIsL16()

boolean fm.liveswitch.AudioBuffer.getIsL16 ( )

Gets a value indicating whether this buffer has L16 audio.

◆ getIsMuted()

boolean fm.liveswitch.AudioBuffer.getIsMuted ( )

Gets a value indicating whether this instance has been muted.

◆ getIsOpus()

boolean fm.liveswitch.AudioBuffer.getIsOpus ( )

Gets a value indicating whether this buffer has Opus audio.

◆ getIsPcm()

boolean fm.liveswitch.AudioBuffer.getIsPcm ( )

Gets a value indicating whether this buffer has raw PCM audio.

◆ getIsPcma()

boolean fm.liveswitch.AudioBuffer.getIsPcma ( )

Gets a value indicating whether this buffer has PCMA audio.

◆ getIsPcmu()

boolean fm.liveswitch.AudioBuffer.getIsPcmu ( )

Gets a value indicating whether this buffer has PCMU audio.

◆ getMinimumBufferLength() [1/2]

static int fm.liveswitch.AudioBuffer.getMinimumBufferLength ( int  duration,
fm.liveswitch.AudioConfig  config 
)
static

Gets the minimum data buffer length for a given duration and configuration.

Parameters
durationThe duration.
configThe configuration.

◆ getMinimumBufferLength() [2/2]

static int fm.liveswitch.AudioBuffer.getMinimumBufferLength ( int  duration,
int  clockRate,
int  channelCount 
)
static

Gets the minimum data buffer length for a given duration, clock rate, and channel count.

Parameters
durationThe duration.
clockRateThe clock rate.
channelCountThe channel count.

◆ mute()

boolean fm.liveswitch.AudioBuffer.mute ( )

Mutes this instance.

This is a one-way operation that clears the underlying data buffer.

◆ setGeneratedByPlc()

void fm.liveswitch.AudioBuffer.setGeneratedByPlc ( boolean  value)

Sets a value indicating whether this buffer contains data generated by packet loss concealment (PLC).

◆ toJson() [1/2]

String fm.liveswitch.AudioBuffer.toJson ( )

Serializes this instance to JSON.

◆ toJson() [2/2]

static String fm.liveswitch.AudioBuffer.toJson ( final fm.liveswitch.AudioBuffer  audioBuffer)
static

Serializes an instance to JSON.

Parameters
audioBufferThe audio buffer.

◆ toJsonArray()

static String fm.liveswitch.AudioBuffer.toJsonArray ( fm.liveswitch.AudioBuffer[]  audioBuffers)
static

Serializes an array of instances to JSON.

Parameters
audioBuffersThe audio buffers.