Sync Heartbeat with Music

matteo angelici's icon

Hello everyone,

So, I have some free time in my hands now and I wanted to make this little project for some time now. Simply put, the patcher I'm trying to design will sync a piece of music with your heartbeat. The easy part was putting together the patch that continously detect the heart rate and updates the 'transport' in Max.
However, I'm finding more and more difficult to wrap my head around how to process the music from here.
The first problem I encountered was to detect the bpm of the music (more precisely detect the transient of the kick and the kick only), from there I would apply a spectral stretch to match the bpm of it with the one of my heartbeat without changing pitch. Once the music match the bpm, I need to align the phase (as in: the 4/4 kick should match the heartbeat). To conclude, I would need this process to be repeated every bar or so, to account to possible changes of my heartbeat.

I'm kind of lost here and I'm not sure how to develop this. Perhaps some of you attempted to do something similar and could give me some advice? Or how would you approach this problem in the first place?
It has occurred to me that since my heartbeat is directly influencing the bpm of the transport, perhaps i could sync the music with the transport itself, but I'm not sure how.
To clarify a bit better, imagine if in Ableton Live you had a piece of music playing in a clip. The music is Warped using the 'complex' or 'complex pro' algorithm. and my heart beat would tap on on the Tap Tempo each time it beats. This way I would achieve something similar to what i want to do completely with Max. Perhaps it would be better to create a M4L device for this project instead of a standalone... Although would it even be possible to use a bang message to control the tap tempo in Live?

Thanks in advance.

Klangschmied's icon

Hi, interesting project. One question related to the heartbeat-detection: how do you detect the heartbeat reliable?

double_UG's icon

https://www.ableton.com/en/packs/beatseeker/#?item_type=max_for_live
this could be a starting point