Reference loadSound()

loadSound()

loadSound() returns a new SoundFile from a specified path. If called during preload(), the SoundFile will be ready to play in time for setup() and draw(). If called outside of preload, the SoundFile will not be ready immediately, so loadSound accepts a callback as the second parameter. Using a local server is recommended when loading external files.

Examples

Syntax

loadSound(path)

Parameters

path
String|Array: Path to the sound file, or an array with paths to soundfiles in multiple formats i.e. ['sound.ogg', 'sound.mp3']. Alternately, accepts an object: either from the HTML5 File API, or a p5.File.

Returns

SoundFile: Returns a SoundFile
Notice any errors or typos? Please let us know. Please feel free to edit src/sources/SoundFile.js and open a pull request!

Related References