Sound: perfect loop

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
daaa57150
Posts: 28
Joined: Fri Nov 17, 2006 10:35 pm

Sound: perfect loop

Post by daaa57150 »

Hi,

I have a really hard time figuring out how to make a sound loop perfectly. I tried OSLib's inbuilt functions with BGM (oslib special sound format) and MP3, and I can always hear the gap between 2 loops. I searched other ways to play my MP3 in a loop and got a bit lost... I *think* all MP3 players do it the same way: they fill a buffer of a predefined size with decoded frames and when at the end of the file, fill the rest of the buffer with 0's, thus the non perfect looping I get.

Does something exist that would play my sound in a perfect loop? I need something with the source available or appropriate hooks because I want to synchronize other objects with the sound, and of course I want it to be compatible with all PSP FW versions.
As I'm pretty sure nothing like that is available, can someone teach me / help me with writing such a thing, as I'm very uncomfortable with so low-level & C (not ++) code.

If you want to test, here is the MP3 I use: http://www.newgrounds.com/audio/listen/59771
It loops perfectly in Itunes & winamp (but not in this flash app).

Thanks.
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

MP3 is NOT gapless. LAME encoded MP3s include metadata in the MP3's tags which indicate the exact length of the song. Only players that support reading this metadata will stop playback at the exact moment, while others will play till the padding is over.

Use AT3 files for gapless.
daaa57150
Posts: 28
Joined: Fri Nov 17, 2006 10:35 pm

Post by daaa57150 »

Ok thanks, I'll see if I can make an AT3 file loop correctly.
User avatar
jean
Posts: 489
Joined: Sat Jan 05, 2008 2:44 am

Post by jean »

MP3 is NOT gapless
WHAT??? What are you guys speaking about?? Every compression technique under the sun does divide data into chuncks; it's up to the decoder to present data continuously. If i correctly understand the original question, the clue is on buffering techniques: i pointed out the lack of proper buffer handling in pspsdk sound library time ago. However, double and triple buffering are not necessarly related to PSP: i bet you'll have better luck finding out how to implement such techniques in a general purpose programming site.
daaa57150
Posts: 28
Joined: Fri Nov 17, 2006 10:35 pm

Post by daaa57150 »

So it really is a buffer problem..
If I manage to write an mp3player with proper buffer handling, (ie: when at the end of the MP3 file, continue with the start of the file), it will be fine then?
If so, I was right and I need some help!
daaa57150
Posts: 28
Joined: Fri Nov 17, 2006 10:35 pm

Post by daaa57150 »

sorry to bother again, but could someone share a recent compiled lib mad (.a and .h)? I still have no connection at home and can't access any svn from my work.
I can give you my mail by PM.

Thanks.
Post Reply