Tuesday, July 06, 2021

musical glove with the CPX

SUMMARY:
  • The notes play a regular pattern at whatever pitch: 1 beat, half beat, quarter beat, rest quarter beat, quarter beat, rest quarter beat, 1 beat, rest half beat.
  • Twist hand to the right increases the pitch
  • Twist hand to the left decreases the pitch
  • Tempo starts at 120 bpm
  • Tilt hand up from wrist increases tempo by 20 bpm
  • Tilt hand down from wrist decreases tempo by 20 bpm
  • Loudness starts at 128
  • Shaking increases loudness by 30
  • Turning hand face up decreases loudness by 30

This is a great tutorial by Kathy Ceceri. In turn Kathy's inspiration was Imogen Heap who pioneered the MiMu Gloves.

Here is an Imogen Heap TEDX talk about and demonstration of the gloves: Sculpting Music with Mi.Mu Gloves

Given that the MiMu gloves cost 1,299 pounds for one and 2599 pounds for a pair this one is a poor persons version. The end product sound is not quite as good ;-) but the concept is brilliantly illustrated.

The making part is straightforward. I bought a cheap pair of leather riggers gloves at Bunnings and attached the CPX with some velcro. I want to clip the battery pack onto my belt so the only other piece of equipment was a JST battery extension cable.

The coding is the more interesting / challenging part of this project. You start with a single note (for instance, middle C) and can vary up to four things: the pitch, duration of the note, tempo (the default is 120 bpm) and volume (ranges from 0 to 255). My simpler version, so far, just varies 3 of those things, the pitch, tempo and volume. Follow the link to Kathy's instructions for varying the note duration as well.

Setup code, you need to make a "loudness" variable:

Tilt the fingers / hand up or down to change the tempo:

Map the sideways tilt (angular pitch) to the frequency (musical pitch) of the notes. I mapped a maximum tilt to the left (+90 degrees) to Low C (represented by the number 131) and a maximum titl to the right (-90 degrees) to High B (represented by the number 988):
(Click on this image for a closer view of how the map function works)

Use some remaining hand motions (shake and face down) to change the volume. For this I created the variable "loudness":
Finishing touches, I've just focused on the core functionality for now. I could:
  • make the neopixels light up in different ways depending on the hand motion (update 11/9/21 I've set the photon hue trail to the tempo value and paused the photon by 500 msec as it travels. I'm getting a nice range of photon trail colours as the tempo changes.
  • add a small speaker to make the sounds louder (I have ordered some from adafruit)(update 11/9/21 I've hacked some speakers through the A0 speaker pin to the speaker jack, this improves the sound since the CPX speaker is too soft
  • incorporate the note duration features as suggested by Kathy, the author of the adafruit tutorial (update 11/9/21 I've copied Kath's suggestions here so now have 4 variables: the pitch, duration of the note, tempo (the default is 120 bpm) and volume (ranges from 0 to 255)
SUMMARY:
The notes play a regular at whatever pitch: 1 beat, half beat, quarter beat, rest quarter beat, quarter beat, rest quarter beat, 1 beat, rest half beat.
Twist hand to the right increases the pitch
Twist hand to the left decreases the pitch
Tempo starts at 120 bpm
Tilt hand up from wrist increases tempo by 20 bpm
Tilt hand down from wrist decreases tempo by 20 bpm
Loudness starts at 128
Shaking increases loudness by 30
Turning hand face up decreases loudness by 30

No comments: