All posts by Jiffer

The Kitsch-Instrument is a way to make music with every day objects. It uses modular hardware interface and a custom solenoid driver shield for Arduino Uno.

Attaching Solenoids

A series of attachments make it possible to attach these small 5V solenoids to various objects.

(1) Hanger; (2) Stand; (3) Suction Cup

Hardware

The driver shield can use either the 5V Arduino supply or an external power supply to drive big fat solenoids.

The shield also sports a socket for an XBee to trigger your solenoids wirelessly. The Solenoid circuit uses an N-Channel MOSFET to enable a low power Arduino pin to turn on a higher power voltage source. The solenoid driver circuit looks like this:

Make a groove

My favorite way to trigger these is with a fairly basic musical algorithm. Driven by an underlying beat, it uses chance to determine whether or not to trigger. The likelihood of a solenoid firing on a given beat is based on the value read at the corresponding analog input and tempo is controlled by another.

It works as a standalone Arduino project but with an audio programming language like Pure Data where you can easily create sequencer or use other musical algorithms. Here’s a patch I’ve used which performs the “likelihood” algorithm:

Random numbers are generated every beat, if it is greater than the value read by the sensor then go boom, or click at least!!!

At TEI

Bonus pics of me trying to conduct the audience at TEI and kids playing at the demo session:

Downloads

The Pd patch chance-beat2 is one of the modular-muse examples in the Pd library.

I have yet to see a nice simple and expandable approach to communication between Pd and Arduino, especially one that sends more than one value. It can be tricky, especially on the Pd side.

Pd and Arduino code for all 3 parts of this tutorial can be downloaded at github here. If you want to cut to the chase, just open up the files in ArduinoPdBiDir.

This example reads in 3 digital pins, 3 analog pins and sends out 3 values which then are used to drive 3 PWM outputs, however each of these can be easily changed to support more or less I/O.

This will be posted in three parts, first digital, then analog and lastly writing data from Pd back to an Arduino.

Reading in digital values:

In the Arduino code an array is used to list the pins which are to be read. You can change this as needed and everything else should take care of itself on the Arduino side. There is a loop based on the size of the array which will read through all these digital pins and print them to the Serial port.

First the Arduino code must initialize the serial port. This example uses 115200 baud but you can change it. However note that if you go too slow you can see issues depending on how much data you are sending. Here is the Arduino code:

This code sends a “D” followed by the digital values it reads on 3 of the pins (in a for loop) then a lower-case “d” is sent to indicate the end of the packet.

NOTE: all the data sent to Pd uses Serial.println()

This is because Pd does not have great ways to parse strings and characters. Everything comes in as a byte and so it is tricky to keep track of things since depending on the number there will be a different number of bytes (i.e. the number 5 is one byte, the number 15 is two bytes). There are other ways of dealing with this, this is mine.

The Pd patch

On the Pd side serial communication uses the [comport] object. Create a new object named: [comport 4 115200]

The comport object can read and write to a serial port. In this case I specified port 4 and a baud rate of 115200. On your machine the port may be different. To see the list of ports create a message box with the message [devices<

Connect this to the [comport] object and click on the message box. You should get a list of the serial ports in the Pd window. Here’s mine:

The port with tty.usbserial* is my Arduino.

I also put a [close< and [open 4< message boxes in to open and close communications with Arduino. (The 4 here again is where my Arduino shows up).

With the port open the data should flow into the Pd patch.

Formatting the digital inputs:

The capital “D” which is being sent before the digital values is used to format the data. A capital “D” is 68 in ASCII. So first I look for a 68 coming through. This opens a gate and resets the list in the[list append] object.

The 3 values received are packed into a list which can then be “unpacked” to individual outputs. This is done with a few more objects [list prepend], [t l] and [unpack]. When the “d” is seen the gate closes.

You need an “f” in the [unpack] object for every value you are reading. So if you are using 12 digital inputs there should be 12 “f”s.

This is what it looks like inside the read_digital sub-patch. The parse-start-stop.pd file can take in two creation arguments. The start and stop bytes which surround the packet of data. These can be changed to whatever you need. If you want to use different characters to begin and end a packet, just figure out what the ASCII value is and make the changes in the parse-start-stop object.

Musicians have control over a lot of different aspects of sound that they use to create expressive, dynamic music. A violinist may alter their bowing to change the timbre, a horn player may create a swell in volume, a vocalist may vary their vibrato. This is what makes music interesting, it gives it variation, change over time. With computer generated music controlling these parameters is the difference between static, lifeless sounds and interesting expressive sounds.

There are a number of modular-muse objects that can assist in creating musical gestures. The first one is the [mm-env] object:

This is a user generated envelope (an envelope describes the change of a parameter over time). It could be used to control a filter sweep, a change in frequency or an increase in vibrato among others.

These are the controls:

time (ms) – How long to “play” through the whole envelope

max out – value at the top of the graph

min out – value at the bottom of the graph

graph – The graph can be changed by clicking on one of the points and drawing a new shape with the mouse. This gives the gesture a shape.

trigger – Clicking will trigger the gestures, alternatively sending a bang message in the first inlet the array will trigger the gesture.

Here’s an example of using it to sweep a filter:

Notice the bang triggers two envelopes, one which is used to control volume and another to sweep the filter cutoff frequency.

The modular-muse library for Pure Data (Pd) makes it easier and faster to program a wide variety of sound interactions from effects processors to electronic instruments. All the modular-muse objects are built out of existing Pd-extended objects. Installation consists of adding the folder containing the library to your Pd-extended path. This guide will explain in detail how to install the modular-muse library for Pd.

Install Pd

First of all, you’ll Pd-extended. Note, modular-muse does not work with the “vanilla” Pd installation as it relies on several extensions available only in the extended version. Pd is available on Windows, Mac and Linux. Download and install instructions for Pd-extended are here.

Download modular-muse OK, now that you have Pd-extended you’ll want to download the modular-muse library from github here. modular-muse installation Extract the zip file somewhere you’ll remember, I like to create a Pd folder and inside that a libraries folder. When you extract the zip file it will create a folder called: modular-muse-master/ Now you just need to add the new modular-muse-master folder to the “path” Pd-extended. This allows it to see all the patches in this folder.

Add modular-muse to the Pd-extended path

Launch Pd-extended and open up the Preferences, depending on your platform this will be under the main Pd-extended menu (Mac) or the Edit menu. Click “New” to add a new path. Browse to the folder modular-muse-master/ you just created and click “choose”.

Close and re-open Pd. Thats it, you’re ready to use the modular-muse library.

Create a new patch in Pd (File > New)

Add a new object (Put > Object)

Enter “mm” and click outside the object you should see the modular-muse object:

I am privileged to be an eCSite fellow which is an NSF funded program that brings computer science into traditional educational settings. That means I get to talk about how amazingly cool of a tool the computer is for music to a bunch of middle school kids.

There are so many incredible ways a computer can contribute to the conversation about music! As I create modules to present in the class I will add information here about how they can be used as well as links to download the software.

The ideaLAB is the Denver Public Libraries hackerspace for teens. They’ve got all sorts of awesomeness going on there, from game design workshops to a recording studio where kids can record and produce their own tracks.