Music cutting out, stuttering etc

I’m having a problem with the playback of my game’s music, but only on some phones. The problem is that the music will cut out or stutter, then play fine for a few seconds, then cut out or stutter again.

So far, this is happening on: an iPhone 4 running the iOS5 beta, an iPhone 3G.

However, it doesn’t happen for any of my testers using iPhone 4 and iOS 4. Nor does it happen on one of my testers iPhone 3G.

I can’t replicate it on my own iPhone 4 at all, and have never had this problem with the music.

Is this a known issue? Can anybody suggest why it may be happening?

Any info greatly appreciated. [import]uid: 26769 topic_id: 13534 reply_id: 313534[/import]

I’ve noticed in on iPhone 4 and in simulator.

Its like the music skips and then never catches up to its correct place, its continue to just skip and skip.

Best way to replicate it ive found is to open Open Feint when an mp3 is playing and jump between screens. This nearly always makes it happen. [import]uid: 5354 topic_id: 13534 reply_id: 53048[/import]

Im managed to write around it and now im getting much better playback.

  1. I dropped all mp3 files from 128kbps to 96kbps, that sorted it stuttering when OpenFeint was holding up the cpu.

  2. In my config.lua I added “audioPlayFrequency = 44100” and every file is now at that freq

  3. The other places it happened in the game were at times of high cpu load, usually restarting a level or when the player dies. Both these occasions did a lot in 1 cpu cycle, reset levels, destroyed objects, played game over music and sfx.

I moved the music changed over to the last thing that happened in the loop and I also put a gap between loading the track to the channel, rewinding it and then playing it.

[code]

– Start Music
local function startBackgroundMusic()

– Play Music
if settingMusic == “on” and gamePaused == false and not audio.isChannelActive( 1 ) and backgroundMusicTrack ~= false then

– Play Track
audio.play( backgroundMusicTrack , { channel = 1 , loops = -1 } )

end

end


– Stop Music
local function stopBackgroundMusic()

– Check If Channel Active
if audio.isChannelActive( 1 ) then

– Stop Audio
audio.stop( 1 )

end

end


– Play Music
function playBackgroundMusic( gameMode )

– Game Paused
gamePaused = false

– Stop Music
stopBackgroundMusic()

– Arcade
if gameMode == “arcade” then

backgroundMusicTrack = assetTable[“backgroundMusicArcade”].sound

– Time Attack
elseif gameMode == “timeAttack” then

backgroundMusicTrack = assetTable[“backgroundMusicTimeAttack”].sound

– Menu
else

backgroundMusicTrack = assetTable[“backgroundMusicMenu”].sound

end

– Rewind Track
audio.rewind( backgroundMusicTrack )

– Start Music
timer.performWithDelay( 100 , startBackgroundMusic )

end

[/code] [import]uid: 5354 topic_id: 13534 reply_id: 53360[/import]

I will pass this on to the development team. It doesn’t sound right that openfeint should be causing these issues. Perhaps Openfeint isn’t freeing correctly or something.

[import]uid: 84637 topic_id: 13534 reply_id: 53361[/import]

@ Danny

OpenFeint can hold up the system and when using a 128kbps mp3 it was easy to replicate.

When you click the leaf icon, bottom right of the OpenFeint menu screen it goes online to download an ad banner in 4-5 different pieces, this is what causes the hit, things get jerky as it loads and fades in the images. To force a mp3 skip I found that if you kept flipping between that screen and a different one in OF it would cause a slow down. [import]uid: 5354 topic_id: 13534 reply_id: 53363[/import]

I’ve opened a support request with Ansca, but not heard anything about this issue yet. It is worrying, because our game is nearing completion, but we can’t release it in this state. [import]uid: 26769 topic_id: 13534 reply_id: 53353[/import]

We get this issue often…usually on an iPod 2G. We were assuming that it is a memory related issue as it tends to trigger when steam samples are changed or when we peg the processor (usually when panning the display around). However, if its an API problem…that would be nice to know.

We are still testing if the memory demands are truly pegged out on the XCODE simulator. [import]uid: 9492 topic_id: 13534 reply_id: 62395[/import]

I am also experiencing streaming music tracks cutting in and out on certain devices. From my observations it seems related to CPU usage rather than specifically Openfeint.

For example, on an iPad2 the streaming tracks never cut out, but on an iPhone 4 the streams cut in and out constantly whenever I finger swipe around the screen. Swiping is the main control mechanism of my game so the audio sounds totally messed up during normal play. Even on certain menus where there are large amounts of graphics being moved around during a swipe the music stream will cut in and out.

Both devices are running iOS 5, and I’m using daily build 644, although I’ve been having issues with streams cutting out for months, ever since I switched over to the (not so) new audio API.

I’m going to play around with some of Matthew Pringle’s suggestions, although I’m pretty sure I tried most of them a few months ago when I tried to get to fix it (and gave up).

I know there are some undocumented and/or unsupported aspects of the audio API. Has anyone tried using any of those to deal with this issue? I don’t really understand most of what I’ve read on the forums about those features so I’ve shied away from messing around with them. [import]uid: 9422 topic_id: 13534 reply_id: 62495[/import]

So, based on Matthew Pringle’s post I went back to my source audio files and, using Audacity, re-exported them as 22050Hz, 96kbps Mp3s and… that fixed the audio drop-outs on devices!

Well, I still hear a couple very minor glitches, but the problem is 99% fixed which is good enough for me.

I had previously set audioPlayFrequency = 22050, but the audio streams themselves were saved at 44.1Khz, 256kbps. That discrepancy might have contributed to the problem, or perhaps the bandwidth was too high with everything else I’m pushing on the CPU during gameplay, but for now it is fixed at the cost of slightly lower fidelity music.

Thanks for the ideas, Matthew! [import]uid: 9422 topic_id: 13534 reply_id: 62538[/import]

We’ve done some more testing and this seems to definitely be associated with the processor. When the processing gets burdened with graphics, the audio gets mis-handled and never recovers. The only way to clean up the audio stream is to restart the app.

Everything works fine at the start which shows me our code works…but if you overwork the processor the audio drops out and stutters (on slower devices). We were able to get this to happen mostly on an iPod Touch 2G as the iPhone 4 and iPad seem to have enough processor power to handle the load demands.

Not sure what else to do to fix this as we’ve tried all sorts of workarounds. We are out of ideas and hoping for an Ansca recommendation and/or daily build fix. [import]uid: 9492 topic_id: 13534 reply_id: 63032[/import]

I had a similar problem and here’s how i solved it.

I was streaming my music and using MP3’s.

Problem was that an MP3 is a compressed music format.
So not only did the phone have to read and play the music on the fly but also uncompress it.

Causing jutterness.

I switched to wav and the problem went away. [import]uid: 91798 topic_id: 13534 reply_id: 66371[/import]

Does anyone have any other suggestions?

I tried using uncompressed .wav, and tried using a 56kbps at 22050 (and setting [lua]audioPlayFrequency = 22050[/lua] in config.lua) but neither had any effect, and I’m still getting stuttering audio (on iOS device only - iPod Touch 3g) [import]uid: 49447 topic_id: 13534 reply_id: 67323[/import]