One of the needs of this project is to detect where the hands of the player are touching the drum. For this an breakout board will be used. It communicates with the I2C protocol and has 12 different pins to detect touch:
While I am not using Adafruit's board, I am using their library and code example:
import audiocore import board import audiobusio import busio import time import adafruit_mpr121 i2c = busio.I2C(board.GP9, board.GP8) i2c_touch_address = 0x5A mpr121 = adafruit_mpr121.MPR121(i2c) right_drum_strokes = ["Na", "Ta", "Tin", "Te", "Ti", "Tun", "TheRe"] left_drum_strokes = ["Ghe", "Ga", "Ke"] all_drum_strokes = right_drum_strokes + left_drum_strokes waveObjects = [] for i in range(0, len(all_drum_strokes)): waveObjects.append(audiocore.WaveFile(open("tabla_samples/" + all_drum_strokes[i] + ".wav", "rb"))) audio = audiobusio.I2SOut(board.GP0, board.GP1, board.GP2) while True: for i in range(12): if mpr121[i].value: audio.play(waveObjects[0]) while audio.playing: pass
This code though, blocks the program while a .wav file is being played, which feels quite unintuitive when trying to simulate a drum, which can always produce sound when stroked. On the other hand, if we play a sound every time the sensors are being touched, the file gets played hundreds of times per second just upon touching the sensor's pins. The following code fixes that:
import audiocore import board import audiobusio import busio import time import adafruit_mpr121 # Configure touch sensor i2c = busio.I2C(board.GP9, board.GP8) i2c_touch_address = 0x5A mpr121 = adafruit_mpr121.MPR121(i2c) # Load .wav files right_drum_strokes = ["Na", "Ta", "Tin", "Te", "Ti", "Tun", "TheRe"] left_drum_strokes = ["Ghe", "Ga", "Ke"] all_drum_strokes = right_drum_strokes + left_drum_strokes wave_objects = [] for i in range(0, len(all_drum_strokes)): wave_objects.append(audiocore.WaveFile(open("tabla_samples/" + all_drum_strokes[i] + ".wav", "rb"))) # Configure I2S output audio = audiobusio.I2SOut(board.GP0, board.GP1, board.GP2) ready = True while True: touched = any(mpr121.touched_pins) if not touched: ready = True for i in range(12): if mpr121[i].value and ready: audio.play(wave_objects[0]) ready = False
Now we can play it "like a drum"!
Another tricky part with this project is how to build a drum and allow for touch sensitivity on the drum itself. For that I am experimenting with DIY conductive ink. I am trying out the following materials:
- Graphite powder
- Liquid tape
- Acrylic paint
My favourite resources I came across when researching about conductive paint where this webpage:
https://www.instructables.com/Make-Conductive-Glue-and-Glue-a-Circuit/
And this video:
Basically we try to saturate either acrylic paint or liquid tape with graphite powder.
While the instructable suggests using liquid tape as the best cheap option after having tried other glues and powdered metals, I believe he did not experiment with plain acrylic paint. I tried both and found the acrylic paint to be much more easier to handle and it definitely smells less toxic than the liquid tape. While the graphite-saturated liquid tape did prove to have less resistance than the graphite-saturated acrylic paint, this might be because it has a very thick texture and naturally there is a thicker layer of it when painting. With acrylic paint one can simply add a second layer of paint and the resistance will drop approximately by half. Acrylic paint: Approved!
Here is a video where I am trying out the touch sensitivity and responsiveness of the DIY, open sou(r)ce, conductive paint at different lengths away from the metal touch sensor pin:
Success!
Stay tuned for a prototype of the actual drum, audio and more!