API reference
API reference
Select your platform
No SDKs available
No versions available

BaseAudioClipStream Class

A simple abstract class that can be used to simplify the code required for a custom IAudioClipStream

Constructors

BaseAudioClipStream ( newChannels , newSampleRate , newStreamReadyLength )
The constructor that takes in a total channel & sample rate
Signature
Meta.Voice.Audio.BaseAudioClipStream.BaseAudioClipStream(int newChannels, int newSampleRate, float newStreamReadyLength=WitConstants.ENDPOINT_TTS_DEFAULT_READY_LENGTH)
Parameters
newChannels: int  The channels to be used for streaming
newSampleRate: int  The new sample rate
newStreamReadyLength: float  The minimum length in seconds required before the OnStreamReady method is called

Fields

Length : float
The length of the stream in seconds.
Signature
float Meta.Voice.Audio.BaseAudioClipStream.Length
TotalSamples : int
The maximum known total of samples currently in this stream.
Signature
int Meta.Voice.Audio.BaseAudioClipStream.TotalSamples

Properties

AddedSamples : int
[Get]
The total number of samples currently added to this stream.
Signature
int Meta.Voice.Audio.BaseAudioClipStream.AddedSamples
Channels : int
[Get]
The current number of channels in this audio data stream
Signature
int Meta.Voice.Audio.BaseAudioClipStream.Channels
ExpectedSamples : int
[Get]
The total number of samples expected from the stream. When streaming, this is not set until the stream is complete.
Signature
int Meta.Voice.Audio.BaseAudioClipStream.ExpectedSamples
IsComplete : bool
[Get]
Whether or not the stream has been completed
Signature
bool Meta.Voice.Audio.BaseAudioClipStream.IsComplete
IsReady : bool
[Get]
Whether or not the stream is ready for playback
Signature
bool Meta.Voice.Audio.BaseAudioClipStream.IsReady
OnAddSamples : AudioClipStreamSampleDelegate
[Get][Set]
The callback delegate for stream samples added.
Signature
AudioClipStreamSampleDelegate Meta.Voice.Audio.BaseAudioClipStream.OnAddSamples
OnStreamComplete : AudioClipStreamDelegate
[Get][Set]
The callback delegate for stream completion once SetContentLength is called & all samples have been added via the [AddSamples(float[] samples)](class_meta_1_1_voice_1_1_audio_1_1_base_audio_clip_stream_1a342c5da66d65e15170d1a70450ae6ea7) method.
Signature
AudioClipStreamDelegate Meta.Voice.Audio.BaseAudioClipStream.OnStreamComplete
OnStreamReady : AudioClipStreamDelegate
[Get][Set]
The callback delegate for stream completion once SetContentLength is called & all samples have been added via the [AddSamples(float[] samples)](class_meta_1_1_voice_1_1_audio_1_1_base_audio_clip_stream_1a342c5da66d65e15170d1a70450ae6ea7) method.
Signature
AudioClipStreamDelegate Meta.Voice.Audio.BaseAudioClipStream.OnStreamReady
OnStreamUnloaded : AudioClipStreamDelegate
[Get][Set]
The callback when the stream has unloaded all data
Signature
AudioClipStreamDelegate Meta.Voice.Audio.BaseAudioClipStream.OnStreamUnloaded
OnStreamUpdated : AudioClipStreamDelegate
[Get][Set]
The callback delegate for stream update if any additional data such as the AudioClip is expected to update mid stream. This can be set externally but should only be called within the clip stream itself.
Signature
AudioClipStreamDelegate Meta.Voice.Audio.BaseAudioClipStream.OnStreamUpdated
SampleRate : int
[Get]
A getter for the current sample rate of how many samples per second should be played
Signature
int Meta.Voice.Audio.BaseAudioClipStream.SampleRate
StreamReadyLength : float
[Get]
A getter for the minimum length in seconds required before the OnStreamReady method is called
Signature
float Meta.Voice.Audio.BaseAudioClipStream.StreamReadyLength

Protected Methods

HandleStreamUpdated ()
Perform on stream update following ready
Signature
virtual void Meta.Voice.Audio.BaseAudioClipStream.HandleStreamUpdated()
Returns
void
IsEnoughBuffered ()
A check if the clip stream has buffered enough to be considered ready
Signature
virtual bool Meta.Voice.Audio.BaseAudioClipStream.IsEnoughBuffered()
Returns
bool
RaiseStreamComplete ()
Method that calls OnStreamComplete on the main thread
Signature
virtual void Meta.Voice.Audio.BaseAudioClipStream.RaiseStreamComplete()
Returns
void
RaiseStreamReady ()
Method that calls OnStreamReady on the main thread
Signature
virtual void Meta.Voice.Audio.BaseAudioClipStream.RaiseStreamReady()
Returns
void
RaiseStreamUpdated ()
Method that calls OnStreamUpdated on the main thread
Signature
virtual void Meta.Voice.Audio.BaseAudioClipStream.RaiseStreamUpdated()
Returns
void
Reset ()
Method for clearing all data
Signature
virtual void Meta.Voice.Audio.BaseAudioClipStream.Reset()
Returns
void

Methods

AddSamples ( samples )
Adds an array of samples to the current stream
Signature
void Meta.Voice.Audio.BaseAudioClipStream.AddSamples(float[] samples)
Parameters
samples: float []  A list of decoded floats from 0f to 1f
Returns
void
AddSamples ( samples , offset , length )
Adds an array of samples to the current stream
Signature
virtual void Meta.Voice.Audio.BaseAudioClipStream.AddSamples(float[] samples, int offset, int length)
Parameters
samples: float []  A list of decoded floats from 0f to 1f
offset: int  The index of samples to begin adding from
length: int  The total number of samples that should be appended
Returns
void
SetExpectedSamples ( expectedSamples )
Calls on occassions where the total samples are known. Either prior to a disk load or following a stream completion.
Signature
virtual void Meta.Voice.Audio.BaseAudioClipStream.SetExpectedSamples(int expectedSamples)
Parameters
expectedSamples: int  The final number of samples expected to be received
Returns
void
Unload ()
Called when clip stream should clear ram and ready for re-use
Signature
virtual void Meta.Voice.Audio.BaseAudioClipStream.Unload()
Returns
void
UpdateState ()
Calls to determine if completion method should be called
Signature
virtual void Meta.Voice.Audio.BaseAudioClipStream.UpdateState()
Returns
void

Static Methods

GetLength ( totalSamples , channels , samplesPerSecond )
Calculates length in seconds based on total samples, channels & samples per second
Signature
static float Meta.Voice.Audio.BaseAudioClipStream.GetLength(int totalSamples, int channels, int samplesPerSecond)
Parameters
totalSamples: int
channels: int
samplesPerSecond: int
Returns
float