Introduction: Arduino Musical Instrument
As part of the Musical Human Computer Interaction module of the Audio Technology MSc at the University of Wolverhampton, we were asked to research, design and build a musical interface/digital instrument.
I chose to build an instrument based on a harp and designed with children in mind. Having a young daughter she often commented that the strings on a Harp felt hard and slightly painful after a while, so a more tactile interface was researched.
Step 1: Human Computer Interaction
After research and investigation it was decided to utilise a strain gauge type of sensor to replace the traditional pluckable Harp strings. A variable resistance rubber / carbon cord was chosen as a string replacement option. It would convert human pulling motion into a digital output.
The logical interface for this sensor and the computer was an Arduino board.
Step 2: Configure Arduino
Connect the Arduino board to your PC or Mac via a USB. Open up an appropriate interface software. For this project I used Pd extended, available here Pd Extended
Step 3: Build Breadboard
The breadboard circuit will host your electrical circuit and be the interface between the physical sensors, and the computer via the Arduino.
Use Breadboard 22 guage solid wire jumper cables.
The circuit is the same as a simple LDR circuit shown in diagram 3, replacing the LDR with the variable resistance chord. Arduino and breadboard connection detail shown in diagram 4.
Connect 5v (red) and common ground (blue) from the Arduino. Yellow leads supply the control inputs to the Ardino inputs A0, A1, A2, A3 as shown.
Step 4: Add Sensors
Variable resistance conductive chord.
Measuring stretch forces isn't easy - unless you have some conductive rubber cord. Adafruit Stretch Sensor has a cord with 2 mm diameter, and 1 meter long, made of carbon-black impregnated rubber. Usually this material is used for EMF gasketing, but its also very fun to play with. In a 'relaxed' state, the resistance is about 350 ohms per inch. As you pull on it, the resistance increases (the particles get further apart). As you stretch it out, the resistance increases linearly. So lets say you have a 6 inches piece - thats about 2.1 Kohms. Stretch it to 10 inches long and now it is 10 inches /6 inches x 2.1K = 3.5 Kohms. You can stretch the rubber about 50-70% longer than the resting length, so a 6 inches piece shouldn't be stretched more than 10 inches. Once the force is released, the rubber will shrink back, although its not very 'fast' and it takes a minute or two to revert to its original length.
Further details can be found here Stretch sensor
To test the principle I elected to use 3 sensor strings and place the breadboard and Arduino in the centre of the configuration, as shown to minimise connection distance.
Step 5: Configure Pd Extended
Public sharing of the Pd code can be found in the Git repository here
pack values refers to smoothing
+ value determines midi starting note (60 is middle C).
mtof provides frequency in Hz.
x value determines pitch change.
The patch takes the variable digital response from the conductive sensors and uses the input value to control a tone output. In theory, each string could be allocated it's own note.
There is a slider halfway down the code chain in the first diagram. This allows the value in the number box to be set just above the resting input value from the sensor. As the string is played the threshold is exceeded and a tone is heard. As the string settles after playing the note will cut off as the threshold is passed.
There is also a slider function (qwerty control) within the patch to allow the note to be varied. [Credit Matt Bellingham for patch design]. The patch is set to vary the note up and down by a semitone using letters on keyboard to mimic the double action (Erhard) used on modern concert harps. This function could be reset to be an octave for example. The coding of this function is shown in diagram 2 where "clip" is the range for the slider, in this example an octave (60-72). "Phasor" is the input frequency in Hz.
This variant has been configured to make two tones available per string. Two tones give an effect similar to a drone instrument such as the bagpipes, with one tone giving a background drone.
A reverb has been added to string one using the "freeverb" object.
Step 6: Test and Calibrate Your Device
Trial and error will allow you to adjust the various values within Pd to get the best play-ability form your instrument.
Test Midi to ensure output.
Select input required by clicking on old settings.
Comport in use shown on initial Pd window. Can be changed in Pd patch.
mtof = note in Hz.
A Harp is normally tuned in a Major Diatonic scale.
Edit an object = Ctrl E.
The device could be developed by augmenting the number of strings and allocating each string a note within the diatonic scale.