[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[sc-users] FFT + SCSoundFileView



Fabrice, is this of any help ? 
not done anything with SCSoundFileView and FFT.

my other reason for posting is a slightly related question:
how do those wicked colour FFT plots I've seen in some progs work?

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

{ FFT(b.bufnum,AudioIn.ar(1)) }.play

(
	var limit=120;
	w=SCWindow("scope",Rect(100,100,400,400)).front;
	m=SCMultiSliderView(w,Rect(10,10,380,380))
		.thumbSize_(1).drawRects_(false).drawLines_(true);
	
	~array=Array.new;
	
	~task=Task({
		inf.do({ |i|
			b.getn(0,n,{ |buf|
				var z,c;
				z=buf.clump(2).flop;
				z=[Signal.newFrom(z[0]),Signal.newFrom(z[1])];
				c=Complex(z[0],z[1]).magnitude.round(0.01);
				if(i<limit,{~array=~array.grow(1).add(c) });
				defer({ m.value=c/50 })
			});
			0.04.wait
		})
	})
)

~task.start
~task.stop

//plot
(
	var l=5,nX,nY;
	nX=~array.size;
	nY=~array.first.size;
	w=SCWindow("",Rect(100,100,l*nX+20,l*nY+20)).front;
	nX.do({ |x|
		nY.do({ |y|
			SCStaticText(w,Rect(l*x+10,l*y+10,l,l))
				.backColor_(Color(  * ((~array[x][y].clip(0,1) )!3)  ))
		})
	})
)


_______________________________________________________________ 
Situated in Italy, what is Stromboli? 

postmaster.co.uk
http://www.postmaster.co.uk/cgi-bin/meme/quiz.pl?id=181