diff --git a/release-packaging/Classes/FluidBufExperiments.sc b/release-packaging/Classes/FluidBufExperiments.sc deleted file mode 100644 index aed0c97..0000000 --- a/release-packaging/Classes/FluidBufExperiments.sc +++ /dev/null @@ -1,29 +0,0 @@ -FluidBufExperiments { - - *allocMatch{|server, srcbuf, rank=1| - var dstbuf,srcbufnum; - - srcbufnum = srcbuf.bufnum; - - server = server ? Server.default; - dstbuf = Buffer.new(server:server,numFrames:0,numChannels:1); - - server.listSendMsg( - [\b_gen, srcbufnum, "BufMatch",dstbuf.bufnum, rank] - ); - ^dstbuf; - } - - - *allocMatchAsync{|server, srcbuf, rank=1| - - var dstbuf,srcbufnum; - - srcbufnum = srcbuf.bufnum; - server = server ? Server.default; - dstbuf = Buffer.new(server:server,numFrames:0,numChannels:1); - server.sendMsg(\cmd, \AsyncBufMatch, srcbufnum, dstbuf.bufnum, rank); - ^dstbuf; - } - -} diff --git a/release-packaging/ignore/Examples/buffer_compositing/fileiterator.sc b/release-packaging/ignore/Examples/buffer_compositing/fileiterator.sc new file mode 100644 index 0000000..89cf368 --- /dev/null +++ b/release-packaging/ignore/Examples/buffer_compositing/fileiterator.sc @@ -0,0 +1,37 @@ +//destination buffer +b = Buffer.alloc(s,1); +c = Array.new(); + +//this patch requests a folder and will iterate through all accepted audiofiles and concatenate them in the destination buffer. It will also yield an array with the numFrame where files start in the new buffer. + +( +var tempbuf,dest=0, fileNames; + +FileDialog.new({|selection| + var total; + fileNames = PathName.new(selection[0]) + .entries + .select({|f| + [\wav, \WAV, \mp3,\aif].includes(f.extension.asSymbol);}); + total = fileNames.size() - 1; + Routine{ + fileNames.do{|f, i| + f.postln; + ("Loading"+i+"of"+total).postln; + tempbuf = Buffer.read(s,f.asAbsolutePath); + s.sync; + c = c.add(dest); + FluidBufCompose.process(s,tempbuf.bufnum,dstStartAtA:dest,srcBufNumB:b.bufnum,dstBufNum:b.bufnum); + s.sync; + b.updateInfo(); + s.sync; + dest = b.numFrames; + }; + "load buffers done".postln; + }.play; +}, fileMode:2); +) + +b.plot +c.postln +b.play diff --git a/release-packaging/ignore/Examples/nmf/JiT-NMF.scd b/release-packaging/ignore/Examples/nmf/JiT-NMF.scd new file mode 100644 index 0000000..bb137ba --- /dev/null +++ b/release-packaging/ignore/Examples/nmf/JiT-NMF.scd @@ -0,0 +1,57 @@ +s.reboot + +//this patch does just-in-time nmf processes on buffer, faking a slightly delayed real-time version of it +//what is happening: +//a circular buffer is doing a fake real time - every half second, it sends a frame to be proceesed by NMF~, requesting 3 ranks. Because this latter process is randomly seeded and not sorted, the 3 ranks are not getting similar results each time, hence the random pan + +( +b = Buffer.alloc(s,s.sampleRate * 2); +c = Buffer.new(s,0,3); +d = Buffer.new(s,0,3); +e = Buffer.read(s,File.realpath(FluidBufNMF.class.filenameSymbol).dirname.withTrailingSlash ++ "../AudioFiles/Nicol-LoopE-M.wav"); +g = Bus.audio(s,1); +h = Buffer.loadCollection(s, Signal.rectWindow(22491).fade(0,440).fade(22049,22489,1,0).put(22490,0)); + +SynthDef(\becauseIcan,{arg bufnum = 0, nmfa = 0, nmfb = 0, input = 0, env = 0; + var head, head2, duration, audioin, halfdur; + duration = BufFrames.kr(bufnum) / 2; + halfdur = duration / 2; + head = Phasor.ar(0,1,0,duration); + head2 = (head + halfdur) % duration; + + // circular buffer writer + audioin = In.ar(input,1); + BufWr.ar(audioin,bufnum,head,0); + BufWr.ar(audioin,bufnum,head+duration,0); + + // cue the calculations via the language + SendReply.ar(head > 500, '/processplease',2); + SendReply.ar(head > (halfdur + 500), '/processplease',1); + + // read the 2 buffers with an envelop + Out.ar(0, Splay.ar(BufRd.ar(3,nmfa,head,0,1) * BufRd.ar(1,env,head,0,1)) + Splay.ar(BufRd.ar(3,nmfb,head2,0,1) * BufRd.ar(1,env,head2,0,1))); +}).add; + +SynthDef(\playa, { arg output = 0, bufnum = 0; + Out.ar(output,PlayBuf.ar(1,bufnum,loop:1)); +}).add; +) + +// instantiate the player +x = Synth(\playa,[\output, g.index, \bufnum, e.bufnum]); + +// instantiate the processor +y = Synth(\becauseIcan,[\bufnum, b.bufnum, \nmfa, c.bufnum, \nmfb, d.bufnum, \input, g.index, \env, h.bufnum], x, 'addAfter'); + +// instantiate the listener to cue the processing from the language side +( +w = OSCFunc({ arg msg; + if(msg[3]== 1, { + FluidBufNMF.process(s, b.bufnum, nFrames: 22500, dstBufNum: c.bufnum, rank: 3, fftSize: 1024, winSize: 512, hopSize: 256); + }, { + FluidBufNMF.process(s, b.bufnum, 22050, 22500, dstBufNum: d.bufnum, rank: 3, fftSize: 1024, winSize: 512, hopSize: 256); + });}, '/processplease', s.addr); +) + +// stop it all +b.free;c.free;d.free;e.free;f.free;g.free;w.clear;x.free; y.free;