Sounds don't play, but only sometimes

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
User avatar
Benamas
Prole
Posts: 28
Joined: Wed Apr 14, 2010 10:23 pm

Sounds don't play, but only sometimes

Post by Benamas »

Code: Select all

function love.load()
   sound = love.audio.newSource( "bump.wav", "static" )
end

function love.mousepressed(x, y, button)
      love.audio.play(sound)
end
In theory this should play the sound every time I click the mouse. In practice, it will make the sound the first time I click, but won't do it again for about five and a half seconds no matter how much I click.

Is this normal? Do I need to use a different method if I want to play sounds rapidly, or is my PC the culprit?
User avatar
bmelts
Party member
Posts: 380
Joined: Fri Jan 30, 2009 3:16 am
Location: Wiscönsin
Contact:

Re: Sounds don't play, but only sometimes

Post by bmelts »

How long is bump.wav?

The reason it won't play multiple times simultaneously is because you're trying to play a Source that's already playing - LÖVE can't play it again until it's finished.
User avatar
Benamas
Prole
Posts: 28
Joined: Wed Apr 14, 2010 10:23 pm

Re: Sounds don't play, but only sometimes

Post by Benamas »

Length: 0.16 sec
Data size: 7420 bytes
Audio Format: PCM 22.050 kHz, 16 Bit, Mono

Interestingly, if I call love.audio.stop() immediately before love.audio.play(source) then it plays correctly every time I click, but this is not an ideal solution since I'll probably also want music in my game and this would kill that.
User avatar
bmelts
Party member
Posts: 380
Joined: Fri Jan 30, 2009 3:16 am
Location: Wiscönsin
Contact:

Re: Sounds don't play, but only sometimes

Post by bmelts »

Well, you can have love.audio.stop only stop that Source, by passing it as an argument.
User avatar
adrywalsh
Prole
Posts: 20
Joined: Fri Feb 26, 2010 7:24 am

Re: Sounds don't play, but only sometimes

Post by adrywalsh »

or get Audacity and only use .ogg files.
I've had way more success getting my sounds to rapid fire with ogg over wav.
while (1)
do LÖVE
User avatar
bmelts
Party member
Posts: 380
Joined: Fri Jan 30, 2009 3:16 am
Location: Wiscönsin
Contact:

Re: Sounds don't play, but only sometimes

Post by bmelts »

Yeah, LÖVE taking too long to determine that .wavs have ended is a known bug.
Post Reply

Who is online

Users browsing this forum: No registered users and 98 guests