Wednesday, July 4, 2012

After a long hiatus, I'm back!

(In which I give a big shout-out to PJRC, designers of the Teensy)

I got inspired to do more work on my Gordophone project when I saw that the Teensy 2.0 had native support for USB MIDI. If you're unfamiliar with Teensy, it's a dynamite little ATMega-based microcontroller that is extremely compatible with Arduino, but also allows you to turn it into a USB device.

I've always been bummed out that, in order for my instruments to drive software synthesizers on my Mac, my designs needed a MIDI shield bolted to the Arduino, and a MIDI interface connected to the Mac, using those 1980s DIN-5 connectors - very unwieldy.

There is a standard for transporting MIDI messages over USB, and any modern music device you get these days will allow you to attach it to your computer via USB. So if, say, you go to your local music store and buy a keyboard, it'll have a USB connector. Plug it into your Mac, start up Garage Band, and you can control the softsynths.

Since Teensy 2.0 has USB-MIDI support built in, this means that the Gordophone can shed all those MIDI cables and interfaces, and work directly over the USB cable that connects the Teensy to the computer.

Also, Teensy is, well, teensy. It's barely bigger than a U.S. Quarter, yet has all the I/O I need to build the Gordophone, and if I need more I/O pins, I can use the Teensy 2.0 ++ (the big brother to the Teensy, which, while being a larger sibling, is still pretty damn small). I'm hoping to be able to embed the controller directly into the instrument in future designs.

PJRC is the company that sells the Teensy. I placed an order with them via the web, received a prompt acknowledgement of my order, and received my order a couple of days later (I'm on the US west coast, so shipping time from Oregon is fast). The Teensy is well-supported with plenty of downloadable sample code.

My first milestone was to put together a simple instrument - a single button that sends a random MIDI node on event when pressed, and sends a note off event when the button is released. Following the help files on the PJRC website, I had my simple instrument running in less than 30 minutes, and the code worked the first time (that *never* happens at my day gig).

My next milestone was to port my old Arduino-based Gordophone sketch to the Teensy.

First, I had to solder up an adapter that would plug into the DB-25 connector on the Gordophone and bring out the individual wires so I could plug them into a breadboard and wire them up to the Teensy:


And then it was a matter of digging up my project docs to remember which of the Gordophone sensors were connected to which input pins on the Arduino. The pins on the Teensy are different, but PJRC thoughtfully provides a reference card that maps the Arduino pin numbers to the Teensy pin numbers. Looking at that, I was able to patch the DB-25 to the Teensy:


Also, I should mention, PJRC has done a fabulous job of integrating the Teensy into the Arduino IDE, via the Teensyduino package. Apart from requiring that you press the Teensy's reset button once, the developer experience is exactly the same as using an Arduino.

Since I have been inactive for a while, getting things running on the Teensy also required porting some code to Arduino 1.0, which required a few code changes since I developed everything on Arduino-22, but within 2 hours, I had everything working.

Kudos to Paul and Robin at PJRC for making such an excellent controller and providing such top-notch support for it. Thank you!

Wednesday, April 6, 2011

3D Trombone Improvements

Over the last few days I've made a couple of improvements to the 3D Trombone firmware that improve its playability and get me a little closer to having a playable instrument to demo. My goal is to have something to take to Maker Faire Bay Area in May.

Improvement 1: Flip-Flopping the Overtone Selector

If you recall, the 3D Trombone has a controller operated with the right hand that selects the "overtone" played by the instrument. All that really means is that, depending on which buttons are pressed, a different note is played when the player blows into the instrument, and the series of notes are the same as you would hear if an acoustic trombone player was playing the overtone series.

In musical notation, that's:


Since I don't have a way of enulating the "overblowing" behavior that I can get on an acoustic trombone, I built a controller that lets the player press buttons to select the "overtone" played. It looks like this:



In my original firmware, I'd mapped the overtones as follows:

All switches open: Fundamental
Switch 4 pressed: overtone 1
Switches 3 and 4 pressed: overtone 2
Switches 2, 3 and 4 pressed: overtone 3
Switches 1, 2, 3 and 4 pressed: overtone 4
Switches 1, 2 and 3 pressed: overtone 5
Switches 1 and 2 pressed: overtone 6
Switch 1 pressed: overtone 7

I found this incredibly difficult to play. I often would unintentionally play a lower note when I intended to play a higher note, or vice-versa. At first I attributed this to being completely unfamiliar with the concept of using my fingers to select pitches, as opposed to using my embouchure.

But after playing "3d air trombone" for a while today, I wondered if some of my difficulties were due to the particular way I'd mapped the keys. So tonight I rewrote the firmware and turned the finger assignments completely upside down. And, lo and behold, it works a lot better. For some reason, it feels much more like the concepts of "up" and "down" make sense now.

To experience this, hold your right hand sideways in front of you, with your palm facing you. If you curl your fingers toward your palm, starting first with your pinky and ending with your index finger, that's the new motion I implemented, and it feels like "up" to me. I had it backwards before!

Improvement 2: Enabling Scene Selection in Ableton Live

Since I want to be able to take this setup and perform live at Maker Faire, I've been trying to build a live performance setup (by the way, I won't have a set location - I'm just hoping to find an electrical outlet somewhere and have an impromptu concert). Although I have mostly been using Apple Logic, I did get a Lite version of Ableton Live with one of the MIDI interfaces I bought, and I was able to upgrade to the Lite version of Live 8 for free.

I've always had a bit of a hard time getting my head around how Live works, but I think I'm starting to get it, and after spending some more time with the tutorials, I can see using it for my performances. Live has a concept of "scenes" that typically map to some musical structure. For example, the scenes might the intro, verse, chorus, break, and outro (for a traditional song form). For a dj, the scenes might be a collection of samples and beats that s/he selects in some sequence.

People who use Live seriously often have a dedicated hardware controller with big, lighted buttons that are easy to see in a dark environment and are easy to hit reliably in a performance. I really don't want to have to haul something like that around. So I decided to build in the ability to do scene selection with the 3d Trombone.

To accomplish that, I added an additional button, operated by the thumb. In the photo, it's labeled "Meta":



To select a scene in Live, you:

Stop playing any notes (that is, stop blowing)
Press button 1, 2, 3, or 4 to select a scene
Press and release the Meta button

When the firmware detects that the meta button was released, it reads the values of the other 4 buttons and sends a MIDI Note On event on an alternate MIDI channel. You can then use Live's MIDI mapping mode to assign that to one of the scene selection buttons in your Live set.

Being the geek I am, I was unhappy with only being able to select one of 4 scenes, so I wrote the firmware so that it reads the 4 switches as a 4-bit binary number and sends that as the MIDI note on. So, if you are able to do binary in your head, you can select up to 16 scenes (if you don't want to do that, you can still just use the 4 notes produced by pressing the 4 switches individually).

Next

Now that I seem to have something that's somewhat playable, the next step is to put together a few Live sets that have some backing material that I can use to show off the 3D Trombone. Unfortunately, it doesn't appear that the Apple Logic Softsynths are available from within Live, so I'll probably need to find an AU or VST synth plugin that is flexible enough to be controlled by my instrument. Most of the really high-end softsynths (things from Native Instruments, Omnisphere, etc) all have very sophisticated MIDI controller routing capabilities, so one of those is probably in my future. If anyone has suggestions for a specific synth they have gotten working well with a wind controller (e.g. a Yamaha WX series, or an Akai EWI), let me know.

Thanks for reading...

-Gordon

Saturday, March 5, 2011

Analog Multiplexing

The Arduino has 6 analog I/O pins. For one project I'm considering, I actually will need 7 analog I/O pins, so I went looking for an analog multiplexer chip that would allow me to have more analog I/O. I found the CD74HC4067, a 16-channel analog multiplexer that will fill the bill.

You can think of the chip like a 16-position switch. There are 4 input pins that select which one of the 16 pins to connect to the common pin. If you write a binary 0000 to the input pins, the common pin is connected to input/output pin 0. If you write a binary 0001, the common pin is connected to input/output pin 1. And so on.

To try this chip out, I built the circuit shown below. Two 10 k potentiometers are wired up as a voltage divider to provide a voltage from 0-5 volts that I can measure. The common pin of the multiplexer chip goes to the Arduino's analog input, and the wipers of the pots go to input/output pins 0 and 1 of the multiplexer chip.




To be sure I was programming the chip correctly, I also hooked the wipers of the pots to Arduino analog pins 1 and 2. If I've got things working properly, then I should see that same value coming from the mux chip as I see on the Arduino analog input.

Finally, I wrote a little sketch that selects one of the mux inputs, and then prints the values from analogRead() on pin 0 (connected to the MUX) and pins 1 and 2 (connected to the potentiometers). Running the sketch, when I turn the potentiometer selected by the mux, I see it value change, and it matches the value directly read by the Arduino. Unit testing hardware FTW!


/**
74HC4067 Test

The 74HC4067 chip is an analog multiplexer. It has 4 control pins where you write
a value (0-15) that selects which of the 16 analog inputs/outputs to/from the chip
are hooked up to the common input/outout. This is useful if you need to read or
write an analog voltage to more than the 6 pins available on the Arduino.

*/

int mpin = 1;

void setup() {
Serial.begin(9600);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
}

/*
Choose the input pin selected by the 74HC4067 chip
*/
void selectInputPin(int pin) {
if (0 == pin) {
digitalWrite(2, 0);
} else if (1 == pin) {
digitalWrite(2, 1);
}
digitalWrite(3, 0);
digitalWrite(4, 0);
digitalWrite(5, 0);
}


void loop() {
Serial.print("Loop begin: select multiplexer pin ");
selectInputPin(mpin);
Serial.print(mpin);
Serial.println();
Serial.print("0: ");
Serial.print(analogRead(0));
Serial.print(" 1: ");
Serial.print(analogRead(1));
Serial.print(" 2: ");
Serial.print(analogRead(2));
Serial.println();
delay(1000);
}

Tuesday, February 22, 2011

3-D Trombone Photos and Ideas

I've finally gotten back to working on my 3-D Trombone concept. It's been a while - work has gotten pretty crazy lately, but I've just gotta get back to this to exercise my creative outlets.

Here are a few photos of the electronics:



The large black unit in the center is the 3-position joystick I liberated from a Gametrak controller. You can see the joystick in the upper right. The circuit board in the upper left is just a wiring junction I built to make the electrical connections more secure. All the potentiometer connections and the power supply line come in/out on the ribbon cable you see (IDC connecors FTW!).

Here's another view where you can see some of the mechanics of the Game Trak controller. It's pretty simple, really - a gear system drives a potentiometer. The large enclosure houses a large coil spring that provides the return force for the z-axis.




There is also a breath sensor based on the same Freescale chip I used in my previous controller, built into a small project box and attached to the gametrak controller box:



I also have a controller that the player holds in the right hand. It consists of 5 monentary pushbutton switches used to select the overtone played. Here's a view of it:




The right hand controller and gametrak box connects to the same Arduino + MIDI Shield box I built for my other instrument (the new box is plug-compatible with the old one). Here's a view from the outside:



The controller electronics attach via the DB-25 connector. The switch on the top is used to select "load" mode, where the Arduino is able to download code from the IDE, and "run" mode where the serial pins are connected to the MIDI shield, which you can see in this photo of the inside:



Visible at the upper-left is the MIDI out port.

Ideas

I had an email conversation with Onyx Ashanti about the cool work he's doing on his Tron Beatjazz Controller. Onyx has some big goals for his work, and some of them could benefit my design, especially the hand-controllers he's working on - they'll have keys for each finger to operate, as well as an accelerometer. I think he's also incorporating some ThingM MaxM LEDs, which is very cool. ThingM's founder, Mike Kuniavsky, is a friend of mine and a former coworker at the University of Michigan.

The night after I had the email conversation, I had a dream that I was playing live at some sort of a club. I had an instrument sort of like my 3-D Trombone, but instead of the overtone controller, in my right hand I held a microphone, and to control the overtones, I moved my right hand up and down in the vertical axis. In my dream, I found it very natural, and was able to play melodies about as easily as on my trombone. I'm still not sure why I was holding a microphone in my dream.

I suspect this idea had been hanging around in my brain for a while, and my conversation with Onyx brought it to the front.

Naive Implementation

I took that idea and modified my 3-D Trombone Arduino sketch to read the Y-axis position of the gametrak controller and map the value, in a linear fashion, to an overtone.

In a nutshell, the result was unplayable. The problem is that, in order to maintain the "slide" position, the amount of "string" deployed out the gametrak controller has to be constant. So, in order to move up and down the harmonic series without changing slide position, you need to move your arm in an constant-radius arc, which is already pretty hard. But to make matters worse, the radius of the arc depends on which position you're in. So if you're in seventh position, the arc is several feet long, but if you're in first position, the arc is only one or two inches long. It produced some fun random effects flying up and down the harmonic series will glissando-ing in and out, but that would get old quick. Here's a picture of what I mean:



I have another idea about how to make this idea (vertical motion selects overtones, horizontal motion selects pitch) - a simple mapping of overtone to vertical position, pitch to horizontal position. Basically, a grid like this:




The X axis is the slide position - a trombone has seven of them, and the Y axis is the overtone. A good trombone player can play about 10 overtones, which corresponds to a range of about 3 octaves plus a few extra notes. So where a person playing an acoustic trombone would keep the slide in first position and move up and down the harmonic series with his/her embouchure, the player of the 3-D trombone would trade in the embouchure for up and down motion.

For those of you who may play trombone, here's how a B-flat major scale would look:



Implementation:

It turns out that it will be very hard to implement this "grid" idea using my current setup. The reason is that, due to the arrangement of the gametrak controller and the player (s/he holds it near the face), and the travel limits of the gametrak unit's joystick axes (about 90 degrees), it's not possible to cover the whole range of motion that might be interesting to a trombone player. So... back to the drawing board.

A more promising arrangement would be to use the Gametrak as it was intended to be used; base unit sitting on the floor. I'll investigate that and post on it in the future.

Thursday, September 30, 2010

HP Creative Camp

Welcome, HP Creative Camp participants who have found your way here. And thank you for all the positive feedback I got at camp, and in email afterwards. If you want to follow my music/microcontroller experiments add this bookmark:

http://gordophone.blogspot.com/

I had the distinct pleasure of participating in HP Software's Creative Camp (modeled on Foo Camp) in Sep. 2010 at the Stanford Sierra Conference Center. I gave a hastily prepared talk on the work I've been doing with microcontrollers and music, gave a demo of my recently completed 3-dimensional trombone, and some weird stuff I've been doing around sonification (sorry, no public posts about that yet). I also "performed" at the big party event, making some sounds with my iPhone+TouchOSC and OSCUlator+Logic, accompanied by other Creative Camp musicians. It was a blast. A video summary of the event was made, and I'm at 4:51.

Oh, and the Silent Disco (everyone puts on wireless headphones) put on by DJ Motion Potion was pretty damn cool! Robbie gave a presentation earlier in the the day (also hastily prepared. according to Robbie, but way, *way* better than mine) about DJ technology and history. As a traditionally trained musician, I've always found DJ culture puzzling, but the way he framed the whole presentation around passion really spoke to me. Thanks, Robbie.

P.S. I looked over the comments from the camp, and someone commented that my session caused them to "rocket into ideation mode". That's exactly what happened to me when I attended the New Music Controllers Workshop at Stanford, and if I managed to trigger that in someone else's mind, that's pretty great. Thanks for sharing that!

Tuesday, August 31, 2010

The 3-D Trombone

When I was at the New Music Controllers workshop at CCRMA this summer, after I'd demoed my trombone controller and mentioned that I was interested in using a retractable string for a slide (based on a suggestion from Chris Graham), a CCRMA grad student named Michael Berger clued me into a very cool device - the GameTrak Controller.

The GameTrak is a pretty amazing little device. Think of a joystick, which can measure X and Y axis movements, then add a retractable cord that protrudes through the handle and can measure Z-axis displacement. There are actually two of these in each GameTrak, and the player wears a pair of gloves that attach to clips on the end of the Z-axis cords. Internally, there are 6 potentiometers that hook to a small board that does all the analog to digital conversion and appears as a USB HID device. Hooking one of these up to, say, Max/MSP or pd is super simple, and here are some cool things that have been done with GameTraks:

Game Trak Theory (A CCRMA performance)
Cop de Cap by Experimental Headbang Orchestra (Stanford)

Since the Wii pretty much destroyed the GameTrak in the gaming market, they're available very cheaply now - I think I now own 6, and I got them for $20 each.

Originally I was only interested in cannibalizing one for the z-axis retractable cord, to use that for the slide of my trombone. But once I got one of the GameTraks open, I thought "why limit the slide to linear motion? Why can't we build a trombone "slide" that operates in 3 dimensions?" And so the 3-D Trombone was born.

Opening up the GameTrak is very easy, and the spring/joystick mechanism for one-half of the device can easily be removed with just a small philips screwdriver. I remounted the assembly in a project box, which is a lot larger than I'd like it to be, but it's a prototype.

I built another breath controller using garden irrigation tubing and the same Freescale Pressure Sensor I used for the Gordophone. For overtone selection, I epoxied some momentary switches into piece of PVC tubing (in the Gordophone, these switches are in the joystick handle that is used to move the slide).

After wiring everything up, I made two changes to the Arduino sketch that does the sensor reading and MIDI event generation:

- Rescaled the "slide" motion limits, since the GameTra can measure about 6 feet of z-axis motion, but a trombone slide is only a couple of feet.
- Coded things so that the X and Y axis controllers produce MIDI continuous controller data on controllers number 16 and 17.

Finally, I put together a patch and an effect in Logic, as follows:

- A simple sine wave instrument using the ES2 synth. The breath controller is mapped to the oscillator amplitude.
- The EVOC 20 TrackOscillator Filter. I used Logic's "Learn" mode to set things up so that the slide's X axis motion controls the Formant Shift, and the Y axis motion controls the LFO intensity. I set the LFO frequency at 100 Hz so it really distorts the sound (I really lean into that distortion at around 0:52 and 1:02).

I made the X and Y axis controls very non-subtle, so I could tell when they were working. This video shows the whole thing in action.




One thing that's very tricky is maintaining a constant slide position on the Z-axis while moving around the X and Y axes. While playing a traditional trombone, one can move around, but the player's body position relative the the instrument remains constant. With the 3-D Trombone, all that changes, and it (so far) seems like a radically different experience. More exprimentation is due.

Sunday, July 4, 2010

A week of good CCRMA



The Knoll - CCRMA Home

This past week I cashed in some vacation time and attended the 5-day New Music Controllers Workshop, led by Edgar Berdahl and Wendy Ju, at Stanford's Center for Computer Research in Music and Acoustics (CCRMA, pronounced "karma"). It was a great experience, with terrific guest lecturers and a fun group of participants.

(Update 7/22/10: Video of all the workshop demos is now online on the CCRMA website.)

The workshop is a one-week version of the same material covered in the Physical Interaction Design for Music course offered at Stanford (Ed and Wendy teach that course as well). Topics covered in the course include the Verplankian Physical Interaction Design Framework, basic electronics, the Arduino, using Max/MSP and pd, and using sensors to interact with the real world.

The guest lectures were one of the high points of the workshop. We heard from Bill Verplank (Interaction Design), Dan Overholt (Music Interface Technology Design Space), Alexandros Kontogeorgakopoulos (Cardiff School of Art and Design - Haptic Digital Audio Effects), and Ge Wang (Chuck programming language, Smule). I particularly enjoyed seeing all the cool projects that Dan Overholt did, including Overtone Violin, Sphere Spatializer, and his Overtone Labs work. And if you've never seen Ge Wang talk, you really, really should. He blew me away with his geek chops, his musician chops, and his business chops -- all in one hour.

I also really enjoyed meeting all the other participants. We were all over the range in terms of experience with music performance, synthesis, hardware, software... but everyone chipped in to help each other fill in their knowledge gaps.

Here are some photos and videos of the workshop:



Ian's Thumb Piano (force sensitive resistors, an acceleromoter, and some Max/MSP code)

Ian is also no stranger to geeking out with electronics and music. Here he is with his Guitamoton (built previously):



and a video of it in action:






A sensor glove from Jenifer (Masters student in Intermedia Music Technology at the University of Oregon)



Jeremy and Chekad testing their "conductor" device that allows the player to change the tempo of a performance by conducting. They had about two days to build it, and it actually worked!

For the final demo/concert in the CCRMA Stage, we had a great audience of CCRMA faculty and students, including John Chowning (!).



Between sessions, I wandered around the CCRMA building. Man, that place is one big house full of cool toys:


The door to the Max Lab, named after Max Matthews



Inside the lab - a music/hardware/software hacker's paradise. And we had full access to it for the week.




Yes, there's one whole bin just for accelerometers.

On the CCRMA ground floor there's a museum of sorts. Check this stuff out:



A NeXT cube. Man, I used to support those things at U of M. The optical drive qualified as a percussion instrument.


A Yamaha DX-7, the first commercially successful digital synthesizer. The FM synthesis patent that Stanford licensed to Yamaha was at one point the most lucrative patent held by the University.



An early prototype FM synthesizer from Yamaha? Check out the console:



Notice how there are actually four separate monitors.



Interesting aural possibilities...

And, in the 2nd floor common area:


When reading Computer Music Journal, it's best to have an ample supply of Tabasco on hand.

After the demo/performance, some beer was consumed, and then Chekad pulled out his violin. I had no idea he was such an accomplished violinist, both in western styles and in the styles of his native Iran. He jammed with Dan Overholt, and then with Alexandros, who managed despite lacking a piano bench:







A nice end to the week.

-Gordon