Software


30
Dec 09

Arduino MIDI controller

A project that I’ve been working will use ultrasonic range finders to determine the locations of people in a space to send MIDI signals back to Ableton Live to trigger tracks of sound. This prototype sends one of four byte strings that make up a MIDI controller command, based on the distance from the sensor. It’s made up of an Arduino, a Maxbotix EZ1, a MIDI to USB cable and some RGB LEDs for visual feedback.

Arduino MIDI Controller

Simply put, if you’re within 8 inches of the sensor, one measure of music on the computer plays and the LEDs show one color. Greater than 16 inches, a different measure plays and the LEDs change to a different color. More than 24 inches away from the sensor and you get yet a different measure of music and color on the rgb LEDs. In the end I hope to scale the spatial awareness of this to intervals within 10 feet, with the LEDs lighting 1′x2′ plexiglass panels with the sensors mounted below the panels, facing into a space.

For now, here’s some Arduino code if anybody’s interested in playing with it:

/*

CTYSND - a spatial musical instrument
Author: Jay Pozo

http://www.jaymatter.com

December 2009

for more info about MIDI messages, go here:

http://www.midi.org/techspecs/midimessages.php

*/

// data pin for the range finder sensor
const int sensorPin1 = 6;

byte firstNote = 0x01;
byte secondNote = 0x02;
byte thirdNote = 0x03;

// commandByte: 0x90 is a note
// 0xB1 is a controller change on channel 2
byte commandByte = 0xB1;

// the third byte sends the velocity. In this case, 0x7F is max of 127
byte thirdByte = 0x7F;
byte lastNotePlayed;

long sensor1Pulse;
long distance1; // in inches

// pins for the colored led panels
// this will have to change later, probably through a shift register to support 8 sets of LEDs
int redPin1 = 9;
int greenPin1 = 10;
int bluePin1 = 11;

// our ranges, in inches
int rangeStart = 0;
int rangeStep1 = 8;
int rangeStep2 = 16;
int rangeStep3 = 24;

void setup() {

Serial.begin(31250);

pinMode(redPin1, OUTPUT);
pinMode(greenPin1, OUTPUT);
pinMode(bluePin1, OUTPUT);

pinMode(sensorPin1, INPUT);
}

void loop() {

sensor1Pulse = pulseIn(sensorPin1, HIGH);
distance1 = sensor1Pulse/147; // distance is in inches (see documentation of sensor for value of 147)

if ( distance1 > rangeStart && distance1 < rangeStep1 )
{
analogWrite(redPin1, 255);
analogWrite(greenPin1, 255);
analogWrite(bluePin1, 255);
if (lastNotePlayed != firstNote)
{
noteOn(commandByte, firstNote, thirdByte);
lastNotePlayed = firstNote;
}

}

if ( distance1 > rangeStep1 && distance1 < rangeStep2 )
{
analogWrite(redPin1, 255);
analogWrite(greenPin1, 0);
analogWrite(bluePin1, 255);
if (lastNotePlayed != secondNote)
{
noteOn(commandByte, secondNote, thirdByte);
lastNotePlayed = secondNote;
}

}

if ( distance1 > rangeStep2 && distance1 < rangeStep3 )
{
analogWrite(redPin1, 255);
analogWrite(greenPin1, 255);
analogWrite(bluePin1, 0);
if (lastNotePlayed != thirdNote)
{
noteOn(commandByte, thirdNote, thirdByte);
lastNotePlayed = thirdNote;
}

}

if (distance1 > rangeStep3 )
{
analogWrite(redPin1, 0);
analogWrite(greenPin1, 0);
analogWrite(bluePin1, 255);

// noteOff();

}

delay(300);
}

void noteOff()
{
Serial.print(0xFC,BYTE);
}

void noteOn(int cmd, int pitch, int velocity) {
Serial.print(cmd, BYTE);
Serial.print(pitch, BYTE);
Serial.print(velocity, BYTE);
}


9
Feb 09

Remote Torrent

Let’s say you have a file server that serves media on your local network, and perhaps downloads torrents day and night.  And let’s say that you get the sudden inspiration while you’re sitting at school or in the coffee shop to download Terminator 2 or The Breakfast Club, something totally legal.  You’re not going to start that bad boy on your laptop and risk the school’s computer services department locking you out.  Besides, if  you have a 22″ HDMI monitor, you might be keen on a 720p file that might take close to 20 hours to download.

So what do you do? (Mac users only):

1. Setup Transmission to watch a folder for new torrent files. (Preferences > Transfers)

2. Setup an email account dedicated to receiving torrent files.

3. Setup Apple Mail to receive mail on that account.

4. Setup a Rule to handle attachments

5. Save and use this applescript to make the magic happen (substitute your watch folder in transmission where noted):

using terms from application "Mail"
on perform mail action with messages theMessages for rule theRule
tell application "Mail"
repeat with oneMessage in theMessages
set {mail attachment:theAttachments} to oneMessage
repeat with oneAttachment in mail attachments of oneMessage
save oneAttachment in ("Your:Volume:") & (name of oneAttachment)
end repeat
end repeat
end tell
end perform mail action with messages
end using terms from

Make sure to check those quotes.  Sometimes WordPress likes to change them and it’ll screw your applescript up.

6. Download a torrent file on ANY computer, and email it as an attachment to the email address you setup in step 2.

7. Don’t download anything you’re not supposed to, and enjoy!


3
May 08

Flex Builder Freebie

Flex

Flex Builder Pro 3 is free for students. You have to fill out the form and download the trial version. Then you wait for Adobe to verify your student status and then they’ll send you a working serial number.

Link


16
May 06

Fuse and Zigo

I’ve been using the Fuse Kit and Zigo tween engine to write actionscript tweens. Pretty easy to use, lots of control when you move onto the Object Syntax. You can synch and sequence movie clip tweening of alpha, position, colour, rotation, scale and more.

If you use it, be sure to donate to Moses Gunesch who brought together all the goodness for this great tool to happen. The link is at the bottom of the page.

Visit the Fuse Kit site