Looping audio problem

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.
User avatar
celynwalters
Prole
Posts: 28
Joined: Sat Aug 11, 2012 10:16 pm
Location: UK
Contact:

Looping audio problem

Post by celynwalters »

I'm trying to make a looping ambient noise for a menu, but I can never get a perfectly clean loop.
I've made a file in Audacity, which loops seamlessly.
I discovered that mp3 files usually insert a silence at the beginning, so I can't use mp3.
I'm on a mac, and I read on the forums that .wav files don't play properly (true).
So I have to use an .ogg. I'd be fine with this, but it's still making a pop on the seam.
I've tried "stream" and "static" (static works better).
Any pointers/info?
Thanks!
User avatar
Lafolie
Inner party member
Posts: 809
Joined: Tue Apr 05, 2011 2:59 pm
Location: SR388
Contact:

Re: Looping audio problem

Post by Lafolie »

Could you post some code/.love so that we can see how you're handling this? I've created looping OGG audio on OS X before and it worked fine.
Do you recognise when the world won't stop for you? Or when the days don't care what you've got to do? When the weight's too tough to lift up, what do you? Don't let them choose for you, that's on you.
User avatar
Boolsheet
Inner party member
Posts: 780
Joined: Wed Dec 29, 2010 4:57 am
Location: Switzerland

Re: Looping audio problem

Post by Boolsheet »

mp3 is a bit tricky because it has to pad the data to make it fit into the transform or something like that. Certain encoders (LAME) save the exact sample number in metadata. If a decoder is aware of it (like mpg123, the one LÖVE is using), it should properly truncate it to its original length. However, I think the decoder that Audacity uses does not recognize the metadata.

So yeah, ogg vorbis all the way.

It would indeed be easier to help if you share the problematic code and audio file. It can also be a short example that shows the same behaviour.
Shallow indentations.
User avatar
celynwalters
Prole
Posts: 28
Joined: Sat Aug 11, 2012 10:16 pm
Location: UK
Contact:

Re: Looping audio problem

Post by celynwalters »

Boolsheet wrote:It would indeed be easier to help if you share the problematic code and audio file. It can also be a short example that shows the same behaviour.
Argh! Yes, of course, thank you.
I tend to put all the code in one file (not such a great idea), so here is only what I need to reproduce the problem.
I dunno, it could work fine on another computer, maybe..
looping.love
(83.51 KiB) Downloaded 209 times
User avatar
Boolsheet
Inner party member
Posts: 780
Joined: Wed Dec 29, 2010 4:57 am
Location: Switzerland

Re: Looping audio problem

Post by Boolsheet »

Source:setLooping expects a boolean. Passing nil is probably interpreted as false.

You only have to call play once and the Source will loop forever. Calling play on an already playing source has no effect (except maybe trigger a bug in 0.8.0 that causes it to go into a very long loop if you call it too many times in a short time).

What happens in your code is that the source plays from start to end and it will be started again with the play call in love.update. If the frame rate is around 60, you may have up to 16 ms of silence (plus the play function overhead) because the Source could have stopped at any point in this time window.
Shallow indentations.
User avatar
celynwalters
Prole
Posts: 28
Joined: Sat Aug 11, 2012 10:16 pm
Location: UK
Contact:

Re: Looping audio problem

Post by celynwalters »

Ahhh..
Yeah, I guess as it looped anyway, I must have thought that "sfx_menu:setLooping()" must have done the trick.
Yet another mystery solved. Thanks! again.
User avatar
IndieKid
Citizen
Posts: 80
Joined: Sat Dec 22, 2012 7:05 pm
Contact:

Re: Looping audio problem

Post by IndieKid »

Hey, I also use OGG that I created on Mac. It works awful. I have disabled audio for my game, because it had ultimate-lags. Do you know what can cause that? The game also crashes randomly. By the way I used to have a lot of audio files in it.
User avatar
celynwalters
Prole
Posts: 28
Joined: Sat Aug 11, 2012 10:16 pm
Location: UK
Contact:

Re: Looping audio problem

Post by celynwalters »

Ogg seems to work very well for me (now it's all fine).
If your game is crashing even with all audio disabled, perhaps the root of the problem is somewhere there?
Have you tried playing your oggs in a new empty project?
User avatar
IndieKid
Citizen
Posts: 80
Joined: Sat Dec 22, 2012 7:05 pm
Contact:

Re: Looping audio problem

Post by IndieKid »

celynwalters wrote:Ogg seems to work very well for me (now it's all fine).
If your game is crashing even with all audio disabled, perhaps the root of the problem is somewhere there?
Have you tried playing your oggs in a new empty project?
I mean, the game crashes sometimes and I can't get why. No when audio disabled the game works perfect. So there is no problem in the code. Maybe I miss something on how to use OGG and audio at all, but why the heck it works then. Can you send me your example please? And what is the bitrate of your OGG, I use 192 Kbps but still can hear some dirty noise.
User avatar
celynwalters
Prole
Posts: 28
Joined: Sat Aug 11, 2012 10:16 pm
Location: UK
Contact:

Re: Looping audio problem

Post by celynwalters »

You might have to use headphones to hear it, it's a bit lower than I wanted it.
When I exported it with Audacity, I only got an option of quality, 1-10, so I chose 10.
VLC says it is 499 kb/s... whoah.
The audio file is about 3 seconds long, don't know what to suggest if this one doesn't work.
looping2.love
(83.52 KiB) Downloaded 183 times
Post Reply

Who is online

Users browsing this forum: No registered users and 55 guests