// title: example fft sc->processing v2 // author: Fredrik Olofsson // description: // an extended version of http://sccode.org/1-4Ty // this one sends 3 streams of spectral data at the same time - high, mid and low filtered. // note: quite heavy on the cpu and sends a lot of data via osc (1024*3 values 61times/second). // play any sound on output bus 0 and 1 to test it. e.g. {SoundIn.ar!2}.play // updated to work with sc3.9 and processing 3.3.6 // code: /* //--processing code: import oscP5.*; import netP5.*; OscP5 oscP5; final int BUFFERSIZE= 2048; //should correspond with fft size in supercollider final int BUFFERSIZE2= BUFFERSIZE/2; float[] fftArrayHi; float[] fftArrayMd; float[] fftArrayLo; void setup() { size(1280, 768); frameRate(60); background(0); noSmooth(); fftArrayHi= new float[BUFFERSIZE2]; fftArrayMd= new float[BUFFERSIZE2]; fftArrayLo= new float[BUFFERSIZE2]; for (int i= 0; i=0, 0, a); Out.kr(bus+i, d.min(1)); }); }).load; SynthDef(\avTrkMd, {|in= 0, amp= 1, bus, freq= 1000| var z= BBandPass.ar(Mix(InFeedback.ar(in, 2)*amp), freq); var chain= FFT(LocalBuf(buffersize), z); Array.fill(buffersize2, {|i| var a= Unpack1FFT(chain, buffersize, i); var d= Demand.kr(chain>=0, 0, a); Out.kr(bus+i, d.min(1)); }); }).load; SynthDef(\avTrkLo, {|in= 0, amp= 1, bus, freq= 100| var z= BLowPass.ar(Mix(InFeedback.ar(in, 2)*amp), freq); var chain= FFT(LocalBuf(buffersize), z); Array.fill(buffersize2, {|i| var a= Unpack1FFT(chain, buffersize, i); var d= Demand.kr(chain>=0, 0, a); Out.kr(bus+i, d.min(1)); }); }).load; s.sync; Synth(\avTrkHi, [\in, 0, \amp, 0.3, \bus, busHi]); Synth(\avTrkMd, [\in, 0, \amp, 0.3, \bus, busMd]); Synth(\avTrkLo, [\in, 0, \amp, 0.3, \bus, busLo]); Routine.run({ inf.do{ var fftArrayHi= busHi.getnSynchronous(buffersize2); var fftArrayMd= busMd.getnSynchronous(buffersize2); var fftArrayLo= busLo.getnSynchronous(buffersize2); n.sendMsg(\fftArrayHi, *fftArrayHi); //sending 1024 values n.sendMsg(\fftArrayMd, *fftArrayMd); //sending 1024 values n.sendMsg(\fftArrayLo, *fftArrayLo); //sending 1024 values (1/61).wait; //a tiny bit faster than framerate }; }); CmdPeriod.doOnce({ busHi.free; busMd.free; busLo.free; }); }; )