> FrAid
 

Real time processing

FrAid scripts used in the demo

300Hz low-pass filter

cutoffF = 300;
controlVar(cutoffF,200);
fil(x)= if x < cutoffF then 1 else 0;
//fil(x)= if (x < 500) | (x > 2000) then 1 else 0;

plot(fil,-1,1.5,5000,-1);

sf=10000;
f(x)=recordSound(sf,2048);

fff(x)=fft1(f);
g(x)=ifft1({fff*fil});
plot(f,g);

//fft to the signals
plot({abs(fff)},{abs(fft1(g))},0,.01,1,-.01);

//spectrum
spectrum( f, 512 );
spectrum( g, 512 );

plot( histogramS( f, 19 ), histogramS( g, 19 ) );

playSound( g );

//now change cutoffF=1000;
//listen for the change
//then make a high-pass 1000Hz by just fil(x)= if x > cutoffF then 1 else 0;
       

Function generator

A=.1;
F=200;                                                       
controlVar(A,.1,F,100);
fun(x) = if isNextIntEven(x) then 1 else 0; //squares
//fun(x)=sin(x);                            //sine
s(x)=A*fun(F*2*Pi*x);
Fs=10000;        //make sure Fs >= 2 * F*2*Pi to avoid aliasing 
sampleLength=1;
ss(x)=sampleL(s,0,sampleLength,sampleLength*Fs);
plot(ss);
playSound(ss);
       

Triangle wave (use with the generator above)

line( x, X1 ,Y1, X2, Y2 )=( (Y2-Y1)*x + Y1*X2 - Y2*X1 )/( X2 - X1 ); //line through (X1,Y1) and (X2,Y2)
nextDivPoint( x, d ) = if isNextIntEven( x ) then nextInt( x ) - d
                                             else nextInt( x ) - 1 + d;
d = .5;
controlVar( d, .5 );
triangleWave( x ) = if x < nextDivPoint( x, d ) then line( x, nextInt(x) - 1, 0, nextDivPoint( x, d ), if isNextIntEven(x) then -1 else 1 )
                                                      else line( x, nextDivPoint( x, d ), if isNextIntEven(x) then -1 else 1, nextInt(x), 0 );
//plot(triangleWave);
//in the fuction generator above just do fun(x)=triangleWave(x);