Archive for the ‘Sound’ Category


How Much Hair Pulled Out is too Much?

My audio issues are becoming increasing frustrating. This morning I decided I would try to simplify things. I had seen other apps handle the music thing like this: if the user is playing their own music when the game starts, let their music keep playing; if the user isn’t playing music when the game starts, play the game’s music. I figured this would be easier to implement (and it should be).

I got curious about how other games handle things like this: start the game with no music playing, then attempt to start music via the quick music pop-up (double-tap the home button to bring it up anywhere on your iPhone/iPod touch) once the game is running (this causes my game to hang right now). I started going through other games on my iPod touch and tried combinations of starting with and without music. I ended up with all sorts of problems: games freezing, music refusing to play, the iPod’s music player jumping around between albums even though it’s not set on random, games playing music the first time I boot them, but then refusing to play music and refusing to accept touch events the next time I boot them.

For example, I booted Rolando while my own music was playing. The game kept playing my music and allowed me to play fine. I quit the game and stopped my music. When I reentered Rolando, no music played (including game music) and touch events had a 5-10 second delay on them rendering the game unplayable. It seems unlikely that this is a problem with the game as I experienced similar behaviour with other games. This is what I like to call “Good Times”.

In short: I’m not sure my iPod touch is stable anymore. I’m wondering if some of the bugs I was seeing are problems with the iPod? Or perhaps my bugs caused problems with the iPod? I’m tempted to do a hardware restore and see if things become more stable. Rebooting the device doesn’t seem to be helping much.

In non-audio related news, Gamasutra has a feature article up today about iPhone game development in 2009:

Now if you’ll excuse me, I’ve got an iPod touch to wipe out.

Owen


Audio Problems

If there is a God of programming, I think it is a vengeful God. I think I’m being punished for saying that I was a pretty good programmer the other day…

I’ve spent the last few days trying to getting Audio Sessions working with the game. Audio Sessions are the iPhone’s way of handling audio priorities. Basically, your iPhone app has little control over audio priorities on the device; you set up an session inside your app and tell the iPhone how you want it to treat your audio: should your audio stop the user’s music from playing when it launches, or should it mix with whatever other audio is playing, for example.

I followed through some example code and I thought I had things working, but it’s not working at all. I’m trying to do something a little more complicated than is standard: I’m trying to let the user decide whether the game’s music plays, or whether they want to hear their own music. They’ll be able to flip a “switch” in the game to change modes. From reading the docs, it looked like this should be straightforward. However, I’ve run into several problems:

  • I don’t get the audio interrupt calls I’ve registered for – this makes it hard to know when audio states have changed.
  • Changing the session category isn’t working – if I switch from a category where my music takes priority to one where the user’s music is supposed to have priority, their music doesn’t play.
  • Changing categories is causing serious crashes – I don’t know why this is happening, but if I change categories and play/stop/play user music in a certain order, I can lock up the iPod touch I’m using. It won’t even let me shut it down unless I hold the “off” button down for 60-120 seconds, eventually it kind of shuts down in stages and reboots, but then the audio system is all screwed up until I do a second manual shutdown of the iPod. Not good. The real kicker here is that the debugger disconnects from the device as soon as it locks up, so I haven’t been able to tell what’s going on. Awesome.

So today has been a rather frustrating day so far.

I’m starting to wonder if it’s worth re-writing my whole audio engine to use the new audio system that was introduced in OS 2.2. The downside of that is that my game would require users to be upgraded to OS 2.2 and I can’t find any data on what percentage of users that is. For now I’ll go back and re-read the audio session documentation, I think.

Owen


I’m Baaaack

Happy New Year, everyone! I hope that 2009 holds good things in store for you.

I’m back at work today after being off for over a week. The break has been great. I had expected to work quite a bit over the holidays, but I didn’t end up doing any work. I think it was good for me to get away from the game for a while and hopefully I’ll be able to come back to it fresh. The next month is going to be extremely busy and tiring, so I’m glad I took the time to relax a bit before the big crunch.

Seeing as how we’ve entered into 2009 (that sounds like we’re living in the future, doesn’t it?) I thought now would be a good time to go over some of the lessons I’ve learned so far about indie development:

  • If at all possible, separate your “work space” from your “life space”. I’ve been working from home for 6 months now and I love it. However, my wife and I live in a tiny (under 600 sq feet) apartment so my office is in the same room as the living room and dining area (the whole room is only 12 x 12 feet). While this didn’t bother me at first, the longer I work here the more I find it difficult to separate work from not-work. When I’m on the couch watching TV, my computer is almost right next to me and I often end up thinking about work when I should be relaxing. When we can afford to move into a bigger place, my main requirement will be that I have a separate room for my office.
  • The idea is easy, the implementation is not. This is not a new lesson for me, this is something you learn very quickly when you start working in the industry. However, when you’re doing everything on your own, it becomes even more apparent. I spent nearly the first two months of the project just prototyping. I had what I knew to be a great idea for a game, but it took me two months of trying different implementations to find something that was really fun to play. I’ll admit it: that surprised me. I was convinced that the original idea I had would be fun, but it wasn’t. The game I have now uses the same core mechanic (mixing paint colours), but the game is totally different from what it started as.
  • Game development is expensive. Don’t let anyone tell you that it’s not. Granted, start-up costs for a business like this are significantly lower than a business that requires retail space, inventory, employees, etc, but it still costs money. However, I did have hardware and software costs, contractors to pay, etc. I also realise that my budget is minuscule compared to a 10-30 million dollar blockbuster title. However, it’s my money that I’m putting up for this. Maybe I should have looked for investors at the start, I don’t know the answer to that. I like that I have complete control over the product I’m developing. For better or for worse, the game is mine. When the game is released I’ll provide some budget numbers (don’t expect a detailed breakdown, it’ll be very high level), but for now it’ll have to wait.
  • Ideas generate ideas. Several months ago I posted an entry stating that every day I was going to try to write down an idea for a gameplay concept, a game mechanic, an environment. The idea was to build up a massive document of ideas that I could draw from. This worked really well for a few weeks. Forcing myself to come up with ideas grew new ideas. It was a great cycle to get into. However, as the game development gathered momentum, I stopped writing in the ideas document. Without forcing myself to come up with new ideas, fewer ideas were being formed. I had an idea this morning that I wrote in the book and noticed that my last entry was Oct 30th. I need to get back into the habit of doing this. It will be very important as I finish Dapple and get ready to move on to my next game.
  • Don’t try to do it all yourself. This is really about knowing your limitations. I’m not trying to be egotistical, but I’m a pretty damn good programmer. I’ve been doing it a long time and I feel like I know what I’m doing. I’m confident in my abilities to solve problems of a programming nature and that I can learn the things that I need to learn. However, I’m not a professional artist. I’m not a musician. I’m not a sound designer. I think a lot of indie developers are tempted to do it all themselves. It’s that attitude of “I know how to use Photoshop; I took an online course,” or “I took an art class in high school that I was pretty good at” that gets people into trouble. When I started I was tempted to do the artwork for my game myself because, yes, I am fairly proficient with Photoshop, and yes, I did take a lot of art courses in high school and university. However, I realised that by doing so, I wasn’t playing to my strengths. I realised that my time would be better spent programming and paying someone whose job it is to create art, to create the artwork for my game. I think this was the correct decision. I’m extremely happy with the artwork, sound design and music I got from the people I worked with. While it cost me money instead of just time, I think I’ve got a much high quality game with a lot more polish out of it.
  • Have fun! It seems like an odd one to have to state, but at the heart of things, I’m doing this because I love doing it. There are times where it feels overwhelming, like it’s not worth it, that it’s just too much work and too much risk. Those are the times where you need to step away from the development and remember why you started doing this in the first place: I’m doing this because I love making games and I want to make the best game I possibly can. What’s better than that?

Happy 2009 everyone!

Owen


Keep On Keepin’ On

My goodness, two days since my last post! I’ve been busy.

As I somewhat expected, I didn’t get any responses from the press release-type emails I sent out. I think I need a different campaign. I think I need to contact editors directly with personal emails, instead of generic ones. I’m going to hold off until I have a version of the game that I can send them as a preview though. I don’t want the press playing the game I’ve got just yet. It needs more polish before I let reviewers have a peak at it.

Yesterday I got two big things done: I implemented the save system for the game and I implemented the High Scores screen. The save game system was surprisingly easy to set up. I had already set up a user data save system for the game options, so it was mostly a matter of determining how to store the game state and when/where to read and write it. The cool result of it is that the game now saves your state if you leave the game and you can resume it the next time you boot it up. That was pretty cool the first time it worked.

The High Scores screen seems less exciting, but it was probably the most complicated screen in my front-end, so it feels good to have that done now. I had been putting it off, but now it’s done and it looks great. However, I did have to make one design decision which may annoy some people: I had to limit the user’s high score name to 8 characters. That’s all that will fit on the high score screen. It was either that or truncate the name in the score screen at run-time, but I figured it was better to let the user see that their name is being truncated while they’re still able to change it.

Oh, and some bad news about my audio memory leak from last week: it hasn’t gone away. Apparently it went away in the one test case I had used. When I put the full music tracks back into the game, the memory leak appeared again. As far as I can tell, the leak is occurring in an OS level call, so I’m not really sure what to do about it next. I’m going to put it on the back-burner for now while I continue with feature implementation. It’ll have to get fixed during bug fixing time.

Another big step forward for the game this week: my artist delivered the last of the artwork to me. Now it’s all up to me to get it into the game. Very exciting stuff!

Owen


Now With 100% Fewer Memory Leaks!

This post is probably only of interest to other programmers, but hey, don’t let me stop you from reading…

I got back into the code today and I was trying to get multiple music tracks to queue up one after the other using the SoundEngine code. I was having some problems and so I went onto the developer forums and discovered that a lot of people have had problems with SoundEngine. Apparently it had a lot of memory leaks and other problems. Some of the leaks have fixes on the forums. However, what was most shocking was to discover that Apple has pulled all of the example SoundEngine code off the developer site. They’re basically telling people not to use it anymore.

With the latest public update to the SDK there are preferred ways to do audio. The problem is, they only work on devices running the 2.2 SDK. I want my game to run on anyone’s iPhone or iPod Touch, so I’m trying to support 2.0.

I managed to track down a bug in the SoundEngine code that was preventing more than one music track from playing and then decided it was time to boot up Instruments (Apple’s cool performance analyzer) to have a look for memory leaks. There were quite a few, all of them coming out of the fix I’d just put in place for the audio system. Ugh.

I spent the afternoon tracking stuff down and I’ve finally fixed all the leaks in the game (for now). I can also queue up multiple music tracks. Hooray!

I did want to post a couple of things I learned today about tracking down leaks with Instruments:

  • You need to launch your iPhone app directly from Instruments (you can’t track leaks in an already running iPhone process).
  • Once you find leaks, go to “View” -> “Extended Detail”. I can’t tell you how important this is! I spent an hour chatting with a friend online trying to find a way to get a full stack trace for the leaked memory allocation. It turns out it’s all in that little hidden window! When you open the Extended Detail window and click on a memory address that leaked, it will show you a full stack trace that lead to the leak.
  • Double-clicking on a function in the Extended Detail stack trace will open the source code to the exact line in XCode!
  • You can’t create custom DTrace instruments for use with an iPhone, they appear to only work with Mac OS X processes.

Now that I know a bit more about how to use it, I’m quite impressed with Instruments. It seems to be a very powerful tool.

Owen