I can't seem to find a way to do this properly without frequent audio glitches.
Currently what I'm doing is tweening a volume variable from 0-1 and assigning it to my audio every update. Unfortunately this sporadically causes some unwanted noise (http://vocaroo.com/i/s0ZvMDfwY1BO).
What are some other ways I can smoothly increment/decrement volume? Should I just do it manually?
EDIT: Turns out this is an issue with TESound, the audio library I'm using. Apparently something about its volume function doesn't agree with being called every update.
Audio fade in/out?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 5
- Joined: Sat Jan 17, 2015 3:19 am
Re: Audio fade in/out?
Couldn't you put some kind of timer on it where the volume increasing function is only called when a timer reaches 0? You could probably do it with faster speeds like dt.
Completely untested but my idea:
I'm going to test it in a few.
Completely untested but my idea:
Code: Select all
function increase_volume(dt,rate)
audioSrc:setVolume(audiosrc:getVolume()+rate*dt
end
function love.update(dt)
local timer = 1
if timer > 0 then
timer = timer-1
elseif timer < 0 then
increase_volume(dt,rate)
timer = 1
end
end
Re: Audio fade in/out?
I've decided to work around it by just using love.audio instead of TESound for atmospheric effects, which works perfectly.
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot], Semrush [Bot] and 8 guests