Code of Music

Bells

Minimalist, atmospheric instrument.



Original Idea

This project turned out completely different than my initial conception of it. In a separate research project, I am working with a group of high school step dancers exploring how we might view dance through the lens of data science, and hopefully produce new paths into interest in STEM. (Some research questions include, how might we train a computer to recognize one dancer from another? And, how might we quantitatively evaluate a routine based on timing and auditory information?) So, I have all of these audio files that I spliced from dance recordings of individual claps and stomps. I figured I might load a bunch in and create a random sequencer that generates its own Step Routines. Stomps might be accompanied by explosions from the floor, while claps might light up and color the room.

After loading in all the sounds and selecting some probabilities for triggering them, I found that I wasn’t quite sure how timing works in the p5 Sound library. I’ve been learning Supercollider over the last few months where generating sequences with some randomness is quite simple. For example, the following code plays the score to Piano Phase with randomly selected durations and amplitudes to simulate (somewhat) a human playing. In p5, I looked at the score, phrase, and looper, objects but couldn’t quite wrap my head around their usage. So instead, I turned to the visuals and figured I’d get back to sequencing later (though I never did).

var score = [64, 66, 71, 73, 74, 66, 64, 73, 71, 66, 74, 73];

Pdef( \piano1,
	(Pbind(
    \type, \midi,
    \midicmd, \noteOn,
    \midiout, m,
	\chan, 0,
    \freq, Pseq(score, inf).asStream.midicps,
	\dur, 0.2,
    \legato, Prand(list:[0.5, 0.6, 0.7], repeats:inf),
	\amp, Prand(list:[0.2, 0.4, 0.6, 0.8], repeats:inf)
	)
)).quant_(0);

Pdef(\piano1).play;

New Experimentation

When looking at the documentation for the p5 random() function, I came across an example that looked like it might work great for stomps. I especially liked that stroke color is dependent on line height - longer lines are lighter simulating depth.

p5 random() function example

The only thing I had to figure out was how to animate this so that the lines rise from the floor like super minimalist dust after a stomp. Unfortunately I struggled with this too. (I’m no expert at p5 as you can tell.) I first tried creating a big list of x-positions and then using a for-loop to gradually raise their position. This turned out to be blocking the sounds from playing and did not animate correctly.

Instead, I thought back to my days working from The Nature of Code and reimagined the lines as particles shot up like cannons only to fall back down due to the influence of gravity. I found a video on YouTube of Daniel Shiffman explaining how to animate an object’s trail, and then modified his code to create the lines I imagined.

Really, the animation is a hybrid of two p5.js tutorials.

Sound

After getting this working, I played around and didn’t feel like the stomp/clap sounds meshed well. It made me think of rain which made me think of wind chimes for some reason. I went to freesound.org and found a wind-chimey bell sound that I liked.

By itself, it is kind of boring, but sped up randomly we can pretend it is multiple wind chime sounds. I added delay, reverb, and reverse playback to try and create something extra atmospheric. There is kind of a weird effect such that sounds will cancel the playback of each other, but will make it in their entirety to the delay line. Finally, I played with the particle settings to make them hang around the screen longer.


A blog for displaying Willie Payne’s progress in the NYU ITP Course “The Code of Music.”