corrected the signature of all NRT buffer pointing class definition (fdNMF and fdTransients) to make them more sc. - and changed all the test code accordingly.

corrected a bug in the fdTransients \cmd def (s missing)
made a backbone helpfile for fdTransients
corrected an error in helpfile of FSDTFT
nix
Pierre Alexandre Tremblay 7 years ago
parent 50027f1ca3
commit 059ef7d3a1

@ -3,7 +3,7 @@ s.reboot
// test for efficiency // 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); c = Buffer.new(s);
x = Buffer.new(s); x = Buffer.new(s);
y = Buffer.new(s); y = Buffer.new(s);
@ -15,19 +15,29 @@ y = Buffer.new(s);
( (
// without sources // without sources
r = Routine{ Routine{
t = Main.elapsedTime; 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; s.sync;
(Main.elapsedTime - t).postln; (Main.elapsedTime - t).postln;
}.play }.play
); );
// with sources // with sources only
( (
r = Routine{ Routine{
t = Main.elapsedTime; 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; s.sync;
(Main.elapsedTime - t).postln; (Main.elapsedTime - t).postln;
}.play }.play
@ -60,13 +70,13 @@ c.plot;x.plot; y.plot;
) )
//play noise through an activation //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 //play noise through both activation and filter
( (
{ {
var chain; 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| chain = chain.pvcollect(~fft_size, {|mag, phase, index|
[mag * BufRd.kr(5,x.bufnum,DC.kr(index),0,1)[~which_rank]]; [mag * BufRd.kr(5,x.bufnum,DC.kr(index),0,1)[~which_rank]];
@ -92,17 +102,19 @@ y = Buffer.new(s);
b.play b.play
( (
r = Routine{ Routine{
t = Main.elapsedTime; 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; s.sync;
(Main.elapsedTime - t).postln; (Main.elapsedTime - t).postln;
}.play }.play
) )
//test a single rank
{PlayBuf.ar(10,c.bufnum,doneAction:2)[9].dup}.play {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 //test process on a segment
Buffer.freeAll(s) Buffer.freeAll(s)
@ -116,17 +128,18 @@ d = Buffer.new(s);
b.play b.play
( (
r = Routine{ Routine{
t = Main.elapsedTime; 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; s.sync;
(Main.elapsedTime - t).postln; (Main.elapsedTime - t).postln;
t = Main.elapsedTime; 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; s.sync;
(Main.elapsedTime - t).postln; (Main.elapsedTime - t).postln;
}.play }.play
) )
c.query c.query
c.play
d.query d.query
d.play

@ -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
);

@ -22,8 +22,8 @@ This is the method that calls for the factorisation to be calculated on a given
ARGUMENT:: server ARGUMENT:: server
The server on which the buffers to be processed are allocated. The server on which the buffers to be processed are allocated.
ARGUMENT:: srcBuf ARGUMENT:: srcBufNum
The source material to be decomposed through the NMF process. The different channels of multichannel buffers will be processing sequentially. 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 ARGUMENT:: startAt
Where in the srcBuf should the NMF process start, in sample. Where in the srcBuf should the NMF process start, in sample.
@ -37,11 +37,11 @@ ARGUMENT:: startChan
ARGUMENT:: nChans ARGUMENT:: nChans
For multichannel srcBuf, how many channel should be processed. For multichannel srcBuf, how many channel should be processed.
ARGUMENT:: dstBuf ARGUMENT:: dstBufNum
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. 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 ARGUMENT:: dictBufNum
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. 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 ARGUMENT:: dictFlag
This flag decides of how the dictionnary buffer passed as the previous argument is treated. 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. ## 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 ARGUMENT:: actBufNum
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. 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 ARGUMENT:: actFlag
This flag decides of how the activation buffer passed as the previous argument is treated. This flag decides of how the activation buffer passed as the previous argument is treated.

@ -1,16 +1,13 @@
FDNMF { 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(srcBufNum.isNil) { Error("Invalid buffer").format(thisMethod.name, this.class.name).throw};
if(srcBuf.bufnum.isNil) { Error("Invalid buffer").format(thisMethod.name, this.class.name).throw};
server = server ? Server.default; server = server ? Server.default;
dstBufNum = dstBufNum ? -1;
dictBufNum = dictBufNum ? -1;
actBufNum = actBufNum ? -1;
dstBufNum = if(dstBuf.isNil, -1, {dstBuf.bufnum}); server.sendMsg(\cmd, \BufNMF, srcBufNum, startAt, nFrames, startChan, nChans, dstBufNum, dictBufNum, dictFlag, actBufNum, actFlag, rank, iterations, windowSize, hopSize,fftSize);
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);
} }
} }

@ -30,7 +30,6 @@ returns::
EXAMPLES:: EXAMPLES::
code::
Summing with the inverse (gain of -1) with a delay of the latency gives us CPU-expensive silence. Summing with the inverse (gain of -1) with a delay of the latency gives us CPU-expensive silence.
code:: code::
{ var source = PinkNoise.ar(0.1); DelayN.ar(source, delaytime:1024/s.sampleRate, mul: -1) + FDSTFTPass.ar(source, 1024, 256, 1024); }.play { 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. Stereo Input Tests.
code:: 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. Stereo Parameter Tests.
code:: code::

@ -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 Unions 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)
::

@ -1,16 +1,12 @@
FDTransients { 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(srcBufNum.isNil) { Error("Invalid buffer").format(thisMethod.name, this.class.name).throw};
if(srcBuf.bufnum.isNil) { Error("Invalid buffer").format(thisMethod.name, this.class.name).throw};
server = server ? Server.default; server = server ? Server.default;
transBufNum = transBufNum ? -1;
resBufNum = resBufNum ? -1;
transBufNum = if(transBuf.isNil, -1, {transBuf.bufnum}); server.sendMsg(\cmd, \BufTransients, srcBufNum, startAt, nFrames, startChan, nChans, transBufNum, resBufNum, order, blockSize, padding, skew, threshFwd, threshBack, windowSize, debounce);
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);
} }
} }
Loading…
Cancel
Save