music vs sound technical discussion (why not always use play sound and .oggs?)

floydianspiralfloydianspiral Member, PRO Posts: 308
edited October 2012 in Working with GS (Mac)
So I've been making a generative music game with A LOT of sound files, I'm already up to 100MB and am not even halfway done. I was an audio major in college so the technical side of me wants to know why anyone would ever use the play music behavior over the play sound one? I know it says "music" is supposed to be for over 30 seconds but it let's me import .ogg over 30 seconds as sound. I've used an AAC, mp4, etc for the play music behavior and it works fine, and then I tried the same thing with a .ogg (imports as sound) and it appears to work the same in terms of RAM and stability. I'm tempted to make everything .ogg because the file sizes are way smaller, I'll continue to do tests and see what the eventual outcome is but was wondering if anyone else knew of a reason why I should not use play sound all the time for all "music" purposes...

Comments

  • floydianspiralfloydianspiral Member, PRO Posts: 308
    @SaladStraightShooter any chance you could ask the dev team? I've read all the documentation and have been a user for a while but having one of the audio programmers' opinion about why you would ever use the play music option as opposed to using all play sound .ogg's is still a mystery to me...
  • HoneyTribeStudiosHoneyTribeStudios Member Posts: 1,792
    M4a/aac files are decompressed in hardware with ios devices. And we can only play one at a time.

    I think ogg files will be run in software which is why we can play multiple files at the same time.

    So I find that m4a tracks don't add to the RAM usage. Whereas ogg files do. So a 5 min song imported as a 'sound' will take up a huge amount of RAM.

    Unless you have a specific purpose for a long track e.g you want to adjust the pitch in-game or play multiple tracks at the same time - then I think it's best to stick to importing as 'music' which is m4a/aac tracks.


  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    Plus with music files you have access to the pause and stop music behaviors.
  • floydianspiralfloydianspiral Member, PRO Posts: 308
    @HoneyTribeStudios thanks Shaz. After looking up the difference in xCode docs it seems that play music behavior utilizes AVAudioPlayer which indeed decompresses in hardware rather than software, which would lead to less RAM use. It seems that for playing sounds there are a lot of different ways to implement in xCode so my guess is GS is using some form of OpenAL because of the positional sound and pitch-shifting capabilities. I wanted to do a comparison of using a .ogg file of my background music which is 1:45 as a play sound vs the same file but as an AAC instead in an almost identical play session and here are the results

    Play Sound vs Play Music
    images: 8.6 8.6
    sound: 72 58 (only 14mb)
    game engine 18.4 17.3
    other: 23.7 22.3
    total ~119 ~106

    the numbers don't exactly add up because of how quickly they change (I'm triggering lots of sounds/particles every second). It would seem that the difference is clear that I should use the play music behavior from the numbers but the thing is the frame rate and play experience is identical (or enough to not notice a difference). I'm usually running 20-30 fps in either, which is fine for what I'm doing. So, I'm still skeptical about whether play music is really going to help me in the long haul. The AAC .m4a file is 1.6mb and the .ogg is 1.8mb so not too much difference in terms of storage.
  • SearleSamaSearleSama Member Posts: 108
    from a developers point of view I use the play music behavior so that I can pause the music then resume it. I do this alot when I have menu changes happen or a special power is being used. similar to sonic or mario when you get the star power another sound plays (i.e. the mini song would be a sound file, < 30 sec) but when the power ends the previous background music resumes. This is easily achievable with GS using play and pause music behaviors.
  • floydianspiralfloydianspiral Member, PRO Posts: 308
    @SearleSama and @FryingBaconStudios thanks...sorry my title is a little misleading, I'm well aware of the stop/pause/resume of the play music behavior and wanted to talk about if there is any reason RAM/FPS wise someone would use music vs sound.
  • SearleSamaSearleSama Member Posts: 108
    Gotcha, I'd be interested to know about this too, I have an idea for a music beats sequencing game.
Sign In or Register to comment.