pgSoundLoader stutter

Help for using specific functions

pgSoundLoader stutter

Postby Andy » Mon Nov 16, 2020 3:10 pm

When playing my mp3 audio with pgSoundLoader I am noticing intermittent stutters, where every so often a clip begins to play and then immediately starts over. I can't find a pattern related to the size of the audio file or any other aspect of it. My only clue so far is that this seems to happen more where the internet connection is not as good. A varying connection quality could explain the intermittent aspect of this behavior, but I'm at a loss as to determining a root cause and more importantly, how to guard against it.

One thought I had is that something might be going on with the caching. Or maybe there is some kind of race condition that only becomes apparent with a slow connection. I even have a superstitious reason because the most recent batch of sound has an underlying sample rate of 48 instead of 44.1.

Anyway, my question would be: Are there some "best practices" I can follow with regard to playing audio? I thought my usage was pretty simple but maybe I've just been lucky these past several years. Also, is there any way to get some logging as to what is happening within the player? The worst behavior is being observed on a Chromebook with its native browser.

Thanks in advance for any suggestions. ~Andy
Andy
 
Posts: 47
Joined: Tue Sep 09, 2014 3:40 pm

Re: pgSoundLoader stutter

Postby Clifton » Mon Nov 16, 2020 3:35 pm

Audio is not too fussy.
However, if unstable or slower connections are accessing your content, then go with a lessor audo bitrate. Audio bitrate is the resolution of the audio file; similar to the dpi of an image file. Audacity generally saves at the standard quality rate of 170-210kbps. You can generally still have pretty good audio playback down as low as 128kbps. You should also consider saving your mp3's with a variable rate. This will give you a decent tradeoff in quality for more complex portions of the file and less kbps for portions that do not require a high resolution.

If you are recording audio, keep the sample rate between 32000 and 44000 samples and don't let the recording program convert to mp3 at the same time. Instead save as a raw wav file and then do your conversions to mp3.

Just a few recommendations.

On the pgSoundLoader() side of things, make sure your project is set to NOT use Flash. Basically it is unsupported by all browsers as of December, 2020 and many browsers will no longer load Flash-based content. pgSoundLoader() will automatically use HTML5.

If you still have trouble with mp3, you might try a different conversion program. Audacity is among the best (and free) programs. Another conversion program I've used when batch converting many files is Freac.

I'm no expert on creating sound files, but these are some things I take into consideration.
 
Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am

Re: pgSoundLoader stutter

Postby Andy » Wed Nov 18, 2020 10:45 am

Looks like I am already observing all of these. But I thought of something while reading your recent post regarding videos:
I want to avoid having more than one audio playing at once, so before starting a new play I have been doing a stopAll. The stop and the play have been coming from separate objects so I've tried to add delays to force the correct order of execution, but that may not be enough. Suppose I put the stopAll in my play object. Is it safe to place a pgSoundControl with action=stopAll immediately before my pgSoundLoader? Would I need to wait for a status from the stop before proceeding with the play?
Thanks, Andy
Andy
 
Posts: 47
Joined: Tue Sep 09, 2014 3:40 pm

Re: pgSoundLoader stutter

Postby Clifton » Wed Nov 18, 2020 10:54 am

You should be fine to send stopAll and immediate begin playing a new file. However, if you always use the same "name" when calling pgSoundLoader(), then a stopAll should not be necessary as the new file will automatically replace the one that is playing under the same name. These sound functions are pretty powerful in that they allow multiple files to play at once ... useful for background music, or sound effects, etc. When playing multiple files, that is when you need to use a different "name" parameter so each audio is playing in its own space.
Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am

Re: pgSoundLoader stutter

Postby Andy » Wed Nov 18, 2020 11:58 am

Thanks, I'll give that a try. As it turns out I use the same name parameter for all my audio, but all of it is transparent so multiple files can be playing simultaneously unless I stop them.

One more thing, please. You mentioned turning off the Flash support and I haven't always done this reliably. I usually use scripts to avoid human error but I found that setting ppEnableFlash of this book to false is not enough. Is there some OpenScript that will get the cleanup routine to run?

Thanks again, Andy
Andy
 
Posts: 47
Joined: Tue Sep 09, 2014 3:40 pm

Re: pgSoundLoader stutter

Postby Clifton » Wed Nov 18, 2020 12:08 pm

Regarding Flash, just make sure "Enable Adobe Flash Support" is UNCHECKED in the PowerPac menu. Your export will no longer use Flash in any PowerPac function. Some Flash elements may still be exported, but they are essentially redundant for backward compatibility. Eventually these resources will be removed, but they do no harm either way. While PowerPac functions will NOT use Flash, that doesn't mean that you aren't adding that support from other 3rd party scripts. You will have to make sure those a clean of Flash support as well. Most are at this point.
Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am


Return to Function Help

Who is online

Users browsing this forum: No registered users and 2 guests

cron