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!
Looping audio problem
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- celynwalters
- Prole
- Posts: 28
- Joined: Sat Aug 11, 2012 10:16 pm
- Location: UK
- Contact:
Re: Looping audio problem
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.
Re: Looping audio problem
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.
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.
- celynwalters
- Prole
- Posts: 28
- Joined: Sat Aug 11, 2012 10:16 pm
- Location: UK
- Contact:
Re: Looping audio problem
Argh! Yes, of course, thank you.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.
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..
Re: Looping audio problem
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.
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.
- celynwalters
- Prole
- Posts: 28
- Joined: Sat Aug 11, 2012 10:16 pm
- Location: UK
- Contact:
Re: Looping audio problem
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.
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.
Re: Looping audio problem
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.
- celynwalters
- Prole
- Posts: 28
- Joined: Sat Aug 11, 2012 10:16 pm
- Location: UK
- Contact:
Re: Looping audio problem
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?
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?
Re: Looping audio problem
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.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?
- celynwalters
- Prole
- Posts: 28
- Joined: Sat Aug 11, 2012 10:16 pm
- Location: UK
- Contact:
Re: Looping audio problem
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.
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.
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 5 guests