Technology Demo

2D Audio Demo

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Spot for images


This demo will show you how to play 2D sound in Luster.

Luster Audio Plugin

In order to even play a sound, you have to load Luster's audio plugin. To do this, go to the XML file of your project. At the bottom of the XML page will be a component that says "Plugin Dependencies." Click the "Add" option, and select Now you will be able to use any of the features of Luster's audio system.

Playing Sound

You can get your source sound from various places. It can be part of the project, though this is only recommended for smaller files, not songs. You can also stream files from your computer or from the internet. We'll start with a sound that is loaded into the project.

Create a new folder called "Songs" and import a song to it. It can be an .mp3, .ogg, .wma, .midi or many other file types. From here, we need to create a system for our audio, which is done as shown in the code below.

-- Start the system
self.system =

To create a sound resource, we need to enter the next line of code.

-- Create a sound resource
self.sound = self.system:createSound("Songs/test.mp3", false)

Now, whenever we want our sound to play, we need to create an instance of the sound resource and tell it to play.

-- Create an instance of the sound
self.soundInst = self.sound:createInstance()

This can be connected to an event, for example, so that when something on the stage is clicked, a sound effect plays.

Streaming a Sound

You can stream a sound from the internet, if you know the URL, or from the user's computer. To use a streaming sound, simply change this line of code

self.sound = self.system:createSound("Songs/test.mp3", false)

to these.

local url ="")
self.sound = self.system:createStream(url, false, true)

If you want to use a file located outside of the l3d project but on your computer, simply substitute the website name for the URL of the file. The syntax for using a file on the computer would look like this:

local url ="file:///Users/Fenris/Music/HME.mp3")