diff --git a/fdNMF/tests.scd b/fdNMF/tests.scd index 0ffa71d..996be66 100644 --- a/fdNMF/tests.scd +++ b/fdNMF/tests.scd @@ -3,7 +3,7 @@ s.reboot // test for efficiency ( -b = Buffer.read(s,"/Users/pa/Documents/documents@hudd/research/projects/fluid corpus navigation/research/denoise_stn/sources/01-mix.wav"); +b = Buffer.read(s,"/Users/pa/Documents/documents@hudd/research/projects/fluid corpus navigation/research/archives-2017-18/denoise_stn/sources/01-mix.wav"); c = Buffer.new(s); x = Buffer.new(s); y = Buffer.new(s); @@ -15,19 +15,29 @@ y = Buffer.new(s); ( // without sources -r = Routine{ +Routine{ t = Main.elapsedTime; - FDNMF.process(s,b,0,-1,0,-1,nil,x,0,y,0,5,100,0,~frame_size,~hop_size,~fft_size); + FDNMF.process(s,b.bufnum,0,-1,0,-1,nil,x.bufnum,0,y.bufnum,0,5,100,0,~frame_size,~hop_size,~fft_size); s.sync; (Main.elapsedTime - t).postln; }.play ); -// with sources +// with sources only ( -r = Routine{ +Routine{ t = Main.elapsedTime; - FDNMF.process(s,b, 0,-1,0,-1,c,nil,0,nil,0,5,100,0,~frame_size,~hop_size,~fft_size); + FDNMF.process(s,b.bufnum, 0,-1,0,-1,c.bufnum,nil,0,nil,0,5,100,0,~frame_size,~hop_size,~fft_size); + s.sync; + (Main.elapsedTime - t).postln; +}.play +) + +// with everything +( +Routine{ + t = Main.elapsedTime; + FDNMF.process(s,b.bufnum, 0,-1,0,-1,c.bufnum,x.bufnum,0,y.bufnum,0,5,100,0,~frame_size,~hop_size,~fft_size); s.sync; (Main.elapsedTime - t).postln; }.play @@ -60,13 +70,13 @@ c.plot;x.plot; y.plot; ) //play noise through an activation -{WhiteNoise.ar(BufRd.kr(5,y.bufnum,Phasor.ar(1,1/~hop_size,0,(b.numFrames / ~hop_size + 1)),0,1)[~which_rank] * 0.01)}.play +{WhiteNoise.ar(BufRd.kr(5,y.bufnum,Phasor.ar(1,1/~hop_size,0,(b.numFrames / ~hop_size + 1)),0,1)[~which_rank])*0.5}.play //play noise through both activation and filter ( { var chain; - chain = FFT(LocalBuf(~fft_size), WhiteNoise.ar(BufRd.kr(5,y.bufnum,Phasor.ar(1,1/~hop_size,0,(b.numFrames / ~hop_size + 1)),0,1)[~which_rank]*0.15),0.25,1); + chain = FFT(LocalBuf(~fft_size), WhiteNoise.ar(BufRd.kr(5,y.bufnum,Phasor.ar(1,1/~hop_size,0,(b.numFrames / ~hop_size + 1)),0,1)[~which_rank]*12),0.5,1); chain = chain.pvcollect(~fft_size, {|mag, phase, index| [mag * BufRd.kr(5,x.bufnum,DC.kr(index),0,1)[~which_rank]]; @@ -92,17 +102,19 @@ y = Buffer.new(s); b.play ( -r = Routine{ +Routine{ t = Main.elapsedTime; - FDNMF.process(s,b,0,-1,0,-1,c,x,0,y,0,5,100,0,~frame_size,~hop_size,~fft_size); + FDNMF.process(s,b.bufnum,0,-1,0,-1,c.bufnum,x.bufnum,0,y.bufnum,0,5,100,0,~frame_size,~hop_size,~fft_size); s.sync; (Main.elapsedTime - t).postln; }.play ) +//test a single rank {PlayBuf.ar(10,c.bufnum,doneAction:2)[9].dup}.play -c.getn(0, 10, {|x|x.postln}) +// play them all across in a sort of upmixed stereo... +{Splay.ar(PlayBuf.ar(10,c.bufnum,doneAction:2))}.play //test process on a segment Buffer.freeAll(s) @@ -116,17 +128,18 @@ d = Buffer.new(s); b.play ( -r = Routine{ +Routine{ t = Main.elapsedTime; - FDNMF.process(s,b,44100,44100,0,1,c,rank:2); + FDNMF.process(s,b.bufnum,44100,44100,0,1,c.bufnum,rank:2); s.sync; (Main.elapsedTime - t).postln; t = Main.elapsedTime; - FDNMF.process(s,b,88200,44100,1,1,d,rank:2); + FDNMF.process(s,b.bufnum,8810,44100,1,1,d.bufnum,rank:2); s.sync; (Main.elapsedTime - t).postln; }.play ) - c.query -d.query \ No newline at end of file +c.play +d.query +d.play diff --git a/fdTransients/tests.scd b/fdTransients/tests.scd new file mode 100644 index 0000000..6c84f7e --- /dev/null +++ b/fdTransients/tests.scd @@ -0,0 +1,39 @@ +s.reboot +//////////////////////////// +// test for efficiency + +( +b = Buffer.read(s,"/Users/pa/Documents/documents@hudd/research/projects/fluid corpus navigation/research/archives-2017-18/denoise_stn/sources/01-mix.wav"); +c = Buffer.new(s); +d = Buffer.new(s); +) + +( +// without basic params +Routine{ + t = Main.elapsedTime; + FDTransients.process(s,b.bufnum, transBufNum:c.bufnum, resBufNum:d.bufnum); + s.sync; + (Main.elapsedTime - t).postln; +}.play +); + +c.query; +c.play; +d.query; +d.play; + +//nullsumming tests +{(PlayBuf.ar(1,c.bufnum))+(PlayBuf.ar(1,d.bufnum))+(-1*PlayBuf.ar(1,b.bufnum,doneAction:2))}.play + + +// with everything changed to make it much faster +( +Routine{ + t = Main.elapsedTime; + FDTransients.process(s,b.bufnum, 44100, 44100, 0, 0, c.bufnum, d.bufnum, 100, 512,256,1,2,1,12,20); + s.sync; + (Main.elapsedTime - t).postln; +}.play +); + diff --git a/release-packaging/fdNMF/HelpSource/Classes/FDNMF.schelp b/release-packaging/fdNMF/HelpSource/Classes/FDNMF.schelp index be291fb..a1e5841 100644 --- a/release-packaging/fdNMF/HelpSource/Classes/FDNMF.schelp +++ b/release-packaging/fdNMF/HelpSource/Classes/FDNMF.schelp @@ -22,8 +22,8 @@ This is the method that calls for the factorisation to be calculated on a given ARGUMENT:: server The server on which the buffers to be processed are allocated. -ARGUMENT:: srcBuf - The source material to be decomposed through the NMF process. The different channels of multichannel buffers will be processing sequentially. +ARGUMENT:: srcBufNum + The index of the buffer to use as the source material to be decomposed through the NMF process. The different channels of multichannel buffers will be processing sequentially. ARGUMENT:: startAt Where in the srcBuf should the NMF process start, in sample. @@ -37,11 +37,11 @@ ARGUMENT:: startChan ARGUMENT:: nChans For multichannel srcBuf, how many channel should be processed. -ARGUMENT:: dstBuf - The buffer where the different reconstructed ranks will be reconstructed. The buffer will be resized to STRONG::rank * numChannelsProcessed:: channels and STRONG::sourceDuration:: lenght. If STRONG::nil:: is provided, the reconstruction will not happen. +ARGUMENT:: dstBufNum + The index of the buffer where the different reconstructed ranks will be reconstructed. The buffer will be resized to STRONG::rank * numChannelsProcessed:: channels and STRONG::sourceDuration:: lenght. If STRONG::nil:: is provided, the reconstruction will not happen. -ARGUMENT:: dictBuf - The buffer where the different dictionaries will be written to and/or read from: the behaviour is set in the following argument. If STRONG::nil:: is provided, no dictionary will be provided. +ARGUMENT:: dictBufNum + The index of the buffer where the different dictionaries will be written to and/or read from: the behaviour is set in the following argument. If STRONG::nil:: is provided, no dictionary will be provided. ARGUMENT:: dictFlag This flag decides of how the dictionnary buffer passed as the previous argument is treated. @@ -51,8 +51,8 @@ ARGUMENT:: dictFlag ## 2 || The passed buffer is considered as a template for the dictionaries, and will therefore not change. Its dictionaries should match the values above. :: -ARGUMENT:: actBuf - The buffer where the different activations will be written to and/or read from: the behaviour is set in the following argument. If STRONG::nil:: is provided, no activation will be provided. +ARGUMENT:: actBufNum + The index of the buffer where the different activations will be written to and/or read from: the behaviour is set in the following argument. If STRONG::nil:: is provided, no activation will be provided. ARGUMENT:: actFlag This flag decides of how the activation buffer passed as the previous argument is treated. diff --git a/release-packaging/fdNMF/classes/fdNMF.sc b/release-packaging/fdNMF/classes/fdNMF.sc index 84fe36a..6afd73d 100644 --- a/release-packaging/fdNMF/classes/fdNMF.sc +++ b/release-packaging/fdNMF/classes/fdNMF.sc @@ -1,16 +1,13 @@ FDNMF { - *process { arg server, srcBuf, startAt = 0, nFrames = -1,startChan = 0,nChans = -1, dstBuf, dictBuf, dictFlag = 0, actBuf, actFlag = 0, rank = 1, iterations = 100, sortFlag = 0, windowSize = 1024, hopSize = 256, fftSize = -1, windowType = 0, randomSeed = -1; + *process { arg server, srcBufNum, startAt = 0, nFrames = -1, startChan = 0, nChans = -1, dstBufNum, dictBufNum, dictFlag = 0, actBufNum, actFlag = 0, rank = 1, iterations = 100, sortFlag = 0, windowSize = 1024, hopSize = 256, fftSize = -1, windowType = 0, randomSeed = -1; - var dstBufNum,dictBufNum,actBufNum; - - if(srcBuf.bufnum.isNil) { Error("Invalid buffer").format(thisMethod.name, this.class.name).throw}; + if(srcBufNum.isNil) { Error("Invalid buffer").format(thisMethod.name, this.class.name).throw}; server = server ? Server.default; + dstBufNum = dstBufNum ? -1; + dictBufNum = dictBufNum ? -1; + actBufNum = actBufNum ? -1; - dstBufNum = if(dstBuf.isNil, -1, {dstBuf.bufnum}); - dictBufNum = if(dictBuf.isNil, -1, {dictBuf.bufnum}); - actBufNum = if(actBuf.isNil, -1, {actBuf.bufnum}); - - server.sendMsg(\cmd, \BufNMF, srcBuf.bufnum, startAt, nFrames, startChan, nChans, dstBufNum, dictBufNum, dictFlag, actBufNum, actFlag, rank, iterations, windowSize, hopSize,fftSize); + server.sendMsg(\cmd, \BufNMF, srcBufNum, startAt, nFrames, startChan, nChans, dstBufNum, dictBufNum, dictFlag, actBufNum, actFlag, rank, iterations, windowSize, hopSize,fftSize); } } \ No newline at end of file diff --git a/release-packaging/fdSTFTPass/HelpSource/Classes/FDSTFTPass.schelp b/release-packaging/fdSTFTPass/HelpSource/Classes/FDSTFTPass.schelp index 2db83d7..c980edb 100644 --- a/release-packaging/fdSTFTPass/HelpSource/Classes/FDSTFTPass.schelp +++ b/release-packaging/fdSTFTPass/HelpSource/Classes/FDSTFTPass.schelp @@ -30,7 +30,6 @@ returns:: EXAMPLES:: -code:: Summing with the inverse (gain of -1) with a delay of the latency gives us CPU-expensive silence. code:: { var source = PinkNoise.ar(0.1); DelayN.ar(source, delaytime:1024/s.sampleRate, mul: -1) + FDSTFTPass.ar(source, 1024, 256, 1024); }.play @@ -41,7 +40,7 @@ code:: :: Stereo Input Tests. code:: - { FDSTFTPass.ar([SinOsc.ar(222,mul: 0.1), PinkNoise.ar(Decay.ar(Impulse.ar(0.666,mul: 0.1), 0.5))], fftSize:1024)}.play + { FDSTFTPass.ar([SinOsc.ar(222,mul: 0.1), PinkNoise.ar(Decay.ar(Impulse.ar(0.666,mul: 0.2), 0.5))], fftSize:1024)}.play :: Stereo Parameter Tests. code:: diff --git a/release-packaging/fdTransients/HelpSource/Classes/FDTransients.schelp b/release-packaging/fdTransients/HelpSource/Classes/FDTransients.schelp new file mode 100644 index 0000000..c2aa538 --- /dev/null +++ b/release-packaging/fdTransients/HelpSource/Classes/FDTransients.schelp @@ -0,0 +1,72 @@ +TITLE:: FDTransients +summary:: A Non-Real-Time Transient Extractor +categories:: Libraries>FluidDecomposition +related:: Overviews/FluCoMa + +DESCRIPTION:: +A non-real-time transient extractor implementing footnote::This was made possible thanks to the FluCoMa project (http://www.flucoma.org/) funded by the European Research Council (https://erc.europa.eu/) under the European Union’s Horizon 2020 research and innovation programme (grant agreement No 725899).:: + +CLASSMETHODS:: + +METHOD:: process +(describe method here) + +ARGUMENT:: server +(describe argument here) + +ARGUMENT:: srcBufNum +(describe argument here) + +ARGUMENT:: startAt +(describe argument here) + +ARGUMENT:: nFrames +(describe argument here) + +ARGUMENT:: startChan +(describe argument here) + +ARGUMENT:: nChans +(describe argument here) + +ARGUMENT:: transBufNum +(describe argument here) + +ARGUMENT:: resBufNum +(describe argument here) + +ARGUMENT:: order +(describe argument here) + +ARGUMENT:: blockSize +(describe argument here) + +ARGUMENT:: padding +(describe argument here) + +ARGUMENT:: skew +(describe argument here) + +ARGUMENT:: threshFwd +(describe argument here) + +ARGUMENT:: threshBack +(describe argument here) + +ARGUMENT:: windowSize +(describe argument here) + +ARGUMENT:: debounce +(describe argument here) + +returns:: (describe returnvalue here) + + +INSTANCEMETHODS:: + + +EXAMPLES:: + +code:: +(some example code) +:: \ No newline at end of file diff --git a/release-packaging/fdTransients/classes/fdTransients.sc b/release-packaging/fdTransients/classes/fdTransients.sc index 7dba72f..0f70cea 100644 --- a/release-packaging/fdTransients/classes/fdTransients.sc +++ b/release-packaging/fdTransients/classes/fdTransients.sc @@ -1,16 +1,12 @@ FDTransients { - *process { arg server, srcBuf, startAt = 0, nFrames = -1, startChan = 0, nChans = -1, transBuf, resBuf, order = 200, blockSize = 2048, padding = 1024, skew = 0, threshFwd = 3, threshBack = 1.1, windowSize = 14, debounce = 25; + *process { arg server, srcBufNum, startAt = 0, nFrames = -1, startChan = 0, nChans = -1, transBufNum, resBufNum, order = 200, blockSize = 2048, padding = 1024, skew = 0, threshFwd = 3, threshBack = 1.1, windowSize = 14, debounce = 25; - var transBufNum,resBufNum; - - if(srcBuf.bufnum.isNil) { Error("Invalid buffer").format(thisMethod.name, this.class.name).throw}; + if(srcBufNum.isNil) { Error("Invalid buffer").format(thisMethod.name, this.class.name).throw}; server = server ? Server.default; + transBufNum = transBufNum ? -1; + resBufNum = resBufNum ? -1; - transBufNum = if(transBuf.isNil, -1, {transBuf.bufnum}); - resBufNum = if(resBuf.isNil, -1, {resBuf.bufnum}); - - server.sendMsg(\cmd, \BufTransient, - srcBuf.bufnum, startAt, nFrames, startChan, nChans, transBufNum, resBufNum, order, blockSize, padding, skew, threshBack, windowSize, debounce); + server.sendMsg(\cmd, \BufTransients, srcBufNum, startAt, nFrames, startChan, nChans, transBufNum, resBufNum, order, blockSize, padding, skew, threshFwd, threshBack, windowSize, debounce); } -} +} \ No newline at end of file