Difference between revisions of "love.audio.setEffect"

(add parent)
m (tweak examples for clarity)
Line 90: Line 90:
 
=== Playing music with added reverb ===
 
=== Playing music with added reverb ===
 
<source lang="lua">
 
<source lang="lua">
love.audio.setEffect('effect', {type = 'reverb'})
+
love.audio.setEffect('myEffect', {type = 'reverb'})
 
local source = love.audio.newSource('music.ogg', 'stream')
 
local source = love.audio.newSource('music.ogg', 'stream')
source:setEffect 'effect'
+
source:setEffect('myEffect')
 
source:play()
 
source:play()
 
</source>
 
</source>
Line 98: Line 98:
 
=== Playing music with distortion ===
 
=== Playing music with distortion ===
 
<source lang="lua">
 
<source lang="lua">
love.audio.setEffect('effect', {
+
love.audio.setEffect('myEffect', {
 
type = 'distortion',
 
type = 'distortion',
 
gain = .5,
 
gain = .5,
Line 104: Line 104:
 
})
 
})
 
local source = love.audio.newSource('music.ogg', 'stream')
 
local source = love.audio.newSource('music.ogg', 'stream')
source:setEffect 'effect'
+
source:setEffect('myEffect')
 
source:play()
 
source:play()
 
</source>
 
</source>

Revision as of 05:26, 20 October 2018

Available since LÖVE 11.0
This function is not supported in earlier versions.

Defines an effect that can be applied to a Source.

Function

Synopsis

love.audio.setEffect(name, settings)

Arguments

string name
The name of the effect.
table settings
The settings to use for this effect, with the following fields:
string type
The type of effect to use.
number volume
The volume of the effect.
number ...
Effect-specific settings (listed below).

Returns

boolean success
Whether the effect was successfully created.

Available effects and corresponding settings

reverb

number gain
number highgain
number density
number diffusion
number decaytime
number decayhighratio
number earlygain
number earlydelay
number lategain
number latedelay
number roomrolloff
number airabsorption
number highlimit

chorus

string waveform
number phase
number rate
number depth
number feedback
number delay

distortion

number gain
number edge
number lowcut
number center
number bandwidth

echo

number delay
number tapdelay
number damping
number feedback
number spread

flanger

string waveform
number phase
number rate
number depth
number feedback
number delay

ringmodulator

string waveform
number frequency
number highcut

compressor

boolean enable

equalizer

number lowgain
number lowcut
number lowmidgain
number lowmidfrequency
number lowmidbandwidth
number highmidgain
number highmidfrequency
number highmidbandwidth
number highgain
number highcut

Examples

Playing music with added reverb

love.audio.setEffect('myEffect', {type = 'reverb'})
local source = love.audio.newSource('music.ogg', 'stream')
source:setEffect('myEffect')
source:play()

Playing music with distortion

love.audio.setEffect('myEffect', {
	type = 'distortion',
	gain = .5,
	edge = .25,
})
local source = love.audio.newSource('music.ogg', 'stream')
source:setEffect('myEffect')
source:play()

See Also