Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: tinytim42 on Tue 19/09/2023 14:25:16

Title: Music Loop skips at end?
Post by: tinytim42 on Tue 19/09/2023 14:25:16
I am trying to loop cleanly the end of a music file with its own beginning, but when I use music.Play(eAudioPriorityVeryHigh, eRepeat), there is a gap of about a tenth of a second between the end of the audio file and the beginning of its loop.

I also tried to put it into an AudioChannel and then use channel.SeekMs() to bring it back to the beginning when it reaches the end of the file, and that just stops it playing altogether. I've experimented with using SeekMs just before the end of the loop, and that improves things, but there's still a noticeable "click" when it loops.

I'd just like it to smoothly interpolate the end of the looping audio file with its beginning. Is there something I can do (or some other audio capability) that would remedy this?

Perhaps this belongs in the beginner's forum, but I haven't found a workaround and I've tried several things.
Title: Re: Music Loop skips at end?
Post by: eri0o on Tue 19/09/2023 15:31:18
This is better at the beginner forums

Please tell specifically exactly which ags version you are using and please share the audio file you are using.
Title: Re: Music Loop skips at end?
Post by: tinytim42 on Tue 19/09/2023 15:48:10
Sure thing. I am running 3.6.0 - Patch 5, and I don't see the capability to attach files in the forums? Here's a link. (https://drive.google.com/file/d/1gdRp1h5SC6yCv3Ix3UCQK-dxpAGzPysU/view?usp=sharing)
Title: Re: Music Loop skips at end?
Post by: eri0o on Fri 22/09/2023 13:02:19
Please try using ogg instead, mp3 can't loop perfectly due to how it's compression works.
Title: Re: Music Loop skips at end?
Post by: tinytim42 on Sat 23/09/2023 22:18:52
Thanks, eri0o! I'm afraid the issue happens with .wav files as well (which aren't compressed). Something funky under the hood, I assume.
Title: Re: Music Loop skips at end?
Post by: morganw on Mon 25/09/2023 20:22:04
I don't think it is an issue of compression, it is more an issue of alignment of the data. Wave files have their own issues so a .wav file isn't a good test.

I converted your file to .ogg and it loops with no problems when I've tested it:
au000003.ogg (https://www.dropbox.com/scl/fi/697dob31ivtitpmlxdocj/au000003.ogg?rlkey=opw8fx2ulzu6wfwp4e3kn6vb2&dl=1)

Quote from: tinytim42 on Tue 19/09/2023 14:25:16I also tried to put it into an AudioChannel and then use channel.SeekMs() to bring it back to the beginning when it reaches the end of the file
This approach will not work because the scripting commands won't run often enough to stay in sync with the end of the audio playback. You need to do it the first way that you tried (usinge eRepeat).