audio.loadStream()

Description:

Loads (opens) a file to be read as a stream. Streamed files are read in little chunks at a time to minimize memory use. These are intended for large/long files like background music and speech. Unlike files loaded with audio.loadSound(), these cannot be shared simultaneously across multiple channels. If you need to play multiple simulataneous instances of the same file, you must load multiple instances of the file.

Syntax:

1
audio.loadStream( audioFileName [, baseDir ]  )

Example:

backgroundMusic = audio.loadStream("backgroundMusic.m4a")
narrationSpeech = audio.loadStream("narrationSpeech.wav")

Parameters:

audiofileName
String: Specifies the name of the audio file you want to load. Supported file formats are determined by the platform you are running on.

baseDir
By default sound files are expected to be in the application resources directory. If the sound file is in the application documents directory, use system.DocumentsDirectory.

Returns:

A handle to a sound file.

Remarks:

Please note that you are responsible for unloading (cleaning up) any audio files you load with this API. Use the audio.dispose() API to clean up audio handles you are completely done with them and want to unload from memory to get back more RAM.

In many usage cases, you may want to use the audio file for the entire program in which case you do not need to worry about disposing of the resource.

Also note that streamed files may have slightly higher latency costs than files loaded with audio.loadSound(). They also may have slightly higher runtime (CPU) cost to play than files loaded with audio.loadSound().

Audio formats supported are determined by the platform you are running on. But note that the same formats are supported between audio.loadSound() and audio.loadStream(). Also, please be aware that on some platforms and devices, hardware decoding is available for certain formats (e.g. iOS and AAC). However, only one file at a time may use the hardware decoder, in which case a software fallback is used. If you are trying to play multiple streaming sources simultaneously, you need to be prepared for the possibility of overtaxing your CPU because you are doing too much software-based on-the-fly audio decoding. Using simple formats like WAV or IMA4 do not tax the CPU hard.

Supported on operating systems and platforms for build numbers shown:
  • Mac OS X:
    Build 2011.222
  • Windows:
    Build 2011.222
  • iOS:
    Build 2011.222
  • Android:
    Build 2011.222

Replies

magnp01
User offline. Last seen 9 years 34 weeks ago. Offline
Joined: 29 Nov 2010

corona is easy to work with, but for some reason I can;t do the simplest tutorial
because I can;t find where to open a folder and save the file in.

Shaunathan
User offline. Last seen 9 years 14 weeks ago. Offline
Joined: 18 Jan 2011

mag, just make a folder anywhere, then save your main.lua there. This is now your game folder.