RedFingerprint a different plot



a class that works with objects like arrays, envelopes and wavetables.  it translates them to length/angle pairs and can then plot these in a separate window.


*new(array, normalize= true)

do the translation and create a new fingerprint object

<>points

coordinates as points

gui(name, bounds, scale= 1)

create a new window and plot the points



/*

//select your weapon of choice

GUI.cocoa;

GUI.swing;

*/


l= {1.0.rand}.dup(100) //an array with random values

a= RedFingerprint(l) //a fingerprint object

a.points //coordinates

a.gui //plot

a.gui(scale:0.33)


l= Env.perc.asSignal

a= RedFingerprint(l)

a.gui

l= Env.sine.asSignal

a= RedFingerprint(l)

a.gui


l= Array.series(90, 0.1, 0.1) //90 values between 0.1 and 9

a= RedFingerprint(l, true) //normalize

a.gui

l= l.normalize

a= RedFingerprint(l, true)

a.gui



//--shortcuts

{1.0.rand}.dup(100).fingerprint.gui

Array.series(90, 0.1, 0.1).fingerprint.gui

Array.series(90, 0.1, 0.1).normalize.fingerprint.gui

Array.series(300, 0.1, 0.1).fingerprint.gui

Pseq([13, 0, 3, 3.44], 2).fingerprint.gui


Env.perc.fingerprint(true, 200).gui

Env.perc(0.4).fingerprint.gui

Env.perc(0.4, curve:2).fingerprint.gui

Env.perc(0.4, curve:-2).fingerprint.gui

Env.sine.fingerprint.gui

Env.adsr.fingerprint.gui

Wavetable.sineFill(128, 1/[1, 2, 3, 4]).fingerprint.gui

Wavetable.chebyFill(128, [0.3, -0.8, 1.1]).fingerprint.gui

Wavetable.chebyFill(1024, {2.0.rand2}.dup(3)).fingerprint.gui("wavetable", Rect(50, 50, 450, 450))


a= Env.adsr(0.2, 0.02).fingerprint

a.gui(background: Color.red(0.5, 0.5), width: 5)

a.gui(scale: 0.75, background: Color.white, color: Color.red, width: 5)



//--animation

(

var win, scale, points, cnt= 0, width= 400, height= 400;

win= GUI.window.new("fingerprint", Rect(100, 100, width, height), false).front;

win.view.background= Color.black;

scale= width/4;

win.drawHook= {

var a= sin(cnt.fold(0, 100)/2pi).linlin(-1, 1, 0.01, 1);

var b= sin(cnt.fold(0, 90)/2pi).linlin(-1, 1, 0.1, cnt.fold(0, 50)/25);

points= Wavetable.sineFill(256, 1/[1, 2, a, b]).fingerprint.points;

GUI.pen.translate(win.bounds.width/2, win.bounds.height/2);

GUI.pen.strokeColor_(Color.white);

GUI.pen.moveTo(points[0]*scale);

points.do{|x| GUI.pen.lineTo(x*scale)};

GUI.pen.stroke;

cnt= cnt+0.5;

};

{while{win.isClosed.not} {win.refresh; (1/25).wait}}.fork(AppClock);

)



//--sound

(

s.waitForBoot{

b= Buffer.alloc(s, 256, 1);

SynthDef(\wormsnd, {|out= 0, bufnum, freq= 60, amp= 0.01, pan= 0|

Out.ar(out, Pan2.ar(OscN.ar(bufnum, freq, 0, amp), pan));

}).send(s);

};

)


(

var n= 5, method= \chebyFill, scale= 190,

win, points, cnt= 100, wt0, wt1, syn;

syn= Synth(\wormsnd, [\bufnum, b.bufnum, \amp, 1]);

win= GUI.window.new("fingerprint", Rect(100, 100, 400, 400), false);

win.view.background= Color.white;

wt1= Wavetable.perform(method, b.numFrames, {1.0.rand2}.dup(n));

win.drawHook= {

if(cnt==100, {

wt0= wt1;

n= 2.rrand(20);

wt1= Wavetable.perform(method, b.numFrames, {1.0.rand2}.dup(n));

cnt= 0;

});

wt0= wt0.blend(wt1, cnt/1000);

b.sine1(wt0, false, false, false);

syn.set(\freq, wt0.mean*100+100);

points= wt0.fingerprint.points;

GUI.pen.width_(2);

GUI.pen.translate(win.bounds.width/2, win.bounds.height/2);

GUI.pen.strokeColor_(Color.blue(0.5, 0.5));

GUI.pen.moveTo(points[0]*scale);

points.do{|x| GUI.pen.lineTo(x*scale)};

GUI.pen.stroke;

cnt= cnt+1;

};

win.front;

{while{win.isClosed.not} {win.refresh; (1/25).wait}}.fork(AppClock);

)


(

var n= 60, method= \chebyFill, scale= 120,

win, points, cnt= 5, wt0, wt1, syn, pat= 0;

syn= Synth(\wormsnd, [\bufnum, b.bufnum]);

win= GUI.window.new("fingerprint", Rect(100, 100, 320, 240), false);

win.view.background= Color.black;

wt1= Wavetable.perform(method, b.numFrames, {1.0.rand2.round(0.1)}.dup(n));

win.drawHook= {

if(cnt%4!=0, {

syn.set(\amp, 1);

if(cnt%5==(0), {

wt0= wt1;

n= 1.rrand(10);

wt1= Wavetable.perform(method, b.numFrames, {1.0.rand2.round(0.1)}.dup(n));

cnt= 0;

pat= pat+1;

});

wt0= wt0.blend(wt1, cnt/(wt1[0]*3000+30));

b.sine1(wt0, false, false, false);

syn.set(\freq, wt0.mean*(wt0[0]*500)+80);

points= wt0.fingerprint.points;

GUI.pen.width_(2);

GUI.pen.translate(win.bounds.width/2, win.bounds.height/2);

GUI.pen.strokeColor_(Color.white);

GUI.pen.moveTo(points[0]*scale);

points.do{|x| GUI.pen.lineTo(x*scale)};

GUI.pen.stroke;

}, {

syn.set(\amp, 0);

if(0.2.coin, {cnt= cnt-1});

});

cnt= cnt+1;

};

win.front;

{while{win.isClosed.not} {win.refresh; (1/25).wait}}.fork(AppClock);

)