First Adventures in Heartrate Monitors

MAT594O,  “Sensors and Interfaces for Multimedia Art” taught by Professor Stephen Pope

The goal of the class is to use electronic sensors and other components to make a project that can be used for Multimedia Art. Beyond that there are not many requirements.

For my project I am using a Heartrate Monitor strap from Polar along with the Heartrate Monitor Interface (HRMI) from Sparkfun Electronics.

The Heartrate Monitor is a plastic strap with electrode patches and a transmitter that the user wears around their chest. In typical fitness training situations the user also wears a special Watch that receives the signals from the monitor and displays the heartrate.

I ordered the monitor from Amazon Marketplace (used) and was fortunate to also receive the watch which is useful to verify the software is receiving an accurate heartrate value.

The HRMI provides a simple USB interface to get the numerical heartrate in beats-per-minute over a USB-Serial port.

For my first experiments with the HRMI I decided to persue audio-related examples using MIDI control. Processing.org is used to read the output of the HRMI and translate it to MIDI messages for use by other multimedia applications.

I used the rwmidi library for Processing to output MIDI messages which were received using Ableton Live.

At first I emitted a MIDI note with pitch corresponding to the heartrate. My heartrate typically ranges from ~60 to ~150 except under strenuous exercises. MIDI expects a note number between 0 and 127 though pitches at the low and high ends are not very audible due to frequency limitations. I mapped the heartrate value onto a usable MIDI range and sent it to a software synthesizer in Ableton. For now it emits the note at a constant rate though it might be desirable to be able to modulate the note-rate based on heartrate (for example, a higher heartrate means the notes come more frequently).

The second test I did was to control the master tempo in Ableton using MIDI from the HRMI. This involved using MIDI Controller Change (CC) messages instead of note messages. This involves sending a Channel #, Message # and a value # (0-127). Ableton makes it simple to map MIDI messages so within minutes I had tempo control working. Ableton’s tempo has a range of 20 to 200 which falls within the normal heartrate range.

The result was most interesting while playing back electronica music that has an inherent tempo of 120 beats per minute. At rest (60bpm) the sound is very distorted and pitch-lowered. By doing jumping jacks or other exercise the heartrate increases and the music sounds more normal. Eventually the heartrate shoots past 120bpm and the music distorts again. This is like a rudimentary bio-feedback game where the goal is to keep the music at the proper rate by controlling heartrate. Because heartrate is volatile this is easier said than done.

Below is the basic code used to send MIDI messages for both experiments:

void process(int val){

 midiOutput.sendNoteOn(0, val, 127);
 int cc_val = (int)map(val, 50, 130,0,127); //map to MIDI range

  midiOutput.sendController(0, 100, cc_val); //send controller change message for stuff like tempo sliders in ableton

 delay(100);
 midiOutput.sendNoteOff(0,val,127);
}

Source Links:
Processing.org used for serial and MIDI communication
rwMidi library for Processing
posted on Tuesday, November 11th, 2008 by Pehr in MAT Projects