I'm a missionary in Japan. The name of my mission agency is WEC International. That's supposedly Worldwide Evangelisation for Christ, but I think I have a better idea about what it stands for...
2008-05-10
Casio Privia and OS X - Sometimes I amaze myself
If Google took you to this page because you have one of these keyboards and a Mac, and you don't know what to do with it, skip to where it says "The short version." Meanwhile, here's the long version.
On Thursday I took delivery of a new (well, second hand) MIDI keyboard. It's a very nice piano, with a great weighted-key feel and a nice bank of sounds. I'd not normally trust Casio for this kind of thing, but my boss had a look around and said it was one of the best on the market.
It also has a couple of MIDI ports on the back, and a USB socket. Excited at the idea of being able to compose songs straight onto my computer again, I hooked it all up, and then read the instructions. (You know how it goes.) And I found those magic words: "Macintosh not supported." I tried it anyway, and really, it wasn't supported.
At this point, I had two options - buy another USB to MIDI convertor (I think I have one in the UK somewhere, but very few people sell them these days) or reverse-engineer the protocol and write my own driver. I should note at this point I have no idea whatsoever how to write device drivers, for any OS, least of all OS X, but I still fancy myself as a bit of a reverse engineer, so I set to work.
Imagine my disappointment when, after a few hours of fiddling, I found that the protocol was just plain old MIDI over USB. Absolutely nothing special about it at all. Apart from the fact that the keyboard's USB interface, for some inane reason, didn't announce itself as an ordinary MIDI-class device, and so the operating system had no idea what to do with it.
But after breaking the protocol (such as it was), I still had no device driver. Thankfully, the standard OS X Developer package includes an example of a USB MIDI device driver. All I needed to do was plug in the manufacturer and device ID, and recompile, and I had a working driver. Depressingly easy, really.
The short version
You can download the device driver here. Put it into the directory it specifies, which if my packaging skills don't work properly, should be /Library/Audio/MIDI Drivers.
There is one slight annoyance. OS X loads its MIDI drivers once it wants to use them. The Casio keyboard, on the other hand, wants to talk with the computer on the USB interface as soon as it's turned on, so that it can determine whether or not to use USB or the MIDI ports. To convince the keyboard to talk on the right interface, you need to (a) turn it off, (b) open a Terminal, (c) type /System/Library/Frameworks/CoreMIDIServer.framework/MIDIServer and hit return, (d) turn on the keyboard. It should now happily report that the active port is USB. Then you're good to go.
2007-01-13
Skype convergence
Last week I wrote:
Next stop is, ideally, to get Skype to automatically update Last Contacted as well, which is perhaps a little bit of a pipe dream.
But then I thought "Skype has an API. I have Mac::Glue. This should be easy!" And it is. Harder than it needs to be, but still easy.
use Mac::Glue qw(:all);
use Time::Piece;
my $s = Mac::Glue->new("Skype");
my $ab = Mac::Glue->new("Address Book");
sub skype { $s->send(command => shift, script_name => "LastContacted") }
my %skypers; # Map of skype user (stored as a "skype:whatever" tag in the
# contact's "note") to email address
for ($ab->prop("people")->get) {
next unless $_->prop("note")->get =~ /skype:(\S+)/;
my $mail = $_->prop("email")->get;
$mail &&= $mail->prop("value")->get and $skypers{$1} = $mail;
}
my $c = skype("SEARCH RECENTCHATS");
$c =~ s/CHATS //; my @chats = split /, /, $c;
my $today = Time::Piece->new->ymd;
for (@chats) {
my $ts = skype("GET CHAT $_ TIMESTAMP"); $ts =~ s/.*TIMESTAMP //;
# We can't set it to a given date, sadly, so just pick out today's chats
next unless Time::Piece->new($ts)->ymd eq Time::Piece->new->ymd;
my $members = skype("GET CHAT $_ MEMBERS");
$members =~ s/.*MEMBERS //;
for (grep {!/lathosjp/} split / /, $members) { # Not me!
if (!$skypers{$_}) { warn "Couldn't find email address for $_"; next }
# Mac::Glue treats values of the contact_info class as
# read-only, need to shell out to Applescript to get it done...
system("osascript", "/Users/simon/update-last-sent.osa", $skypers{$_});
}
}
Run this from cron, and Robert is your father's brother!
2007-01-08
Missionary contact management with OS X
I realised recently that a significant proportion of the missionary job is actually a customer relationship management problem: keeping in touch with people back home, sending out newsletters, thanking supporters, etc. As well as that, I want to be regularly praying for many of my friends and contacts, because, well, many of them are missionaries too. And besides, I look back on the number of friends from university that I've fallen out of touch with, and I really don't want that to happen with my ANCC friends as well.
So I started looking around for tools that could help me with this, and really couldn't find anything useful. The major problem I have is, as usual, a convergence one: I want my mail client, my address book and my calendar all to talk to each other in clever ways. I want to know when I last emailed someone, and automatically schedule in an email to them if it's been a long time. In the end, I've come up with a hairy solution made of bits of twig and baling twine, but it more or less works.
First, I've added two custom fields to my address book: last contacted, and last prayed for. Now, I want "last contacted" to be automatically updated, and there's no useful way to get Thunderbird to do anything when an email is sent. So I Bcc every outgoing email to simon@localhost, where a waiting Postfix server forwards it to a Perl script which strips out the email addresses, and hands them to a bit of Applescript (I said it was hairy.) which updates Address Book.
Next, iCal is subscribed to a magic calendar made out of a Perl CGI which reads the Address Book using Mac::Glue and produces a daily prayer calendar based on the people I haven't prayed for recently, and also adds To-do items to email the people with old "last contacted" dates. iCal re-syncs the calendar every day, so stuff that's done drops off automatically. To ensure that the address book's idea of their email address gets carried over to Thunderbird, I'm using Plaxo to synchronise the two.
I have to update "last prayed" in the Address Book manually, which means that if I don't actually pray for the people I'm scheduled to, I get scheduled to pray for them again the next day when iCal refreshes. Meanwhile, "last contacted" gets automatically updated, and the todo items will resolve themselves, again when iCal refreshes.
So far, so good. I have minimised the amount of work I have to do, apart from two things: manually update "last prayed" - which ensures I actually do it, and make sure I put new people into Address Book. Which I think I should be doing manually.
Next stop is, ideally, to get Skype to automatically update Last Contacted as well, which is perhaps a little bit of a pipe dream. (Although I know it can be scripted with AppleScript) But this will help; it's got several applications talking to each other, and provides the convergence that software in the 21st century really should have but still doesn't...
2005-11-13
iView Media Pro
So I've been looking at moving my iPhoto picture library to.... anything other than iPhoto. iPhoto has been unreliable, and slow to the point of unusable for me. Unfortunately, nothing really managed to cut it as a replacement until I had a look at iView Media Pro.
Damn, it's fast. It has a pretty decent first-pass editor for the times I don't need to bring up Photoshop. It handles keywords well. It has a range of ways of slicing-and-dicing the view of the library which seem to fit my head pretty well. And best of all, it's scriptable, so I spent a happy hour or two this evening rewriting my Memories exporter to work with it. So it looks like a winner.
I also refactored said exporter to have a separate
Memories::API module, and I spent a while making Memories
have RSS feeds for any page with pictures on it. A happy afternoon's
recreational coding.
| « | 2008-05 | |||||
|---|---|---|---|---|---|---|
| S | M | T | W | T | F | S |
| 1 | 2 | 3 | ||||
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |
lathos: Just written a device driver for my new piano. I impress myself sometimes.
Elvis Costello – The Invisible Man





