Game Performance and audio

jhaasjhaas Member Posts: 233
I've noticed that up until I add sound files to a game I'm working on everything work just fine. Once I add the mono 22khz sound effects files(about 8) and I play the game for about 10 minutes - I start seeing the game freeze and jitter occasionally.

Anyone else notice the same thing? Is this the .ogg files? I've also tried importing .wav files and allowing GS to do the conversion - no change.

Maybe the game engine needs some more work in the audio dept? It shouldn't bog down simply playing the same sound files over and over - it's sort of what a game engine is supposed to do. :)

Comments

  • scorelessmusicscorelessmusic Member Posts: 565
    For me, thanks to a tip, I've been using .caf files and not looking back. :) Simply by switching to .caf (mono, aac format), my app Mozart To Infinity went from sure-to-crash even on 3G to smooth-to-approve even on 1st gen iPod Touch.
  • JGary321JGary321 Member Posts: 1,246
    scorelessmusic - I don't use terminal much. Can you post exactly what you typed to convert? I used Max to do the switch, but I wanna try your way to b/c Ma did not give an option for mono.
  • rebumprebump Member Posts: 1,058
    Cobra from GS says:

    "reducing the quality and/or number of channels in your audio files will help with both filesize and load time.

    In situations where you want high-quality audio, there's another option: the Apple CAF format. GameSalad will accept .caf files without converting them to .ogg.

    With CAF you have a choice of codecs. At the extreme end, uncompressed Linear PCM (16-bit little-endian) gives you CD-quality sound reproduction and will load lightning-fast, but will also increase filesize.

    Max is a good, free utility that can do batch conversion between sound formats."

    So I would be interested to know if you tried that (using CAF version of the file) if things ran any more performant!?
  • JGary321JGary321 Member Posts: 1,246
    @Rebump - It `seems` to have helped. Before it would stutter a little (3G) when a spell hit like 4-5 enemies. It `seems` to have helped switching to .caf, but I cannot say for certain. Either way I like the idea of having less load times even if the file size is larger.
  • scorelessmusicscorelessmusic Member Posts: 565
    I'm currently using a script... let me post it here:

    ##
    ## Shell script to batch convert all files in a directory to caf sound format for iPhone
    ## Place this shell script a directory with sound files and run it: 'sh converttocaf.sh'
    ##

    for f in *; do
    if [ "$f" != "converttocaf.sh" ]
    then
    /usr/bin/afconvert -f caff -d 'aac ' -c 1 -l Mono $f
    echo "$f converted"
    fi
    done

    -------------------

    If you're doing it to a single file, the command is :

    /usr/bin/afconvert -f caff -d 'aac ' -c 1 -l Mono <filename>

    Hope this helps!
  • scorelessmusicscorelessmusic Member Posts: 565
    in most cases, the path is already set so just typing:

    afconvert etc etc etc ...

    would be good enough.
  • JGary321JGary321 Member Posts: 1,246
    Thanks a lot man. I was trying to figure this out, but couldn't. I'm a lifetime windows user waking up from the dream & migrating to Mac =)
  • scorelessmusicscorelessmusic Member Posts: 565
    All the best with that, JGary321. If you need any help, we're all here to chip in. So to frame it in the Windows/DOS world, the shellscript .sh is like a batchfile .bat in DOS world.

    Some additional tidbits...

    1. I placed all the AIFF files I want to convert in a particular folder
    2. Then launch Terminal
    3. To change directory, the same as DOS with the 'cd' command but here's a quick tip...
    3a. You can type 'cd ' (and space) then drag and drop the path from the GUI
    - do this by dragging the small icon of the folder next to the folder name at the top of the folder window into the Terminal window
    - especially good for long paths
    4. Once in the right path, you can execute the .sh by typing ./<shellscript filename>
    5. Have to be sure that the .sh is executable using the 'chmod' command

    I'm not really an expert with the command line, but it has definitely saved me from a lot of work, especially for batch processing.
  • jhaasjhaas Member Posts: 233
    I've now converted my .ogg audio files with MAX to .caf using the A - Law encoder. I'm still having the same issue as before. After about 10 minutes of game play the game stutters occasionally.

    Is there a different setting of the MAX encoder that I should use or am I wasting my time trying to get any sound to work in my game?

    Again the game plays fine with no stuttering with no sound effects.

    Any suggestions?
  • scorelessmusicscorelessmusic Member Posts: 565
    I will be attempting my first GS game soon and hopefully will gather some meaningful tips along the way. So far, all my experience has largely been just handling audio with very minimal UI interaction and other actor activity.

    Personally, I doubt that the audio alone is throwing up problems since my music app runs smoothly through the night (at least 7 hours). And you can be sure that even a 0.01 second delay will be noticed when it comes to music being assembled on the fly.
  • jhaasjhaas Member Posts: 233
    The funny thing is I'm not seeing an increase of memory usage over time - or any other resources. (Based on what I can see in GS.)

    All I know is when I run with no sound effects - no issues.

    Maybe it's the combination of the on screen activity and the way the engine handles repeatedly playing the sounds over and over that causes some resource constraint?
  • PhoticsPhotics Member Posts: 4,172
    I switched all my audio files to .caf ...and then my game had no sound! :-p

    The .ogg file format seems to be a problem for GameSalad... but .caf or the other format for GameSalad, didn't work out for me either.
  • jhaasjhaas Member Posts: 233
    When converting to .caf - I had to use the A-law or U-law encoding option in MAX. 8 or 16 bit didn't work inside GS. :)
  • scorelessmusicscorelessmusic Member Posts: 565
    Well, I am 100% sure .caf works as that's what I solely use in Mozart To Infinity which is now a paid app on the App Store. :) It was converted using the command line 'afconvert' using the script I posted above.
  • rebumprebump Member Posts: 1,058
    @scoreless: so what loading and/or performance changes did you see using .caf (or did you just use .caf from the get go)?
  • JGary321JGary321 Member Posts: 1,246
    I didn't see any improvement personally in load times. Still takes 30 secs to load. However, I only have a couple sound files anyways, so that probably not the main issue.
  • scorelessmusicscorelessmusic Member Posts: 565
    I think there might not have been a measurable change in load times moving from .ogg to .caf which in mono aac is quite compressed and really small in filesize. The most significant change for me and the reason why I'm always using .caf mono aac now is the single fact that it does not crash anymore.

    Mozart To Infinity with audio files in .ogg = crash on everything but iPhone 3GS
    Mozart To Infinity with audio files in .caf = performs even on 1st Gen iPod Touch

    Considering the fact that I did not change any part of the code, it's probably reasonable to assume that the process of converting to .caf helped with stability issues.

    Moving forward, all my projects now are using audio files in .caf (mono, aac) until we experience something different with GS updates or new info from GS HQ.
  • chosenonestudioschosenonestudios Member Posts: 1,714
    @scorelessmusic, how are you converting your files? are you using max? if so how do you change the quality settings and such for .caf because everything ive done so far has been 50mg +!
  • scorelessmusicscorelessmusic Member Posts: 565
    @chosenonestudios as mentioned above, I'm using the command line in Terminal. It's really geeking out so I probably won't recommend it to people unfamiliar with typing commands in Mac OSX Terminal window. Who knows if GS does something along these lines and we see greater control or options in future releases which allows invisible importing via the 'afconvert' utility found in every Mac (command line), or even batch conversion and import/delete management (that would be a sweet feature).

    In terms of just file sizes, here's what happened to Mozart To Infinity:

    1. Total number of audio files = 272
    2. Total size in AIFF = 166.8MB
    3. Total size after .CAFF conversion using afconvert = 12.8MB

    Because it's a command line program, it allows us to write a script to automatically go through an entire folder of AIFF files. Just imagine the amount of blood I'd be coughing out if I had to convert 272 clips by hand! :-O~
  • SDMGSDMG Member Posts: 280
    I have made a simple lcd game with 2 sounds (ogg-format, each 4 KB... beep! and bam!)
    I can play my games for 3-5 Minutes and then each 30 sec. it slows down for 10-20 fps and your player dies!

    When i delete the sounds ...the game runs flawless...

    I will try to test the caf conversion above ( unfortunatly i have never used the terminal ;)

    These slowdowns with ogg files are very very annoying! (fix please!!)
  • maniraptormaniraptor Member Posts: 81
    Inspired by this (relatively) recent info, I'm trying cafs in my current project. I've run into some problems, though.

    The U-encoding files I made in Max didn't reliably play in the GS builder preview, so I took those out and replaced them with A-encoded files. These play fine in the preview, but they crash the app on the iPhone. (The app runs fine with no sounds and with oggs.)

    My next step is to try scorelessmusic's terminal processing for my files. Onward!
  • IcedBIcedB Member, PRO Posts: 384
    Thanks for this, I almost uploaded my game that is super sound intensive. I'm going to try converting all the files tomorrow. Just out of curiosity...
    Why does gamesalad auto convert to .ogg and not give an option for .caf when it knows that could save the designer ram usage?
  • coojamcoojam Member Posts: 26
    Did anybody ever have any success with this?

    I've tried all the various suggestions here with regards to sound effects causing noticeable stuttering. I have a sound effect that plays every time the player collects an object in game. Doesn't matter what effect I choose, how much I compress the chosen effect, what format (aiff, wav, mp3, caf), nothing seems to help.

    I'm using Max to convert an mp3 into a caf... should I be directly converting the original aiff?

    Thanks in advance.
Sign In or Register to comment.