lovr.data.newAudioStream
Creates a new AudioStream. AudioStream has two modes:
- Constructed with a filename or blob, AudioStream will decode the given file on demand. Right
now, the only supported audio format is Ogg Vorbis (.ogg).
- Constructed without, it's a "raw" audiostream that you append data to in real-time. See
AudioStream:append
for usage.
Create an AudioStream
decoding ogg audio from the file at filename
.
audioStream = lovr.data.newAudioStream(filename, bufferSize)
Arguments
Name | Type | Default | Description |
filename | string | | The filename of the audio file to load.
|
bufferSize | number | 4096 | The size of the stream's audio buffer, in samples.
|
Returns
Name | Type | Description |
audioStream | AudioStream | The new AudioStream.
|
Create an AudioStream
decoding ogg audio from the given Blob.
audioStream = lovr.data.newAudioStream(blob, bufferSize)
Arguments
Name | Type | Default | Description |
blob | Blob | | The Blob containing audio data to decode.
|
bufferSize | number | 4096 | The size of the stream's audio buffer, in samples.
|
Returns
Name | Type | Description |
audioStream | AudioStream | The new AudioStream.
|
Create a raw AudioStream
. You must call append
to give it audio to stream later.
audioStream = lovr.data.newAudioStream(channelCount, sampleRate, bufferSize, queueLimit)
Arguments
Name | Type | Default | Description |
channelCount | number | | Number of audio channels (1 for mono or 2 for stereo).
|
sampleRate | number | | The resolution of the stream, in samples per second (examples of common values: 44100, 48000, 16000).
|
bufferSize | number | 4096 | The size of the stream's audio buffer, in samples.
|
queueLimit | number | sampleRate * 0.5 | The maximum number of audio samples that this AudioStream will queue. The default is half a second worth of data. Set to 0 for no limit (but be careful not to use too much RAM).
|
Returns
Name | Type | Description |
audioStream | AudioStream | The new AudioStream.
|
See also