Thought for the Dazed

I've had to give up that Distance Learning course as I was having trouble seeing the teacher.

Flickr
www.flickr.com
RobMiles' items Go to RobMiles' photostream
Twitter
C# Yellow Book

Search entire site
Thursday
Jan312013

Using Speech with Windows Phone 8

DSCF0579_80_81.jpg

I said yesterday that I’d submitted my latest version of Voice Music to Microsoft for certification.

It failed (sad face).

The reason it failed is interesting if you write speech applications for Windows Phone 8. It has to do with what happens if you interrupt the speech playback. One of the principles of the Windows Phone UI is that at any point when you are using a program you should be able to press the Windows Key on the phone and go off and do something else. Then, when you have finished doing the something else, you press the back key and return to the previous program. If your program doesn’t work like this it will fail certification, since this is a required behaviour.

It turns out that my version of Voice Music had a problem if the user pressed the Windows Key while it was announcing a message. They could go off and do something else, but when they pressed Back they did not return to Voice Music. This was a fairly nasty bug to spot, in that it only occurs when the program is running “in the wild”, i.e. when it is in the phone and not attached to the Visual Studio debugger. It also made finding the bug tricky, in that as soon as I tried to look for it the program started working again. Which was not very nice.

Eventually I used a technique that has worked before. I asked for help. And it turns out that the answer is quite simple. When a speaking program is interrupted by the user pressing the Windows Button (or generally moving away from the application) it will throw an exception when the program is next restarted by someone returning to it. The exception is thrown by the SpeakTextAsync method. If your program doesn’t catch this exception it will fail to restart. The exception has a particular type that you can check for if you wish:

try
{
    SpeechSynthesizer synth = new SpeechSynthesizer();
     await synth.SpeakTextAsync("Hello cheeky.");
 }
catch (Exception ex)
{
     if (((uint)ex.HResult == 0x80045508)) 
     {
        // System Call Interrupted thrown by Speech 
     }
 }

My program just ignores the exception, which seems to have fixed the problem. You can do more clever things if you wish. I’ve resubmitted it for certification. Fingers crossed….

Wednesday
Jan302013

Voice Command on Nokia Conversations

VoiceMusic

Last week Rob Crocombe, one of our students, was featured on Nokia Conversations, talking about the things that he has been doing with Windows Phone during his time in the department at Hull. Now it’s my turn. You can find the post here. It contains a fairly shameless plug for Voice Music, my little program that lets you select music on your Windows Phone 8 device simply by asking for it. A new version is presently working its way through Marketplace certification.

Tuesday
Jan292013

Catching Heartbeats with the Gadgeteer

image

I reckon the Gadgeteer has more interfaces than just about any other embedded framework. Including neat things like this Pulse Oximeter from Seeed. They make the point on the product description that you should not use this as a medical instrument but, what with the theme of GlobalGameJam being heartbeats, and me having one to play with, the temptation to use it in our game was very hard to resist.

Using it is very easy indeed. You can bind to events that fire when connected (i.e. someone has put their finger into the sensor), disconnected (when someone has pulled their finger out, so to speak) and on a pulse detected event. You can also read the sensor object to find out pulse rate, blood oxygen levels and signal strength.

This is my code to bind methods to the sensor events:

pulseOximeter.ProbeAttached += 
   new PulseOximeter.ProbeAttachedHandler(pulseOximeter_ProbeAttached);
pulseOximeter.ProbeDetached += 
   new PulseOximeter.ProbeDetachedHandler(pulseOximeter_ProbeDetached);
pulseOximeter.Heartbeat += 
    new PulseOximeter.HeartbeatHandler(pulseOximeter_Heartbeat);

The handlers then do all the work:

void pulseOximeter_Heartbeat(PulseOximeter sender, 
PulseOximeter.Reading reading) { sendMessage("P" + reading.PulseRate.ToString()); }

The sendMessage method takes a string and sends it on to the game via a serial port interface that is also connected to the Gadgeteer device. The sensor has proved to be quite sensitive and works rather well. It is quite unnerving to be playing a game and find that the gameplay matches your heartbeat.

Monday
Jan282013

Buying a Computer is Hard Work

image

Last week I decided that I needed a new computer. Specifically a Sony Ultrabook. While I love my Samsung Slate to bits it has hardly any internal storage and the behaviour of the USB drivers when you turn on hardware virtualisation is less than exemplary. So I went down to a well known computer store (they have a World of PCs there) and tried to buy one. This was not a good experience.

In the first branch I tried they had the computer I wanted proudly on display. But of course they had none in stock. And according to the salesman (I use the term loosely) there were none to be found this side of York (although he could order one for me for delivery – just like I could from Amazon).

Of course, when I go on to the internets and check stock levels I find lots of local branches showing the item. So I head for one of those. Yes, they have one in stock. No, they can’t sell it for the price advertised. This is because, as a special service to customers, they’ve taken it out of the box, set it up and then made a backup CD. Which costs twenty quid extra. So they want me to pay for a service I don’t want or need. When I refused to pay the extra they were miraculously able to track down another device that hasn’t had this treatment, and so I actually managed to get the one that I wanted at the price advertised. At this point I thought I was out of the woods. But no.

I now had an experience not unlike the uncomfortable ones that I used to have at school when I went to see my headmaster to be told off. The salesman sat at one side of a desk and I sat the other side feeling defensive. He then tried to sell me services that I didn’t want for a computer that shouldn’t need them, implying that I was taking a risk in not going for the extended warranty and other gubbins that they are all undoubtedly under great pressure to sell.

Finally I managed to escape with the goods. I’m loving the new machine. Very, very useful. I’ve been horrible to it already, plugging and unplugging devices, and using it as if I didn’t care how much is left in the battery when I charge it, and generally just opening it, using it a lot, and closing it again. And it has taken the punishment with aplomb. I’ve got an extra 4G of memory for it from Crucial and it fair whizzes along.

But I must admit that I fear for the future of shops selling hardware if my experience is anything to go by. At a number of points in the process I felt I was being told stuff that was at best a bending of the truth, purely to serve the agenda of the person and company I was buying from. I’m pretty sure I’d have had a much better experience buying from an Apple Store and of course if I’d gone to Amazon I could have cut out the person completely. And given the hassle that I had, there is now an even greater chance that I’ll do that.

Sunday
Jan272013

GlobalGameJam Hull Results

Judging was a really frenzied effort. Two teams of judges, videos to take and show and final presentation right at the end of the day, with the coach for the Grimsby crew waiting outside with the engine running…

I went round with one of the judging teams and took some of the videos, Simon did the rest. If you want to find them and take a look at the wonderful stuff that was built you can search YouTube here. At the time of writing some of the videos were still being uploaded, but they should all be online soon.

After the judging, we had prizes. I took pictures of most of the prize winners, but for some reason I didn’t get pictures of everyone, sorry about that.

First up we had the special awards. These are teams who have excelled in specific competition categories.

DSCF0554.jpg

“Heart Attack Team” with their Social Media awardDSCF0555.jpg

“3 Old Robots and an Englishman” with their Diversifier award

DSCF0556.jpg

“50 Shades of Simon Grey” with their Art award

DSCF0557.jpg

“Blimbu” with their Project Management award

DSCF0558.jpg

Lifeline team with their Collaboration Award

Now it was time for the top three teams.

DSCF0559.jpg

“Across the Border” came third with a lovely heart powered jetpack game. Well done guys

In second place we had the “Heart Attack” team with a single finger controlled sideways scroller that has the player boosting their heart and avoiding circular saws. Sorry guys, I didn’t get a picture of you all.  But you are in the one above for your social media integration…

DSCF0561.jpg

The winners were “50 Shades of Simon Grey”, who designed, built and then textured an entire haunted mansion for their terrifying game where a ghostly presence stalks multiple players as they search the rooms to try and exorcise the evil that lurks there. The game uses 3D sound to play the hearbeat of the avenging ghost as he comes up behind you for the kill. Great,and very atmospheric, stuff.

Then it was time to pack up and head out. Thanks to Simon and Tom for making it work, Hull College for letting us have the use of their amazing Hull Studio School venue and all the folks who turned up. A great time was had by all, and we will definitely do all this again. HullGlobalGameJam will be back. Once we’ve had a lie down….