The vaults are insufferably damp.

Friday, November 13, 2009

My go development box is a virtual machine

I've been playing around with the new go language from Google. It is a very interesting computer language. It is currently only supported on Linux and MacOSX. I've been watching the #go-nuts IRC channel on freenode.net the past few days. A lot of the messages there are pleading for a Windows implementation. I also saw complaints about the mercurial source code version control system used (Oh no, not another version control system...).

Haven't any of these people heard of virtual machines?

I set up a Gentoo Linux image in Qemu and use that for learning Go. It doesn't matter that my laptop is running Windows, the tools I need for Go are right there in the vm. Install mercurial? All I had to do was emerge it. And since I wasn't installing it on my primary machine I didn't think twice.

With all the work I've done on embedded systems and Processing I just don't care so much about what OS or device some software will run on. I have the tools to connect the different platforms. This early release of Go seems especially suited for running network services, and I can whip up a Processing GUI for that, no problem. I do think that a ready-built vm image, either for Qemu or a VMWare appliance, would be a great thing.

Saturday, November 07, 2009

Arduino Audio Sandbox

I'm listening to my rendition of the 4ms Autonomous Bassline Generator. Here's how I put it together. First I needed a reasonable audio generator for the Arduino. I found an Adrian Freed Arduino sketch that makes a good sine wave using the PWM2 output. Adrian uses a 256 slot wavetable and some fixed point math. I took his wavetable and his interrupt routine and got that running. Next I wanted one octave of musical notes, so I looked up the frequency values and put them into a 12 slot array. I started with five notes in a melody array that I would cycle through over and over, but now that has grown to eight notes. I play that three times in a row, then generate a new set of melody nodes and run that.

The sine wave I was getting was good, but I wanted a raspier sound, so I added a second wave table (this one in RAM) and filled it with random values. My first attempt at mixing this with the sine wave failed. All I got was noise. I worked with the values some and got it working, but I think the next build will have a total volume level. The noise level is user variable, and the sine level is the master volume minus the noise level.

I used a LDR (light sensor) to set the noise level, but it was more fun to use it to alter the tempo. My desk gets a sliver of sunlight crossing it around 12:30 pm, so I set the Arduino on the desk. The music starts out slow, getting faster as the light moves over it, then slowing again as darkness returns. If a cloud passes in front of the sun that also slows the tempo.

This is more fun than you might expect already, but I have several ideas for continuing the project. I'm going to use one of my Arduino Pro boards to build this as a permanent fixture. I'll have to build an enclosure for it, with a built-in audio amplifier and speaker. I'll mount the LDR on top and a few variable resistors. I also want to try IR synchronization like the original ABG project. I'll probably add a breadboard section for experimenting with the generated audio.

On the software side I want to expand the melody section to three 'passages'. The default will be to cycle through each in turn, over and over again. A second mode will change just one or two notes in each passage. There will also be a way to replace all the notes in the melody at once. The goal here is to make a kind of musical game, with the Arduino playing the bassline and the human improvising over the top.
Support This Site