Clap Beats
A10. Clap Beats
Jianhao Ma, Shihao (Tiger) Zhang
Links:https://editor.p5js.org/roger1mjh/sketches/rJMbn4UG
Video Demo:
Inspiration:
Originally, we were thinking about using poseNet and camera to make a gesture interactive random beats generator with Markov Chains. However, we thought that almost every IMA student knows how to do gesture control in P5, and we have done similar projects before. Therefore, we switched to sound control. The idea is: the tempo of the beat is determined by the frequency users clap their hands.
Design Decisions:

The music style we aimed for is Lo-Fi. At first, I imported 26 tracks of samples and categorized them into five arrays. We tried to incorporate some visual designs like changing colors and shapes based on the last track played and the array it belongs to. Sadly, Shihao was sick when we moved on to that part so we just left it as future works.
How does it work?
So the core part of the project is to measure the tempo of users' clapping and map it to bpm. I set a threshold for the variable that stores the value returned by getLevel method. Once the volume exceeds certain decibel, a new data of the time(millis) it happens is pushed into an array. When the array has four values, a math calculation is executed to get the average difference of those values. Once the array.length exceeds four, the shift method I coded will delete the first value of the array. The average difference returned previously will be formatted and mapped to a new bpm value.
Difficulties
Honestly, a lot. At first I imported too many tracks. It makes the browser too laggy after I've been working on it for hours. I essentially deleted over half of them. Coding the Markov Chain for over twenty tracks is tedious. Although, I used array as short cuts, the final result is still over 300 lines of codes. Debugging and optimizing is the most painful part. I honestly don't know how I get it to work(in most cases). Just testing out all the possible approaches I could think of to make the program slimmer.
Instruction
- Adjust the volume down
- make sure the environment is quite enough
- play the beats for over 5 secs
- start clapping your hands, close to the mic, keep it clear and steady for over 7 claps
- change your tempo gradually and gently
Comments
Post a Comment