Audio glitchy and memory leak?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
LordAndrew
Prole
Posts: 2
Joined: Sat Dec 28, 2013 12:08 pm

Audio glitchy and memory leak?

Post by LordAndrew »

I'm experiencing a weird problem with the audio module of LÖVE. No matter what song I play--regardless of its format--is played in a very glitchy manner (the song stutters and sounds very robotic). LÖVE's memory usage also skyrockets and the program ends up crashing from using up too much memory.

I've tested this on both versions 0.8.0 and 0.9.0 (both clean installs). In one test case I installed LÖVE and in the other I just used the zipped version, but the issue still persists. I have no idea what could be causing this and I'm at a loss. Is there some kind of issue I'm not seeing?
User avatar
slime
Solid Snayke
Posts: 3163
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Audio glitchy and memory leak?

Post by slime »

What's the code you're using to test?
LordAndrew
Prole
Posts: 2
Joined: Sat Dec 28, 2013 12:08 pm

Re: Audio glitchy and memory leak?

Post by LordAndrew »

slime wrote:What's the code you're using to test?
It looks like I done goofed. It just hit me why it's happening:

Code: Select all

-- The code I was using.
function love.draw()
  s = love.audio.newSource("test.mp3")
  s:play()
end
Playing a song every tick is probably not a good idea, haha. My bad.
User avatar
slime
Solid Snayke
Posts: 3163
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Audio glitchy and memory leak?

Post by slime »

The Source:play() call isn't what's causing the memory issues (although it's generally good to avoid calling that when you don't actually want a Source to start playing.) It's the love.audio.newSource call, which loads a completely unique new Source every time it's called. :)
User avatar
qubodup
Inner party member
Posts: 775
Joined: Sat Jun 21, 2008 9:21 pm
Location: Berlin, Germany
Contact:

Re: Audio glitchy and memory leak?

Post by qubodup »

slime wrote:The Source:play() call isn't what's causing the memory issues (although it's generally good to avoid calling that when you don't actually want a Source to start playing.) It's the love.audio.newSource call, which loads a completely unique new Source every time it's called. :)
Clarification: put the love.audio.newSource() line into love.load(). love.draw() gets executed all the time.

Actually you might want to put the :play() line into love.load() for testing as well, unless you want it to repeat all the time.
lg.newImage("cat.png") -- made possible by lg = love.graphics
-- Don't force fullscreen (it frustrates those who want to try your game real quick) -- Develop for 1280x720 (so people can make HD videos)
User avatar
slime
Solid Snayke
Posts: 3163
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Audio glitchy and memory leak?

Post by slime »

qubodup wrote:Actually you might want to put the :play() line into love.load() for testing as well, unless you want it to repeat all the time.
If you want it to repeat then you should call Source:setLooping(true) once, and call Source:play() when you want it to start the first time (or if it's paused or stopped at some point and you want to unpause or restart.)

Think of it like music player GUI controls, you click a repeat button and click play, and leave it until you want to change things.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Audio glitchy and memory leak?

Post by bartbes »

You don't mash the play button? :crazy:
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 11 guests