Jun 2007

iPhone SDK

As disappointing as the lack of an iPhone Cocoa SDK was at last week's WWDC and the 'controversial' techniques developers are encouraged to use to write applications for the iPhone, there is an application that appears to substantiate Apple's suggestions.

OneTrip is a shopping list web application specifically styled and built for the iPhone. It uses UI metaphors from the iPhone's applications, is styled sympathetically and is designed with features such as drag-scrolling and screen resolution in mind. Data storage happens on the server with cookies managing session identification so there is no user registration or login.

If all iPhone web applications are like this then maybe the current lack of a SDK it isn't such a disaster.

|

Multi-Channel Audio

Delivering forty channel audio using QuickTime APIs to adjust movie files.

A little while ago, Oliver (Watershed's ICT Co-ordinator) , asked me to write a small command line tool to set the audio output channels of a QuickTime movie. Oliver was writing software for Dream Director, a project that plays audio to people sleeping in pods in response to rapid eye movement.

A Mac mini plays back the audio to up to twenty pods (containing sleeping people) through a collection of M-Audio Firewire410 boxes. As the audio-out hardware units have been aggregated into a single virtual device with forty available channels, it was just a case of playing back a stereo file through a selected pair of channels.

QuickTime movies will save the audio channel mapping inside the file, so the requirement was to build a tool that would set the selected channels in a movie and save the file to disk. The source listing is for a Cocoa command-line Tool, using QTKit, to open an audio file, set the track mapping and save as a QuickTime movie.

QuickTime now uses Core Audio to handle the audio channel mapping and I thought this may be of some use to people. The partial listing below shows the code needed to map audio channels using QuickTime and a link to the source file of the tool is below the listing. Sorry about the wrapped source listing.

  1. Movie qtMovie = [movie quickTimeMovie];
  2. Track audioTrack = GetMovieIndTrack(qtMovie,1);
  3. AudioChannelLayout* trackChannelLayout = NULL;
  4. OSStatus err = noErr;
  5. UInt32 trackChannelLayoutSize;
  6. // Allocate a layout of the required size
  7. trackChannelLayoutSize = fieldOffset(AudioChannelLayout, mChannelDescriptions[2]);
  8. trackChannelLayout = (AudioChannelLayout*)calloc(1, trackChannelLayoutSize);
  9. trackChannelLayout->mChannelLayoutTag = kAudioChannelLayoutTag_UseChannelDescriptions;
  10. trackChannelLayout->mNumberChannelDescriptions = 2;
  11. // Adjust the channel Assignment so that for an index we get a pair of channel
  12. // allocations. The index starts at 1
  13. // index channelA channelB
  14. // -----------------------------
  15. // 1 discreet0 discreet1
  16. // 2 discreet2 discreet3
  17. // 3 discreet4 discreet5
  18. // 4 discreet6 discreet7
  19. // ... and so on
  20. channelAssignment = (channelAssignment-1)*2;
  21. #warning This will break if Apple change the CoreAudio's Channel Layout internals
  22. trackChannelLayout->mChannelDescriptions[0].mChannelLabel = (1L<<16) | channelAssignment;
  23. trackChannelLayout->mChannelDescriptions[1].mChannelLabel = (1L<<16) | (channelAssignment + 1);
  24. // Set the track layout
  25. err = QTSetTrackProperty(audioTrack, kQTPropertyClass_Audio, kQTAudioPropertyID_ChannelLayout, trackChannelLayoutSize, trackChannelLayout);
  26. if (err != noErr) {
  27. NSLog(@"**Error** QuickTime SetPropertyError: %i", err);
  28. return 1;
  29. }
  30. Download the full source code.

    |

Contacts Plug-in

There's been (some) progress on the RapidWeaver plug-in that allows users to create a page using cards from Address Book.

I've been pretty busy working on the Church Hall conversion in my spare time so development of this plug-in has been painfully slow and I'm still far from finished but I thought I would release an early Beta for anybody that is interested in seeing progress.

Warning: this plugin is not for production use. It may look fine when previewed in RapidWeaver but things go downhill when the pages are exported and things get even worse when viewed in Internet Explorer.

Some notable omissions include (but not limited to):

  • No support for mobile telephone numbers
  • Incorrect handling of PNGs, Javascript and CSS in Internet Explorer
  • No visual feedback of 'Large Type' telephone numbers; just click them
  • Incomplete Microformat support
  • Dragging multiple cards, or groups, from the list or in from Address Book results in a single card being added
  • Broken pagination links in List view
  • Miscalculated pagination when some contacts are disabled in the list
  • The Appearance tab in Setup does nothing. Still not sure how I will handle changing the appearance (If at all).

and so it goes on… Anyway, if you haven't been put off and are still interested the download and have a look.

|

Off to WWDC

I'm catching a flight, from Bristol to San Francisco, Saturday morning to attend Apple's WWDC. Although I've been a number of times, I'm still excited as ever about the technical content of the sessions and the chance to meet other Cocoa & WebObjects developers.

|

odds&ends…
Benjamin Miller