Audio issues since release 268

Hi guys,
I have found a few issues with since the latest release. The audio engine seems quite a bit slower. Some of my sounds don’t play at times.

I have also found what seems to be a bug with fade in. I have my music fade in every time I press the play button. If I keep pressing on and off , when it comes on the volume seems to be halfed each time, eventually after multiple times going to 0.

Weird. [import]uid: 8192 topic_id: 6165 reply_id: 306165[/import]

I’ve noticed that it won’t play an mp3 audio file that is less than a second.

media.playSound("shortclip.mp3") -- doesn't play

I have very similar problem. Same WAV file will play fine at times, but it would not some other time. Some sound will play just the beginning, but not the whole clip. In most cases, I cannot predictably repeat the problem. It happens randomly (except a few cases, I know the sound never plays). It works fine with 243. [import]uid: 19297 topic_id: 6165 reply_id: 22768[/import]

the new audio API also pauses background (iPod) music
with the Corona SDK it was possible to open an app and listen to iPod music at the same time
[import]uid: 6459 topic_id: 6165 reply_id: 22804[/import]

Has anyone had any issues with audio.stop stopping all sounds playing on all channels even when a specific channel to stop is written? I’m waiting to test this on device because I’m beginning not to trust the emulator. [import]uid: 21456 topic_id: 6165 reply_id: 22936[/import]

I’m also having issues with the audio API regularly, regardless of using the Simulator, my IPhone or an Android device.
I’ve also seen this problem in the latest release of “Tilt Monster” by Jonathan Beebe. The background music isn’t always played while running. Probably the same problem.
From my experience, the audio channels seem to need some time to close. So you need to work with timeouts before calling the next method / switching the level / opening the next sound…strange stuff. [import]uid: 11219 topic_id: 6165 reply_id: 23657[/import]

the following function works from time to time only. App starts with a sound playing in channel 1. the button below should mute/unmute the channel.

In general, it mutes and I cannot unmute it anymore (however, and this is the big question mark, from time to time the code works - mute/unmuting)

[code]

local onETouch = function(event)
if event.phase==“release” and E.isActive then

local isChannelPaused = audio.isChannelPaused(1)
if isChannelPaused then
audio.resume(1)
else
audio.pause(1)
end
end
end
[/code] [import]uid: 4883 topic_id: 6165 reply_id: 27996[/import]

Is it something I am doing wrong or the sound API is really an issue? [import]uid: 4883 topic_id: 6165 reply_id: 30537[/import]

I solved all my audio issues by exclusively using the Audio api and using the aifc (compressed AIF) format for my apps that need to run on iOS. I suggest not using media.event sounds no matter how tempting. [import]uid: 21456 topic_id: 6165 reply_id: 30555[/import]

As far as the muting issue what I’ve experienced with the audio API on my first app which uses up to 10 channels playing simultaneously is that you will get more reliable results if you reserve channels there by locking them to certain sounds and preventing other sounds from grabbing those channels once they become free which could result in abnormal or unpredictable audio API performance.
[import]uid: 21456 topic_id: 6165 reply_id: 30560[/import]

This still doesn’t work. Where is ansca on this? Kinda blows that I can’t use background music in my game…
[import]uid: 13529 topic_id: 6165 reply_id: 34777[/import]

Any news on this at All? Evan?

I find the audio still much buggier and slower then before. [import]uid: 8192 topic_id: 6165 reply_id: 37979[/import]

I moved in another direction with my game, but, before I did, I noticed most of my problems were related to audio ‘transitions’. For example, if a track was paused when still fading in, it would never restart. [import]uid: 13529 topic_id: 6165 reply_id: 37980[/import]

For the original problem posted, the solution is that you need to reset the channel volume to your desired volume level. As documented, the fade APIs are persistent and change the underlying volume. When a fade ends, the channel volume is left at that fade value. If you cancel a fade midflight, the behavior is undefined, but rest assured that the channel volume was changed before that point so you will still need to reset the volume before you start playing again.

[import]uid: 7563 topic_id: 6165 reply_id: 38112[/import]

And how about the whole Audio API being laggy? I cant do any sound work on my game until some solution is made. im on windows developing for Android, and my sounds are delayed a good amount on the device… [import]uid: 19620 topic_id: 6165 reply_id: 38279[/import]

I’m assuming you are smart enough to understand the difference between loadStream and loadSound and when to properly load assets. If not, go re-read all the docs. Otherwise, here is Android audio explained in detail.
We have made a continual stream of fixes and performance enhancements behind the scenes to the new audio API since 268. (You only need to monitor the daily build logs.)

However, Android has fundamental problems in their audio system that Google must solve. Since 268, we have tuned the OpenAL implementation on Android to reduce latency as much as we can. For apps that don’t stress the CPU, the latency may be acceptable, but as CPU becomes stressed, Android behavior penalizes audio and latency becomes worse. So depending on what your app is doing, you may or may not be affected by the problems.

Ultimately, the Android problem is two-fold.

  1. Their old audio API sucked.

  2. Their OS (down to the kernel level) doesn’t provide low enough latency response to do real time audio.

Google has publicly admitted to these problems. And it’s no secret among Android developers…you only have to do a quick Google search to see for yourself:

http://code.google.com/p/android/issues/detail?id=3434
http://kile.stravaganza.org/blog/post/android-audio-api-sucks
http://www.badlogicgames.com/wordpress/?p=1315
http://groups.google.com/group/android-ndk/browse_thread/thread/29f88a99dc954c71
http://mindtherobot.com/blog/555/android-audio-problems-hidden-limitations-and-opensl-es/
http://music.columbia.edu/pipermail/portaudio/2010-December/011146.html
Google has started fixing (1) by introducing a brand new audio API based on OpenSL ES and is accessible through the C layer instead of Java. But this requires Android 2.3 or beyond and the API is still seems to be unstable. But obviously, to ‘fix’ audio on Android requires us to drop 2.2 which we’re not sure our users are ready for, so be careful what you wish for because you might just get it.

Unfortunately, Google has not yet fixed (2). I’ve been told their kernel team, their multimedia team, and their audio team are working on this. But I’m going to assume their problems are fundamental and serious since they have 3 teams working on this. But regardless, the fundamental latency problems must be fixed by Google and is out of our control.
That all said, we feel your pain. We are in the same boat as you. We have done what we can and continue to look for ways to improve performance. In many cases, the new audio engine is usable on Android and you should continue to give it a try and try performance tuning your app. If that fails, you can fallback to the old API, but you lose access to all the capabilities the new audio API gives you (and you are exposed to other bugs/limitations in the old audio API).

[import]uid: 7563 topic_id: 6165 reply_id: 38299[/import]

thanks for the response, ill just have to see how i can make it work. And i have been through all the documentation. thanks anyways [import]uid: 19620 topic_id: 6165 reply_id: 38303[/import]

Thanks ewing. media.playEventSound is blazing fast on iOS with uncompressed audio. [import]uid: 4596 topic_id: 6165 reply_id: 38357[/import]

@ewing. Thank you very much for the explanation. I am finding the issue in iOS. I have no idea about Android.

I can’t seem to find the issue, but it does happen with streaming audio when I exit and then go back to the app. There seems to be a lag. My game is music dependent so I am trying to find feasable workarounds. I would be happy to send you code if you are available to look at it.
Thanks [import]uid: 8192 topic_id: 6165 reply_id: 38949[/import]

Yes, please submit a bug report with a simple reproducible test case. (Would appreciate it if all assets were included.) Please tell me the bug number or the exact title of the bug so I can search for it.

When an app is backgrounded, we do multiple things to put the audio system into hibernation mode. We have to do that for phone call interruptions, but we reused the code for backgrounding as well, though we may need to re-evaluate that behavior since some people want background music, though we need to expose more plumbing before we can do that.

The transition back and forth from hibernation mode may be part of the performance issue. You are definitely in an edge case scenario. For now, I recommend you try calling audio.pause or better yet audio.stop on everything when you get a backgrounding notification and see if that helps. Then resume or play when the system starts up again.

[import]uid: 7563 topic_id: 6165 reply_id: 39012[/import]