We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello! I'm working on project where I'm trying to make music from my real time heart beat I'm using ad8232 heart monitor and Arduino UNO Here is my bare bones code:
import processing.sound.*;
SoundFile file;
import processing.serial.*;
import cc.arduino.*;
Arduino arduino;
void setup() {
size(500, 500);
file = new SoundFile(this, "KICK011F.wav");
// Prints out the available serial ports.
println(Arduino.list());
arduino = new Arduino(this, Arduino.list()[1], 57600);
}
void draw() {
background(0);
if (arduino.analogRead(1)<600) {
file.play();
}
I would like to somehow filter the signal and only play one sound on each heart beat. For now it works fine, but sometimes there are multiple sounds for one heart beat. It should somehow see each beat and play the sound once. I'm guessing it could be done by setting a minimal distance between two sounds and choosing the highest value for each beat. I doesn't work if I just set a global theshold, because sometimes the highest value for one beat is lower then second highest in other.
Thanks!
Answers
Recent related post: https://forum.processing.org/two/discussion/23510/heart-beat-recognizing
Do you have a clean QRS curve? Are all those curve the same?
In your code you have
arduino.analogRead(1)<600
. If you are looking at the peak, or above certain threshold, shouldn't you be looking atarduino.analogRead(1)<600
?Without knowing much about the nature of the data, I can suggest the next modified version of draw() right below. Notice that if the data that is above the threshold is less that the length of the sound, then your code or the code below should give you the same result aka. no change.
Kf