Difference between revisions of "User:Zorg/Manual:Audio/1"
(→Introduction: Added some more text.) |
|||
Line 8: | Line 8: | ||
It's everything regarding sound, a game's background music, ambience, effects, voice acting. | It's everything regarding sound, a game's background music, ambience, effects, voice acting. | ||
+ | |||
+ | Most released games that had any amount of work put into them have audio in one way or another, with the two exceptions being art-games that have no audio for some philosophical reason, or really old pong-era games where there wasn't a way to have it. | ||
== How does LÖVE do it? == | == How does LÖVE do it? == |
Revision as of 16:25, 11 November 2016
Contents
Sound - Basics
Introduction
So, what's audio?
It's everything regarding sound, a game's background music, ambience, effects, voice acting.
Most released games that had any amount of work put into them have audio in one way or another, with the two exceptions being art-games that have no audio for some philosophical reason, or really old pong-era games where there wasn't a way to have it.
How does LÖVE do it?
Löve has two namespaces for sound related objects and methods. love.sound and love.audio.
To understand what's happening, consult the image to the right.
SoundData
are objects that contain individual sound samples. Either short sounds or they can hold even long tracks as well, though they would use a lot of RAM, since they are decoded into samplepoints.
Examples
Our vocal player
Insert baker Sven joke here...
local source = love.audio.newSource('sound.ogg')
Now that we have a source we'll want to play the sound. Thankfully, there's a function called Source:play() which does just that.
source:play()
(Insert humor here). When play() is called, the sound will continue to play until it reaches the end of the sound. You only have to call play once, to start it.