Archive for the ‘Code’ Category

iPhone Music and Sound Effects in Parallel

Tuesday, April 6th, 2010

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!

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 } } }

Bookmark and Share

MythPyWii – now on Google Code

Monday, January 4th, 2010

Fancy submitting to MythPyWii? Let me know! It’s now on Google Code.

Code, documentation, bugs, bugfixes, etc all welcome!

Bookmark and Share

MythPyWii Power Update (v17)

Saturday, October 3rd, 2009
Myth tv logo
Image via 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!

Reblog this post [with Zemanta]
Bookmark and Share

Arduino Pin Speed (Multiplexing)

Tuesday, September 8th, 2009

I’m working on a new project, I’ve got a 8×8 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 8×16 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.” Read on…

(more…)

Bookmark and Share

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

Monday, June 22nd, 2009
Apple Sucks

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.

Reblog this post [with Zemanta]
Bookmark and Share

Calling All Southampton Hackers!

Wednesday, May 20th, 2009
City of Southampton
Image via Wikipedia

Before we start, just to be clear – this is not for crackers (people who illegally break in to computer systems) but for hackers (people who modify the software or hardware of their computer system including building, rebuilding, modifying and creating software and electronic hardware either to make it better, faster, give added features or to make it do something it was never intended to do).

UPDATE: we have a google group: http://groups.google.com/group/southackton

I’m intending on setting up a “Hackerspace” in Southampton targeted around software programming (for fun) and hardware hacking (e.g. robotics). I anticipate that people would attend the hackerspace either with their own personal projects (such as controlling their television using a Wii remote), or looking to join in on a cool project. The idea is that we can all share knowledge and help each other out in a fun and innovative environment.

I am provisionally calling this project Southackton, though I expect (hope!) a better name will surface once more people are interested! If you or anyone you know is interested, please contact me via email (my name at benjiegillam.com) or by leaving a comment on this post.

The ultimate goal would be having an “office” somewhere in Southampton where members can drop in any time (within reason) and get to work on their project/just hang out with fellow hackers. If you work from home you could even work form the Hackerspace directly – it wouldn’t be so lonely! I am, however, expecting that we would run it as a “club” until we have enough interested members to make it feasible. Whether this club be weekly, fortnightly, monthly, or bi-monthly is a matter for interested persons to discuss – get in contact and let me know what you think!

As you may know if you read this blog (doubtful!), I am a great fan of open source, and have been a dedicated GNU/Linux user for almost 10 years now, so Linux users would be cool to have as they tend to be interested in tweaking hardware/software, however everyone would be welcome independent of their choice of operating system. Yes, that’s right – even Windows users!

Further, there is no required skill level. I’m happy to have people attend who want to acheive something (e.g. making a webcam recognise who is sat at the PC and change the computers background to a related picture/have their favourite teddy walk towards them) but have no idea how to go about it, so long as they are patient and willing to learn!

I hope you’re interested – let me know!

UPDATE: if you’re interested, sign up to our google group: http://groups.google.com/group/southackton.

Reblog this post [with Zemanta]
Bookmark and Share

Useful Bash Scripts

Tuesday, April 7th, 2009
Bash
Image via Wikipedia

Here’s a couple of bash scripts I’ve written recently that might be of use to someone.They work well under Ubuntu, and should work under any GNU/Linux or Unix system with the suitable software installed.

Improved “svn diff” command (ignores whitespace, colour highlights output, requires colordiff) – I put it in /usr/local/bin/svndiff:

#!/bin/bash svn diff -x -w $@ | colordiff

Improved recursive grep command (greps recursively, ignores files in the .svn folders, ignores temporary files, highlights output in colour) – I put it in /usr/local/bin/grepr:

#!/bin/sh SEARCHTERM=$1; shift; find . -type f -a -not -iname "*~" -a -not -iwholename "*/.svn/*" -exec grep -H --color=auto $@ "$SEARCHTERM" "{}" \;

You might also be interested in my previous “whoops I deleted files without telling svn” post here.

Reblog this post [with Zemanta]
Bookmark and Share

SVN Hint: Automatically removing manually deleted files from SVN

Friday, February 6th, 2009
Bash
Image via Wikipedia

When deleting files in a working copy of an SVN repository you should do it on the command line: svn rm [filename]. If, however, you don’t do this (e.g. delete through a gui, or just do “rm” without the “svn“) then SVN gets confused, and puts a “!” in it’s status before all the deleted files. If you svn update, all the files will be recovered, rendering all your time spent deleting them wasted. Really you should use svn rm, but if it’s already too late for that, you can use this bash fragment to delete the files from SVN:

svn status | grep "^\!" | sed 's/^\! *//g' | xargs svn rm

This command does a status command, finds all lines starting with “!“, and then extracts the filename and runs it through “svn rm” – really deleting the file.

Caveats:

  1. Manually deleted files are not the only things that makes svn use “!” – so beware of this! Ensure you do really want to delete all those files!
  2. This works for filenames which are all_one-word/without/any.spaces but I am not sure if it will work or not for filenames with spaces in.
  3. Use at your own risk. The code is simple enough so you should be able to grok what it does.

Enjoy!

Reblog this post [with Zemanta]
Bookmark and Share

New Year: Get Fit With GymFu!

Tuesday, January 6th, 2009
PushupFu Demo

PushupFu Demo

I had intended to get fit (and thin) before my wedding last August, however that never happened. And before I knew it it was Christmas, with all that loverly food. I’m not stupid enough to try and diet over the Christmas period! Instead, I thought, what else is the New Year for if not improving ones health?

My business partner Jof and myself had been working on a fitness app for the iPhone, PushupFu, for a couple of months and we finally uploaded it to Apple on 23rd December. In a very generous gesture from Apple, the app was released on 1st January (or 31st December, depending where you live!) – a full week earlier than we were expecting. I find that the app definitely motivates me to do pushups when users challenge me, plus I also intend to complete the training course (should be done by May) – when I can do 100 pushups I will really feel fit! (Currently I’m still only able to do single figures, but I have only just started!)

So, if you feel you need to get a bit more toned this year, why not give it a go by visiting http://www.GymFu.com/ ? At time of writing we have 5 reviews in the App Store, all are 5 stars, so give it a go! Check out our other reviews below:

Reblog this post [with Zemanta]
Bookmark and Share

MythPyWii Bugfixes and Enhancements

Thursday, September 18th, 2008
Software Bugs

Image by FastJack via Flickr

I’ve just updated MythPyWii to handle the connection to Mythfrontend more smoothly, and to give feedback via the wiimote on error/disconnect. (i.e. if myth closes, the wiimote shakes, and the LED pattern changes to [ . # # . ] instead of [ # . . # ] just before the wiimote turns itself off). This means if there are issues connecting to Mythfrontend you can retry again simply by pressing 1&2 once more (fix any issues first though – e.g. closed mythfrontend/no remote interface enabled).

I’ve fixed a little bug with timestretching, and have also improved the timestretch responsiveness by emulating not just the left/right keys but also the up/down keys (which increase/decrease timestretch by 0.25 instead of just 0.05).

As always, download the latest version of MythPyWii here.

Ah hah, an update to Zemanta has just been released! Integration with Facebook and Flickr, eh? I best sign up for a Flickr account then, I suppose… Argh! They seem to have broken images with my theme – I fixed it by adding this CSS to my theme (copied from firebug):

.alignright { float:right; } .wp-caption { -moz-border-radius-bottomleft:3px; -moz-border-radius-bottomright:3px; -moz-border-radius-topleft:3px; -moz-border-radius-topright:3px; background-color:#F3F3F3; border:1px solid #DDDDDD; margin:10px; padding-top:4px; text-align:center; }

Reblog this post [with Zemanta]
Bookmark and Share