View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide

Sonification of the Cantor Set

The Cantor Set can be sonified by converting it into a chain of short impulses.
The examples below show two ways to implement this, with a different result.

Here is an example of the 11th iteration, with a minimal trigger signal time difference of 0.042 ms.
Listen to the sound directly: cantor_dust.mp3 [99Kbytes mp3]



//___________________________cantor dust examples:
(
var modict, pat, level,  ftrig;
level = 8;
ftrig = 3 ** level / 8;

modict = IdentityDictionary[
                        0 -> [0, 0, 0],
                        1 -> [1, 0, 1]
                ];
pat = Pseq([Prewrite( Pseq([1]), modict, level)], 1);


pat.asStream.all.size;
d = { arg t_trig, freq=5000;
	var trig = Duty.ar(1 / ftrig, 0, Dseq(pat.asStream.all));
	 Ringz.ar(trig, freq, 0.01, 0.1)
}.play;
)



//___________________________cantor dust
// this takes a while to render
(
var modict, pat, level, times;
level = 11;

modict = IdentityDictionary[
                        0 -> [0, 0, 0],
                        1 -> [1, 0, 1]
                ];
pat = Pseq([Prewrite( Pseq([1]), modict, level)], 1);

times = pat.asStream.all.separate { |a,b| b == 1 and: { a == 0 } }.collect(_.size);
d = { arg t_trig, freq=8000;
	var trig = TDuty.ar(Dseq(times) *SampleDur.ir, 0, 1.0, doneAction:2);
	Ringz.ar(trig, freq, 0.01, 0.1)
}.play;
)


//___________________________the cantor set as trigger (SC3)
(
var modict, pat, level,  ftrig;
level = 11;
ftrig = 3** level / 1000;

modict = IdentityDictionary[
                        0 ->[0, 0, 0],
                        1 - [1, 0, 1]
                ];
pat = Pseq([Prewrite( Pseq([1]), modict, level)], inf);


d = { arg t_trig, freq=440; 
	 Ringz.ar(Impulsar.ar(t_trig), freq, 0.01, 0.1)
}.play;


Routine({
	var f, t, fsum=0;
	f = pat.asStream*600 + 1000;
	t = pat.asStream;
	loop {
		fsum = (fsum + f.next).wrap(300, 3000);
		
		d.set(\freq, fsum, \t_trig, t.next);
		ftrig.reciprocal.wait;
	}
}).play;


)






//___________________________the cantor set as trigger (SC2, so this is old code..)
(
var modict, pat, level, sy, ftrig;
level = 11;
ftrig = 3** level / 1000;

modict = IdentityDictionary[
			0 ->[0, 0, 0],
			1 - [1, 0, 1]
		];
pat = Pseq([Prewrite( Pseq([1]), modict, level)], inf);

sy = {
	var freq, stream, fstream, out;
	
	stream =  pat.asStream;
	fstream = pat.asStream;
	freq = Plug.kr(10);
	
	Sequencer.kr({ arg i; 
		freq.source = (freq.source + fstream.next).wrap(10, 100);
		 0.0 
	}, Impulse.kr(ftrig));
	

	out = ImpulseSequencer.ar(stream, Impulse.ar(ftrig));
	Ringz.ar(out, freq*100, 0.01, 0.1);
};

//4.do({ arg i; sy.plot(i+1** 2 / 2) });

sy.play;

)


//___________________________cantor jam (SC2)
(
var modict, pat, sy, ftrig, level;
var magnification;

level = 11;


modict = IdentityDictionary[
			0 ->[0, 0, 0],
			1 - [1, 0, 1]
		];
pat = Pseq([Prewrite( Pseq([1]), modict, level)], inf);
{
magnification = MouseX.kr(1000, 10000);

sy = {
	var freq, stream, fstream, out, fmul, ftrig, mod;
	
	fmul = 15 + 10.0.rand2;
	mod = 100 + 30.rand2;
	stream =  pat.asStream;
	fstream = pat.asStream; 
	freq = Plug.kr(0, 0);
	
	ftrig = 3**level/magnification;
	
	Sequencer.kr({ arg i; 
		freq.source = (freq.source + fstream.next) % mod;
		 0.0 
	}, Impulse.kr(ftrig));
	

	out = ImpulseSequencer.ar(stream, Impulse.ar(ftrig));
	
	Pan2.ar(
		
			SinOsc.ar(freq*fmul + 40, LFNoise2.kr(2000, pi/4), 0.01)
		+	Ringz.ar(out, freq*fmul*6/5 + 40, 0.1, 0.1) 
		
	, 1.0.rand2);
};

//4.do({ arg i; sy.plot(i+1 2 / 2) });

OverlapTexture.ar(sy, 14, 14, 3, 2) 
}.play;


)

/*
authors so far:
jrh 2001
*/


regarding Prewrite
[see: L-Systems in SC]


Links to this Page