Close

The Problem With Kids

A project log for DrumKid: aleatoric drum machine

A lo-fi digital drum machine which uses randomness to create unpredictable beats. Runs on Arduino, with audio provided by the Mozzi library.

matt-bradshawMatt Bradshaw 09/19/2019 at 10:160 Comments

I did a bit of accidental user testing recently, which has caused me to redesign part of the circuit. I met up with my cousin and his kids, who are keen musicians, so I decided to show them a prototype of DrumKid. I gave the headphones to Kid A and turned on the power. "I can hear it making noise already!" he exclaimed, before I had even started a drumbeat, and I realised instantly that I had a problem.

As I explained in earlier project logs, using an Arduino to generate audio requires using PWM (pulse width modulation), which basically means turning one of the pins on and off very quickly to produce an audio wave. The frequency at which you turn this pin on and off must be above the human range of hearing, otherwise you will notice an unpleasant noise at this frequency.

The library I am using to produce audio is called Mozzi, and it has a few different modes. It can use a carrier frequency of 32kHz, which is above the human range of hearing, but this requires more processing time, and wouldn't allow me to run all of DrumKid's functions. Instead, I use a more basic mode with a carrier frequency of 16kHz. This frequency is pretty much above my hearing range (I'm 34), but just about within my partner's hearing range (she's 28), so I did realise early-ish in the design process (when I showed her a prototype) that I would have to add a filter to the circuit to get rid of this noise.

I spent quite a while researching filters, and designed a second-order low-pass filter which seemed to do the job... until I showed DrumKid to a child for the first time. It turned out that I hadn't done a good enough job of filtering the signal for people with a really good hearing range (i.e. young people), so I decided to redesign my filter, this time using a bit more science.

I used an audio editing program called Goldwave to analyse the performance of different filters. The 16kHz spike was clear to see. I tried a few different designs, and ended up settling on a twin-T notch filter (a variation of the one recommended on the Mozzi website, which I should definitely have used to start with!). The design was tricky to get right because I was trying to satisfy several competing criteria:

I'm much happier with the signal now - it sounds indistinguishable from the previous circuit, but analysis in Goldwave shows that the carrier signal noise is much reduced. I will add a paragraph in the manual to explain the carrier signal, because it would be a good idea to do further filtering in software if you were going to record a track with DrumKid, especially if you were to pitch-shift it downwards. However, I think the improved filter circuit means that the output signal is now acceptable for the final product.

Discussions