I took it upon myself to setup a heart rate sensor for use while a person plays our game Zen Trials. I used a wireless heart Rate Sensor that required a slightly hacked up way of using it. There is a receiver than needs to be powered from a usb, however the data cant be retrieved from this so there is an led light that flashes on the board to represent the heart-rate value, I used an Arduino with a light sensor taped to the wireless receiver to pick up these values in processing for use with Ben’s Audio creation.
Firstly I created a rather standard BPM calculating script based on beats in a fifteen second period, times by four to give beats per minute, this worked but only updates every fifteen seconds and will cause drastic changes in sound. I needed something that would constantly update the BPM value so the sound was fluid. I decided to calculate the heart-rate based on the time in-between each beat, you can then divide this by sixty to give you beats per minute. This value was also slightly sporadic but it updated every time there was a new value which was what I wanted. To try and reduced the dramatic increase and decrease i created a five slot array and averaged the last 5 values constantly replacing the oldest value with a new one, this gave a better value that was representative of BPM, fairly accurate but didn’t jump by crazy ammounts when a new value was produced.
We decided that adding audio based on a heartbeat value of a player would then allow the user to have a feedback loop of their relaxation and could try to control it, Ben worked on the Audio after i had the heart rate sensor working.
I used this as my first chance to use Github, it was fun to learn a new tool and I plan to use it wherever possible in future projects. You can find the code here.