Playing sound high resources

I have written a canvas game, its delivering 60+ frames a second until I add sound effects, then I am lucky to get 10 and the canvas redrawing is stuttering pretty bad. I have even put the sounds in a thread, makes no difference.

I have tried mp3 and wav files, all less than 30k. Is there an issue with sound? is there a preferred audio format for performance?

HELP, want to put this app in the app store but with any sound effects I expect it will be rejected on performance grounds.

[quote=168473:@dave duke]I have written a canvas game, its delivering 60+ frames a second until I add sound effects, then I am lucky to get 10 and the canvas redrawing is stuttering pretty bad. I have even put the sounds in a thread, makes no difference.

I have tried mp3 and wav files, all less than 30k. Is there an issue with sound? is there a preferred audio format for performance?

HELP, want to put this app in the app store but with any sound effects I expect it will be rejected on performance grounds.[/quote]

You may want to delegate the sound business to a helper app. The principle is less complicated than it sounds.

Create an app with no window which sole purpose is to play the sounds. Then from you game, launch it. Use IPCSocket to communicate with it so you can instruct it which sound to play, stop, etc.

You can see how IPCSocket works in the examples/Communication

Since the helper app is completely separated from your game, it will not slow it down a bit. In fact, it will run on its own core, so you will get true multitasking.

To package your app for the store, use a copyfile to place it in Resources, and for use launch it from there.

You will have to use App Wrapper 3 to sign it. App Wrapper Mini will not be able to sign the helper. Or use the -deep option if you sign from the command line.

Heres is a link to part 1 of a 3 part series on iOS audio formats at Ray Wenderlich.'s iOS programming site. Just glanced at it but is should have the info you need.

[url=http://www.raywenderlich.com/69365/audio-tutorial-ios-file-data-formats-2014-edition]audio-tutorial-ios-file-data-formats-2014-edition/url]

link text

If you had posted in the iOS channel, I would have not suggested a helper. In iOS there is no way to use a helper.

Why not use an actual game engine?

'cause there is none yet for Xojo ios ?

Dave, I believe you need to use a different file format for your sounds. Try one of the formats which is uncompressed and see if there is an improvement.

This is very disappointing, back in '06 we created a canvas based game with sounds affects and had no problem like this… Hard to believe that 9 years later and it can’t be done on a phone (with a CPU & GPU which is most certainly better performer than the Mac/Windows machines we had then).

I’m sure there is some magic you’re missing somewhere.

I suppose you have tried to set the sound thread to PriorityLow and use as low as possible sampling rate (see link from Robert Schofield) to save as much as possible computing power ?

The phone circuitry is amply able to play music without hindering the performances of a program. I am sure the magic is inside Core Audio.
https://developer.apple.com/library/mac/documentation/MusicAudio/Conceptual/CoreAudioOverview/CoreAudioEssentials/CoreAudioEssentials.html#//apple_ref/doc/uid/TP40003577-CH10-SW1

Time for declares…

The lower the bitrate, the less it will be taxing on your app. Have you read this
http://www.raywenderlich.com/69365/audio-tutorial-ios-file-data-formats-2014-edition ?

I shall think the best is 32 kbit. The sound will be less quality, but it will require less resources.

See also
http://www.raywenderlich.com/69367/audio-tutorial-ios-converting-recording-2014-edition

to convert your existing background music.

For the moment. But we are 64 bit with 2015R1 just issued on 64 bit phones.

That is possible in Mac OS X because an app can start another process. That is forbidden in iOS.