Type Function Library audio.* Return value none Revision Release 2022.3683 Keywords audio, dispose See also audio.loadSound() audio.loadStream()
Releases audio memory associated with a handle.
You must not use the handle once the memory is freed. The audio should not be active
audio.dispose( audioHandle )
The handle returned by audio.loadSound() and audio.loadStream() that you want to release.
-- Load a laser sound and a background music stream into memory local laserSound = audio.loadSound( "laserSound.wav" ) local backgroundMusic = audio.loadStream( "backgroundMusic.m4a" ) -- Play both the sound and the stream local playLaserSound = audio.play( laserSound ) local playBackgroundMusic = audio.play( backgroundMusic ) -- Stop both the sound and the stream and 'nil' out each reference audio.stop( playLaserSound ) playLaserSound = nil audio.stop( playBackgroundMusic ) playBackgroundMusic = nil -- Dispose the handles from memory and 'nil' out each reference audio.dispose( laserSound ) audio.dispose( backgroundMusic ) laserSound = nil --prevents the handle from being used again backgroundMusic = nil --prevents the handle from being used again