Class StreamedAudioSource
Plays back the streaming audio provided to it. Automatically adjusts to any changing sampling frequency or channel count. Samples of varying lengths can be sent, however this could impact performance. Consider keeping sample length constant.
Inheritance
Namespace: Adrenak.UniMic
Assembly: cs.temp.dll.dll
Syntax
public class StreamedAudioSource : MonoBehaviour
Constructors
StreamedAudioSource()
Declaration
[Obsolete("new not allowed. Use StreamedAudioSource.New", true)]
public StreamedAudioSource()
Properties
BufferDurationMS
Declaration
[Obsolete("Use BufferFactor instead. This property may be removed soon")]
public int BufferDurationMS { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
BufferFactor
Determines the duration of the internal buffer. DEFAULT = 32 This value determines the length of the internal AudioClip which is = last sample count (fed in the Feed method) x this value. There's usually no reason to change this. A high value like 32 will take some more memory but will ensure audio jitters are minimal.
Declaration
public int BufferFactor { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
Buffering
Declaration
[Obsolete("This property has been deprecated and is equivalent to IsPlaying from v3.2.0 onwards.It may be removed soon.")]
public bool Buffering { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
ChannelCount
The channel count in the last samples this instance played
Declaration
public int ChannelCount { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
FrameCountForPlay
The number of frames that must be received before playback starts. Note that setting this value to 1 will cause playing to begin right after receiving the first audio data, which can lead to playback being jittery. A value of 2 or 3 is generally ideal. Also note that higher values will lead to increased delay in playback starting.
Declaration
public int FrameCountForPlay { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
IsBuffering
Declaration
[Obsolete("This property has been deprecated and is equivalent to IsPlaying from v3.2.0 onwards.It may be removed soon.")]
public bool IsBuffering { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsPlaying
Whether this instance is currently playing
Declaration
public bool IsPlaying { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
SamplingFrequency
The sampling frequency of the last samples this instance played
Declaration
public int SamplingFrequency { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
UnityAudioSource
Provides access to the AudioSource used for playing the audio.
WARNING Do not invoke play or pause methods on this object.
The play, pause and unpausing of this
If you want to start or stop playback, use Play() or Stop() methods on this object directly.
Declaration
public AudioSource UnityAudioSource { get; }
Property Value
Type | Description |
---|---|
AudioSource |
Methods
Feed(Int32, Int32, Single[], Boolean)
Feed audio data for playback
Declaration
public void Feed(int frequency, int channels, float[] samples, bool autoPlayWhenReady = true)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | frequency | The sampling frequency of the audio |
System.Int32 | channels | The number of channels in the audio |
System.Single[] | samples | The PCM samples of the audio |
System.Boolean | autoPlayWhenReady |
New()
Declaration
public static StreamedAudioSource New()
Returns
Type | Description |
---|---|
StreamedAudioSource |
Play()
Start/resume the playback
Declaration
public void Play()
Stop()
Stop/pause the playback
Declaration
public void Stop()