PROBLEM:
-when using streaming, sound gets all "clicky" and prog crashes.
QUESTION:
-how do i get rid of the sound bug and crashes when using streaming.
INFO:
-all drivers up to date (x86 w8RP 8400build, but had the same pb under w7)
-under love 0.8.0
-audio file is an.ogg (212kb .. 18sec) (not ticking under VLC)
-code exemple:
I am not sure what that "player" variable is, but nevertheless calling love.audio.play and love.audio.stop this often extremely hampers audio playback, and it wouldn't surprise me if this is what's leading to your crashes.
player is just a .png pic that moves with direction keys...
i see what you mean, no streaming for sound effects... got it.
so how can i get a loading screen then before jumping into the game? because there is a white screen while all the music is loading into the memory when you're using "static"...
function love.load()
loadingStage = 'start'
end
function love.update()
if loadingStage == 'start' then
loadingStage = 'loading'
return
elseif loadingStage == 'loading' then
loadImages()
loadingStage = 'done'
end
-- Game stuff here!
end
function love.draw()
if loadingStage == 'loading' then
drawLoadingScreen()
return
end
-- Game stuff here!
end
Here's how this works:
Note: In the default love.run, love.update is run before love.draw.
First love.load runs, and loadingStage is set to 'start'.
Then love.update runs, and loadingStage is set to 'loading' and the rest of love.update is skipped using return.
Then love.draw runs, and the loading screen is drawn, and the rest of love.draw is skipped using return.
Then love.update runs, and the images are loaded, and loadingStage is set to 'done'.
The rest of love.update is run, then love.draw and love.update run normally!
For a more advanced solution (if you wanted an animated loading screen for example), you might want to try something like love-loader.
My gripes with doing this in love.update is that this unnecessarily bothers the audio thread (which is busy trying to send you smooth audio), since generally a sound hasn't ended before love.update runs the next time. If you want a looping sound (looks like it), you can use Source:setLooping. In any case, I would advice you to only call play or stop (or any of the source functions, for that matter) when you actually want to change something. When you want to start playing, not when you want to continue playing, etc.
function love.load()
s = love.audio.newSource("music/music.ogg")
end
function love.update(dt)
if player >= 450 then
playAudio()
else
stopAudio()
end
end
function playAudio()
if s:isStopped() then
s:play()
end
end
function stopAudio()
if not s:isStopped() then
s:stop()
end
end