Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / [bug] loop small wav just clicks and pops

Author
Message
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 28th Mar 2020 16:53
I've encountered a critical problem while working on my XM player.
There's a bug with Playsound () looping small samples. This is especially damaging for playback of chip/synth or mathematically generated samples which are typically very small.
Here's an example WAV which you can play with any other sound tool and loops a continuous tone.

Using



This may also indicate an issue with GetSoundPlaying() being slightly off as I had to write my own version of it in the end.
It's probably not just an issue with small samples, but just more obvious (and a breaking issue).



Attachments

Login to view attachments
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 28th Mar 2020 18:47 Edited at: 28th Mar 2020 18:49
yeah, the bug is horrible. and same occurs with .ogg sound.
trying with:

is no help:

but may provide insight?

similar: https://forum.thegamecreators.com/thread/225148

Attachments

Login to view attachments
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 28th Mar 2020 19:38
I would not be surprised if this happened with a stream, because it uses buffering.
Cybermind
Valued Member
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 30th Mar 2020 10:42
@Virtual Nomad, is there any specific reason why you don't load small samples as sound instead?
13/0
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 30th Mar 2020 13:37 Edited at: 30th Mar 2020 13:46
i do. but, from the linked thread, the music command set has native "GetDuration" support which could help with a manual looping function. that's the only reason i'd consider it.

a possible work-around would be to make all sounds the (theoretical minimum) 0.5 second duration and decide when to stop the sound from playing instead of deciding when to play the sound?
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 30th Mar 2020 17:54 Edited at: 30th Mar 2020 17:55
I was going to say that it wouldn't work in this scenario.

For XM looped instruments, they could be like this:

|================|==========|
start______________ loopstart_____looprepeat

Whereby the first single replay is start->looprepeat, then subsequently from loopstart->looprepeat.
I get around this in the player by splitting the sample into 2 different AppGameKit sounds.

However, you triggered a thought here by suggesting making the sound longer. I could take the loopstart->looprepeat part of the sample and unwrap it x times to make it hopefully long enough to work? Theoretically, the end result would be the same (doesn't matter about stopping, as it's an infinite loop), just consume a little bit of memory.
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 30th Mar 2020 22:45
Unrolling the sample loop portion to >256 bytes does work.
Tried it on some different samples and sometimes works better if unrolled to 1024 - not sure why.

Login to post a reply

Server time is: 2024-11-22 04:22:40
Your offset time is: 2024-11-22 04:22:40