Tag Archive: python

2015
10/29

Category:
Computing

TAG:


COMMENTS:
Comments Closed

Raspberry Pi theremin

This was the supposed to be just a quick project to fill some time while waiting on an eBay purchase from China. I had been building up parts ready to build a simple Raspberry Pi-powered robot (inspired by articles in both Linux Format and The MagPi magazines).

The distance sensor is an HC-SR04, only a couple of quid on eBay, and I then found a simple guide on ModMyPi showing how to wire the sensor into a Raspberry Pi and read the distance in Python.

It being half-term, I had ordered the required resistors and was delighted at how easily the code work. “Fabulous!” I said to myself, “Now I just need to make it round the distance to, say, the nearest 5cm and then play a tone from there.”

How wrong can one statement be?!

After a good two days of intermittent playing, I have managed to get *something* working, basing my theremin on Zulko’s Pianoputer as I simply couldn’t find an easy way to just get Python to play a pitched tone. His code was set to use a keyboard, mine now reads the distance from the HC-SR04 and plays the relevant sound from there. In place of his “bowl.wav” I’ve grabbed (and trimmmed, and down-sampled) a clarinet sample from freesound.org and use that as my base sound, which Zulko’s code then down/up-samples to make the various pitches required, at startup.

So yes, it’s a little clunky. And yes, it can take a while to start up and transpose the various samples.

But I’m a happy geek – I built my own personal theremin!

2013
05/24

Category:
Computing

TAG:




COMMENTS:
Comments Closed

Programming on an iPad

Just a quick jotting to mark the occasion of my first real programming success in an iPad. Rather chuffed, really, that it all worked out as hoped and seriously impressed with the software involved.

So, then, to details – what have I achieved? Nothing too spectacular in terms of visible results, but I’ve managed to get the Minecraft Pi Python API into the Pythonista app (by means of copy/paste as there seems to be no way to import code from, say, DropBox) and then quickly code a simple class that uses the API, connects to a running instance and posts a chat message.

Like I said, nothing too glamorous, but it proved the idea – now on to some more exciting ideas. I’m going to aim for the tried-and-tested platform that follows the player around, so you can never fall. Then, who knows? The sky is, as ever, the limit 🙂