It's been a while since my last post (sorry!), and there's a lot to tell!
Things are progressing nicely! David and I presented the project at the CIS Senior Design Fair, where we earned an honorable mention. We wanted to have a working prototype to show off at the fair so we had a marathon lab session the night before - we got a 6-note demo unit working about an hour before the fair started. People seemed really excited by the concept and once they actually played the instrument, it seemed like they really understood what we were going for. You can view our poster here. Below is a pic of the demo unit.
This was our setup for the demo. There are two layers in that little package, the top is just the thumbsticks soldered into a perfboard, and the bottom is the ADC / Multiplexing board David put together (shown right). At the bottom of this board is a surface mount version of the PSoC 4 (the development board version is in red in the corner of the above image). We bought a couple surface mount PSoC 4s for $1 each because they'll make for a smaller, sleeker, more permanent package. The one used here we soldered onto an Adafruit breakout board with a solder paste pump and a reflow oven. I've never tried that before, but it was pretty tough. Miraculously it worked, and we now have a slick little package that has headers for the thumbsticks' analog and digital signals, and just requires power and an SPI connection from the Raspberry Pi.
For the demo we also beefed up our synth patch. This guy has a different architecture, and is 6-note polyphonic. There are two significant changes to the patch. The first is that we have a different way of routing OSC messages. Rather than sending a separate message for each of the six notes' four parameters (pitch, filter, pulse width, and volume), we now can just send one message per active note. If only one note is playing, only one message gets sent containing all of its parameters in one shot. This improved performance dramatically. The CPU is no longer pegged all the time when the program runs and there are fewer pops in the audio output (especially when the Pd gui is hidden). We also decided to do away with the low-pass filter because we suspected it was a CPU hog. Now each note is generally structured like this:
The note column receives a pitch in MIDI notation from the python script. It converts that to a frequency in Hz, multiplies it by -1 and sends it to two sawtooth oscillators (phasors - the negative frequency produces an 'inverse saw' that sounds nicer at low frequencies I think). The right phasor receives the natural pitch, but the left phasor receives the pitch after it passes through the detune mechanism, where it gets knocked up or down a couple Hz (based on the second parameter from the OSC message). The difference in tuning between the two phasors creates an interference pattern that gives the note a fatter sound. The stream from each phasor is split in two, one of which gets multiplied by -1, uninverting it. It gets a little complicated here, but you can follow along in the patch and it'll make more sense. The inverted and uninverted signal are summed, creating a triangle wave from the saw (this happens for both oscillators), and then the natural and detuned triangle waves are combined for a fat triangle (that's an industry term right there). Additionally, the inverted sawtooth waves are combined for a fat saw. The third parameter from the OSC message, the mix, allows the user to fade between a triangle and a saw wave, making the note sound darker or brighter respectively. Finally, the whole signal is multiplied by the fourth OSC parameter, the volume, divided by 100 to change the amplitude. There is a screenshot of the patch below.
So now we're kicking into high gear. It's the last week of this project (it's due on Thursday) and there's a lot to be done. I went into center city and bought some acrylic from Everything Plastic to use for the enclosure. Later today, I'm making an excursion to Home Depot for some wood to build the base out of. I plan to lurk around the Fab Lab, building this box and waiting for an opening on the laser cutter.
One of the big problems we have is figuring out how to mount these thumbsticks. There aren't perfboards large enough (and still affordable) to cover our whole project, and tiling smaller perfboards presents a slew of other problems. We've decided to basically lasercut our own perfboard out of acrylic. So we'll see how that goes.
In other exciting news:
The screen works! This was extremely annoying so I'm going to write down what I did because there doesn't seem to be any other guide for this display online. This is the newer version of Adafruit's 2.2" TFT LCD, which has a different driver chip and pinout than the old one (it's also higher resolution). I followed this guide to install the version of the kernel without built-in drivers. Then I hooked up the display according to this wiring guide. Then, I loaded the drivers with:
sudo modprobe fbtft_device name=adafruit22a
The 22a is important, because it distinguishes this new display from the old display drivers. If you type dmesg it should spit out a bunch of log stuff about which SPI devices are registered, GPIOs in use, etc. If it mentions something about 9-bit SPI not being available, and emulating it with 8-bit, that's fine, the intrepid github user notro who wrote these drivers took care of everything. You should then be able to type:
con2fbmap 1 1
And it'll pipe the console over to the screen. If you type:
con2fbmap 1 0
That'll map console 1 back to framebuffer 0 (your original monitor / tv / whatever). To get the X desktop session to show up on the display, I had to follow these instructions (for the X server), the command
didn't work for some reason. Anyway, so now I can start developing a Python gui that'll display useful information about what notes are playing, what effects are active, and so on. Ideally the Pi will boot up and immediately launch that app, also initializing Pure Data and loading the correct patch in the process. That startup script will probably be a lot of work in its own right.
Well, next time I post, hopefully the project will be finished! Unless I do microposts this week.