about:benjie

Random learnings and other thoughts from an unashamed geek

iPhone Music and Sound Effects in Parallel

| Comments

I was trying to find out how to use [MPMusicPlayerController iPodMusicPlayer] and AVAudioPlayer in parallel. I’d read before that I’d need Audio Sessions, but the documentation for that was huge and confusing. Fortunately Andrew pointed me at this post from Mark at Sputnik Games which solved my issue immediately just by copying and pasting 14 lines of code into the applicationDidFinishLaunching method of my application delegate (see below). Sputnik Games’ blog doesn’t seem to support comments, so I thought I’d buy his latest game, Aerolite, and write this post to show my appreciation. Thanks Mark!

Add to applicationDidFinishLaunching to enable music & sound effects at the same time
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
OSStatus result = AudioSessionInitialize(NULL, NULL, NULL, self);
if (result) {
  // Init error, handle error here
} else {
  UInt32 category = kAudioSessionCategory_AmbientSound;
  result = AudioSessionSetProperty(kAudioSessionProperty_AudioCategory,
                                    sizeof(category), &category);
  if (result) {
      // set audio session error, handle error here
  } else {
      result = AudioSessionSetActive(true);
      if (result) {
          // Set audio session active error, handle error here
      }
  }
}

N900: First Impressions

| Comments

This post is part 2 of a three part series. You may also be interested in: Part 1: N900: the tale of the indestructible box Part 3: N900: a phone for hackers? (coming soon…)

After conquering the indestructible box and charging the N900 I decided to have a quick play. I watched the getting started video which I found to be both beautifully smooth, showing off the high definition of the N900 screen immediately, and somewhat slow content-wise.

G1 (top), N900 (left), iPhone 3GS (right)

The N900 is similar in width and height to the iPhone but

N900: The Tale of the Indestructible Box

| Comments

This post is part 1 of a 3 part series. You may also be interested in: Part 2: N900: first impressions Part 3: N900: a phone for hackers? (coming soon…)

A week ago I was contacted by Lydia of WOMWorld.com/nokia who asked me if I would be interested in receiving an indestructible box. I was told that she found me via my twitter profile and felt it would appeal to my passions. After confirming the email was not spam I replied, intrigued, “yes please” and sent her my address.

4iP Funding for GymFu

| Comments

image GymFu (that’s Jof Arnold, Jem Gillam and myself) has received just shy of £100,000 funding from 4iP (an angel/investment arm of Channel 4) to work on a new project improving the health of the nation in bitesize chunks. This is obviously very exciting for us all, but I’m afraid we can’t tell you any more until details are firmed up, though I can tell you that you should see output from this project by the middle of next year. Wish us luck! Why not read 4iP’s press release and TechCrunch’s take on the funding?

MythPyWii Power Update (V17)

| Comments

Myth tv logo from Wikipedia

Thanks to Matthew Zimmerman for sending me his modified version of MythPyWii, it now has power-saving - after 35 minutes of inactivity the Wiimote turns off. You can download the latest version, as always, here; or you can get this specific version (v17) here. I love open source!

Arduino Pin Speed (Multiplexing)

| Comments

image

I’m working on a new project, I’ve got a 8x8 dual colour dot matrix display (£2.50 delivered from Earthshine Design) and I want to power it from the Arduino. One way of making a chip like that (which has 2x8x8 = 128 LEDs) would be to have a common ground and an additional 128 pins - one for each LED. This, I think you’d agree, would be a nightmare, so instead they’ve basically gone for an 8x16 grid for a total of 24 pins. This raises two main problems:

  1. You can’t turn 2 arbitrary LEDs on at the same time unless they are on the same row/column. (Doing so would actually draw a square of LEDs.)
  2. My Arduino doesn’t have enough digital input/output pins

Point 1 is easily solved - we simply update just one row at a time, letting Persistance Of Vision (POV) do the hard work for us. Point 2 is the subject of this post - multiplexing, combining multiple individual signals into just one signal. I will not be using this dot matrix display in this post, instead I will simply be powering normal LEDs. I wanted to find out if the Arduino is fast enough to multiplex the data through just a few pins in order to power this display. The answer (one of my favourite answers!) is: “Yes, but not without some hacking.”

OSStatus iPhone SDK Meanings

| Comments

Image representing iPhone as depicted in Crunchbase

If you’ve got a line like this:

1
 LOGGING_FACILITY1( sanityCheck == noErr, @"Problem adding private key, OSStatus == %d.", sanityCheck );

But you don’t know what the OSStatus value means, and you’re devving on iPhone, here’s the answers:

OSStatus definition - what the different codes mean.
1
2
3
4
5
6
7
8
9
10
11
12
 enum
 {
 errSecSuccess                = 0,       /* No error. */
 errSecUnimplemented          = -4,      /* Function or operation not implemented. */
 errSecParam                  = -50,     /* One or more parameters passed to a function where not valid. */
 errSecAllocate               = -108,    /* Failed to allocate memory. */
 errSecNotAvailable           = -25291,  /* No keychain is available. You may need to restart your computer. */
 errSecDuplicateItem          = -25299,  /* The specified item already exists in the keychain. */
 errSecItemNotFound           = -25300,  /* The specified item could not be found in the keychain. */
 errSecInteractionNotAllowed  = -25308,  /* User interaction is not allowed. */
 errSecDecode                 = -26275,  /* Unable to decode the provided data. */
 };

iPhone SDK Upload Issues? Blame Apple’s “Compress This” Feature.

| Comments

Apple Sucks

If your app won’t upload but you’re sure you’ve compiled it and signed it right, the fault might not be yours. For me, it was the built in “Compress [Folder]…” option - the archive produced from this might be missing files. You’re likely to see such errors as: “The binary you uploaded was invalid. The signature was invalid, or it was not signed with an Apple submission certificate.” “Icon specified in the info.plist not found under the top level app wrapper” Seriously, Apple, what the f*ck? Thats 2 hours of my life lost because Apple couldn’t nail the basics: an archive utility. I’m so angry right now.