Audio stutter using audio.loadStream()

Does anyone else notice random stuttering in playback of music loaded with audio.loadStream()?

I have used audio.loadStream() in the past with no issue, so I believe this may be an issue in the latest public release or perhaps the one prior.

I have tested various formats, with various audio files, all which playback fine on the computer itself (Mac).

Formats tested: .ogg, .mp3, .aiff, .wav

It really helps to use a stereo headset (preferably over ear) whilst testing this. The stuttering can either be every few seconds, or every 4 seconds roughly.

Just want to know if anyone else has had this happen, before I open a bug report.

Thank you

We haven’t made any changes to the audio side.  But I do know stutter can happen for the following reasons…

  1. You are playing too many audio channels at the same time.  The more audio channels you use at the same time, the more work Corona has to do to *mix* them together into a single audio stream (which is a CPU bound operation) before delivering the final mixed stream to the audio device.  Meaning that the more active audio channels that you have, the longer it takes to mix them together.  You’ll hear a *skipping" effect if the amount of time it takes mix the audio channels is longer than the audio frame/duration that it is mixing.  I hope this makes sense.  Also note that how busy your CPU is is a factor as well (like it doing OS updates in the background, playing YouTube videos, etc.).

This is the most likely case.  It’s also why many AAA desktop games have an option/setting for setting the number of audio channels it’ll use.  The more channels they use, the more work the CPU has to do to mix them together.

  1. You might also run into a skipping effect when streaming audio from file if your hard disk (the kind with the spinning platters; not the solid state or flash drives) is super busy too.  Like if your OS is busy indexing all of your files, which involves hitting the disk a lot.  Anti-virus software on Windows would do the same because it involves scanning files on the disk as well.

Hey Josh. How are you?

I’ve tested this on various platforms and logged a bug, case: 43416. The test case just loads an audio file using audio.loadStream() and plays it back. That is all.

It can be reproduced using a single audio file (only one channel in use, no other audio playing), and my Mac has a SSD, and naturally phones have flash based storage also. On the Mac, I had very little other programs open, no videos in play or anything strenuous on the CPU.

I hope you guys can reproduce. A colleague of mine was also able to reproduce this, using the test case I supplied in the bug report.

Thanks for the reply

Hey Danny,

I just tested this on a low-end MacBook.  It’s 5 years old and still running Mavericks.  It plays your project just fine; no audio skipping.  I’ll ask someone else here to give it a go on a more modern Mac.

Couple questions for you:

  • What OS version and hardware are you running on?

  • Do you hear any audio skipping with our “Media/SimpleMixer” or “Media/AudioPlayer” sample apps?

El Capitan 10.11
iMac 27" late 2013 - 256gb ssd, 16gb ram, 2gb Amd graphics.

I’ll have to get back to you on your sample apps, when I’m back at my computer in a few.

Thanks

@Josh I was able to reproduce this using the Audio player sample. Using the longer audio file, as it’s easier to spot.

One of our guys was able to reproduce this on OS X Yosemite.  Yeah, it’s definitely an issue.

Looks like it only happens on OS X.  iOS and all other platforms are okay.

That’s great to hear. I want to pubish a game soon, and being able to use audio.loadStream() is really important.

Thanks for all your assistance in this matter Josh :slight_smile:

We haven’t made any changes to the audio side.  But I do know stutter can happen for the following reasons…

  1. You are playing too many audio channels at the same time.  The more audio channels you use at the same time, the more work Corona has to do to *mix* them together into a single audio stream (which is a CPU bound operation) before delivering the final mixed stream to the audio device.  Meaning that the more active audio channels that you have, the longer it takes to mix them together.  You’ll hear a *skipping" effect if the amount of time it takes mix the audio channels is longer than the audio frame/duration that it is mixing.  I hope this makes sense.  Also note that how busy your CPU is is a factor as well (like it doing OS updates in the background, playing YouTube videos, etc.).

This is the most likely case.  It’s also why many AAA desktop games have an option/setting for setting the number of audio channels it’ll use.  The more channels they use, the more work the CPU has to do to mix them together.

  1. You might also run into a skipping effect when streaming audio from file if your hard disk (the kind with the spinning platters; not the solid state or flash drives) is super busy too.  Like if your OS is busy indexing all of your files, which involves hitting the disk a lot.  Anti-virus software on Windows would do the same because it involves scanning files on the disk as well.

Hey Josh. How are you?

I’ve tested this on various platforms and logged a bug, case: 43416. The test case just loads an audio file using audio.loadStream() and plays it back. That is all.

It can be reproduced using a single audio file (only one channel in use, no other audio playing), and my Mac has a SSD, and naturally phones have flash based storage also. On the Mac, I had very little other programs open, no videos in play or anything strenuous on the CPU.

I hope you guys can reproduce. A colleague of mine was also able to reproduce this, using the test case I supplied in the bug report.

Thanks for the reply

Hey Danny,

I just tested this on a low-end MacBook.  It’s 5 years old and still running Mavericks.  It plays your project just fine; no audio skipping.  I’ll ask someone else here to give it a go on a more modern Mac.

Couple questions for you:

  • What OS version and hardware are you running on?

  • Do you hear any audio skipping with our “Media/SimpleMixer” or “Media/AudioPlayer” sample apps?

El Capitan 10.11
iMac 27" late 2013 - 256gb ssd, 16gb ram, 2gb Amd graphics.

I’ll have to get back to you on your sample apps, when I’m back at my computer in a few.

Thanks

@Josh I was able to reproduce this using the Audio player sample. Using the longer audio file, as it’s easier to spot.

One of our guys was able to reproduce this on OS X Yosemite.  Yeah, it’s definitely an issue.

Looks like it only happens on OS X.  iOS and all other platforms are okay.

That’s great to hear. I want to pubish a game soon, and being able to use audio.loadStream() is really important.

Thanks for all your assistance in this matter Josh :slight_smile: