WARNING: Failed to create audio sound

I’m preloading a bunch of sound effects in my app. In build 345 I get a series of warnings for each sound in the console, one for each sound:

WARNING: Failed to create audio sound (soundFX/boom.wav)

This occurs ONLY in the simulator. Device audio still works. Moreover, if I quit and relaunch the simulator audio functions normally again, but if I restart the app. a bunch of times from within a simulator session, eventually I get the warnings and non-functioning audio.

Memory leak in simulator related to openAL, I presume? [import]uid: 9422 topic_id: 8782 reply_id: 308782[/import]

Thanks for the info. Some trivia, the new audio engine is the exact same codebase across all platforms (with a few differences under the audio engine for handling file decoding). But since the simulators (both Mac and Windows) have to relaunch, the there is extra restart/teardown code that exists only there.

Would you do several things:

  1. Try the latest daily build. I made a change recently which fixed some cleanup issues which might also fix this bug.

  2. If you still have the problem, would you submit a bug report at: http://developer.anscamobile.com/content/bug-submission

Please include a simple example program (with assets) that reproduces the problem and a step-by-step procedure so we can reproduce it internally to track down the problem.

Thanks
[import]uid: 7563 topic_id: 8782 reply_id: 32012[/import]

I’m already using the latest daily build available to me, 345. I’ll try again when the next version is up.

I can repeat the bug with Ansca’s own example code, “Simple Mixer”. If I relaunch the app repeatedly with “command-R” about 35-40 times I’ll get similar warning messages in the console and the audio stops playing correctly. (It’s takes only about 10 times in my own app.)

[import]uid: 9422 topic_id: 8782 reply_id: 32022[/import]

I just applied a fix to 347.
[import]uid: 7563 topic_id: 8782 reply_id: 32033[/import]

Looks like your fix did the trick. 347 does not exhibit the behavior I described.

Thanks for the quick turnaround!

[import]uid: 9422 topic_id: 8782 reply_id: 32055[/import]

I’m getting the same error in the terminal:

WARNING: Failed to create audio sound()

I’m using audio for collisions and at times there can be alot of them trying to play. any suggestions?

Thanks! [import]uid: 47357 topic_id: 8782 reply_id: 32349[/import]

You need to give a lot more information. Is your problem due to relaunching the simulation? Are you using 347 or later?
[import]uid: 7563 topic_id: 8782 reply_id: 32350[/import]

You need to give a lot more information. Is your problem due to relaunching the simulation? Are you using 347 or later?
[import]uid: 7563 topic_id: 8782 reply_id: 32351[/import]

This happens every time I start the simulator OR restart it, on my current project (I think maybe the audio format/encoding the sound guy gave us is incompatible?):

[text]
Windows simulator build date: May 18 2011 @ 15:25:09

Copyright © 2009-2011 A n s c a , I n c .
Version: 2.0.0
Build: 2011.505
WARNING: Failed to create audio sound (sfx/slingShot/sling_stretch_back.wav)
WARNING: Failed to create audio sound (sfx/slingShot/sling_stretch_back2.wav)
WARNING: Failed to create audio sound (sfx/slingShot/sling_stretch_back_3.wav)
WARNING: Failed to create audio sound (sfx/slingShot/slingshot release.wav)
WARNING: Failed to create audio sound (sfx/slingShot/Slingshot shoot.wav)
[/text]
On a side note, I noticed that after between 3 and 7 restarts, the simulator stops executing script at a certain point, but until I’ve restarted it several times, it executes all script.
When it comes up short, it causes major glitches that make the game unplayable. Is this related?

[import]uid: 63787 topic_id: 8782 reply_id: 41115[/import]

Yes, please check the sound format. We only officially support 16-bit signed little endian linear PCM files for .WAV. If the encoding is something else, then it won’t necessarily work on all platforms.

Audacity is a free program that might help you analyze the file formats.

[import]uid: 7563 topic_id: 8782 reply_id: 41209[/import]

exactly same problem here…but a am using caf files…and as i’ve noticed this only happens on windows(build 484 )…on hackintosh works perfectly…i guessed it has something to do with the android…it doesn’t bother me that much (i know it works on the actual device and in the mac version…this is enough for me)

[import]uid: 57170 topic_id: 8782 reply_id: 41887[/import]

The .WAV decoding backends are different on Mac/iOS than Android and Windows. The former uses Apple’s native decoders. Apple has lots of expertise in audio and handles a lot more cases.
[import]uid: 7563 topic_id: 8782 reply_id: 41948[/import]

I just downloaded build 2011.619 and I’m getting this error too.

WARNING: Failed to create audio sound(sound/gasp.m4a)
WARNING: Failed to create audio sound(sound/ice_in_glass_01.m4a)
WARNING: Failed to create audio sound(sound/imp_junk_large.m4a)

When I went back to the previous build I had been using, 2011.605, the error no longer showed up.

Note that I’m using loadStream to load a lot of sounds at the beginning and most of them work fine. It’s not until after 7 sounds loaded via audio.loadSound and 40 sounds load via loadStream that this error happens. [import]uid: 9905 topic_id: 8782 reply_id: 56127[/import]

We need a lot more information. Is this Mac Simulator, Windows Simulator, iOS, Android? Which models of device? Which OS version?

If on iOS, are you getting low memory warnings? Which devices? Original iPhone? iPad 2?

Is it only for sounds in subdirectories? There was a daily build change yesterday that affects subdirectories.

Can you reproduce the behavior in build 606 and 608? 608 introduced changes to the audio backend, much oriented towards loadStream. But the memory profile wasn’t supposed to change much. Are you playing the samples when this fails, or are you doing pure loading?

Currently, each loadStream targets about 100KB of memory to be used for raw PCM plus data structure overhead. 40 simultaneous files open may be a bit excessive and you might consider only opening files when you actually need to play them and closing them when you are done.

Also, keep in mind that every file handle remains open with loadStream and operating systems tend to have a low limit on the number of file handles you can have open at a given time. (I recall Mac used to be around 128 once upon a time…I imagine iOS would be less.) This would also explain file open failures.

[import]uid: 7563 topic_id: 8782 reply_id: 56130[/import]

I did post a bug report also. But to answer your questions…

The error appears on the Mac Simulator, and I haven’t tried it on any device yet. I also haven’t tried it on any version after 605 yet. I do have all the sounds in a subdirectory, but haven’t tested whether this has an effect.

The version of my app that’s on the market actually has 67 loadStreams and 10 loadSounds open throughout the app. Haven’t had an issue with this as far as I know with builds all the way back to March 2011.

Of course, I’m not playing more than maybe 5-8 sounds at once. But I’d much rather have the flexibility to keep them all open (as before) than have to rework all my code.
[import]uid: 9905 topic_id: 8782 reply_id: 56187[/import]

Okay, I reproduced your problem. It looks like Apple’s OpenAL implementation has a hardcoded limit on the number of alBuffers that can be generated.

Opening as many stream files as you are is a fringe case I’m not sure if we’re going to support. As I said elsewhere, the number of files you can open is limited on OS’s so you are already risking on pushing other limits. However, you got hit by an OpenAL limit first. You should take this as a clue that you should be closing streams you are not currently using.

Reverting back to the old audio changes will lose streaming optimizations designed to minimize buffer under run conditions, so we are not going to revert our changes.

However, since I have already announced many of the secret audio APIs, I will share one more that I omitted. Be warned, setting these to bad values will really mess up performance and I don’t really want people messing with these which is why I didn’t share them before.
(See the ALmixer implementation if you really want to understand what’s going on.)

But I created this backdoor API just in case people needed to fine tune performance in case buffer under runs were a serious problem. In your case, you might tweak it to restore the old behavior.

audio.loadStream supports a table parameter with 4 keys:

audio.loadStream(file, {bufferSize=4096, maxQueueBuffers=25, startupBuffers=8, buffersQueuedPerUpdate=4})
(Note: The values listed here are the current defaults.)

The old default before the change was something like the equivalent of:
audio.loadStream(file, {bufferSize=16384, maxQueueBuffers=5, startupBuffers=2, buffersQueuedPerUpdate=1})
(The last parameter didn’t exist in the older builds and is part of the new optimizations.)

I am currently thinking I might change the defaults to:
audio.loadStream(file, {bufferSize=8192, maxQueueBuffers=12, startupBuffers=4, buffersQueuedPerUpdate=2})
but I am undecided on this.
[import]uid: 7563 topic_id: 8782 reply_id: 60474[/import]

Hey,

For anyone that is having audio problems using the API audio.loadStream look at the link below to get some bright “light”!

Here you go --> http://developer.anscamobile.com/forum/2011/11/10/music-woes#comment-71116
Cheers,
Rodrigo. [import]uid: 89165 topic_id: 8782 reply_id: 71131[/import]

I am trying to load a sound file in the simulator and it fails. I am on Mac using Version 2012.929 (2012.10.5)

Simulator output:
2012-11-12 09:18:56.100 Corona Simulator[7241:f03] File exists
2012-11-12 09:18:56.100 Corona Simulator[7241:f03] WARNING: Cannot create path for resource file ‘/Users/username/Library/Application Support/Corona Simulator/Appname-62E8EEEE864DC266B5288AC1B9F8D60C/Documents/test.wav’. File does not exist.

2012-11-12 09:18:56.100 Corona Simulator[7241:f03] WARNING: Failed to create audio sound (/Users/username/Library/Application Support/Corona Simulator/Appname-62E8EEEE864DC266B5288AC1B9F8D60C/Documents/test.wav)

[code]
local path = system.pathForFile( “test.wav”, system.DocumentsDirectory )

local fhd = io.open( path )

– Determine if file exists
if fhd then
print( “File exists” )
io.close()
end

local wordSound = audio.loadSound(path)
[/code] [import]uid: 138352 topic_id: 8782 reply_id: 130705[/import]

I was able to get the sounds to play by switching to this instead. No more warnings and everything works.

[code]
local path = system.pathForFile( filename, system.DocumentsDirectory )

local file = io.open( path )
if file then
io.close(file)
playWord = audio.loadSound( filename, system.DocumentsDirectory )
audio.play( playWord )
else
print(“File does not exist”)
end
[/code] [import]uid: 138352 topic_id: 8782 reply_id: 130717[/import]

I am trying to load a sound file in the simulator and it fails. I am on Mac using Version 2012.929 (2012.10.5)

Simulator output:
2012-11-12 09:18:56.100 Corona Simulator[7241:f03] File exists
2012-11-12 09:18:56.100 Corona Simulator[7241:f03] WARNING: Cannot create path for resource file ‘/Users/username/Library/Application Support/Corona Simulator/Appname-62E8EEEE864DC266B5288AC1B9F8D60C/Documents/test.wav’. File does not exist.

2012-11-12 09:18:56.100 Corona Simulator[7241:f03] WARNING: Failed to create audio sound (/Users/username/Library/Application Support/Corona Simulator/Appname-62E8EEEE864DC266B5288AC1B9F8D60C/Documents/test.wav)

[code]
local path = system.pathForFile( “test.wav”, system.DocumentsDirectory )

local fhd = io.open( path )

– Determine if file exists
if fhd then
print( “File exists” )
io.close()
end

local wordSound = audio.loadSound(path)
[/code] [import]uid: 138352 topic_id: 8782 reply_id: 130705[/import]