Sonifying IR spectroscopy data – rhythm

For today’s exciting episode, I’m using the simplified spectrum data from glycine to generate a sound, and then looping round the same data to play the sound in a kind of ‘rhythm’:

~name = "glycine";
~path = Document.current.dir.asString++"/"++ ~name ++".csv";
f = CSVFileReader.readInterpret(~path);

f = ((f.flop[1] * -1) + 1).normalize;

f = (f*100).asInteger;
f = f.differentiate.removeEvery([0]).integrate;
f = f/100;

~peaksIndices = f.differentiate.sign.findAll([1,-1]);

g = Array.fill(f.size, 0); { |i| g[i] = f[i] }; // Daniel's line

~amps = g;

// [f,~amps].plot(~name, Rect(840,0,600,450));

~freqs = (36..128).resamp1(f.size).midicps;

SynthDef(\glycine, { | gate=1, amp |
	var env, sig;
	sig =`[~freqs, ~amps, nil],;
	env =, gate, doneAction: 2);,, 0, env))

Pbind(	\instrument, \glycine,
		\amp, Pseq(~amps, 4).collect { |amp| if(amp > 0) {amp} {Rest}},
		\dur, 0.02,

In other news, my collaborator Steve has been having Ideas. Watch this space.

One Response to Sonifying IR spectroscopy data – rhythm

  1. Pingback: Amino Piano | Experiment, Experience, Explore and Engage

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s