BufHPSS has now proper class declaration and a skeleton of helpfile

nix
Pierre Alexandre Tremblay 7 years ago
parent 00351686b0
commit 190a5ded14

@ -1,15 +1,12 @@
FluidBufHPSS{
*process { arg server, src, offsetframes = 0, numframes = -1, offsetchans = 0, numchans = -1, harmbuf, percbuf, psize = 31, hsize = 17, winsize = 4096, hopsize = 1024, fftsize = -1;
server = server ? Server.default;
if(src.bufnum.isNil) {Error("Invalid Buffer").format(thisMethod.name, this.class.name).throw};
server.sendMsg(\cmd, \BufHPSS, src.bufnum, offsetframes, numframes, offsetchans, numchans,
if( harmbuf.isNil, -1, {harmbuf.bufnum}),
if( percbuf.isNil, -1, {percbuf.bufnum}), psize, hsize, winsize, hopsize, fftsize);
*process { arg server, srcBufNum, startAt = 0, nFrames = -1, startChan = 0, nChans = -1, harmBufNum, percBufNum, pSize = 31, hSize = 17, winSize = 4096, hopSize = 1024, fftSize = -1;
if(srcBufNum.isNil) { Error("Invalid buffer").format(thisMethod.name, this.class.name).throw};
server = server ? Server.default;
harmBufNum = harmBufNum ? -1;
percBufNum = percBufNum ? -1;
server.sendMsg(\cmd, \BufHPSS, srcBufNum, startAt, nFrames, startChan, nChans, harmBufNum, percBufNum, pSize, hSize, winSize, hopSize, fftSize);
}
}
}

@ -9,4 +9,4 @@ FluidBufSines{
server.sendMsg(\cmd, \BufSines, srcBufNum, startAt, nFrames, startChan, nChans, sineBufNum, resBufNum, bandwidth, threshold, minTrackLen, magWeight, freqWeight, winSize, hopSize, fftSize);
}
}
}

@ -1,14 +1,63 @@
s.reboot
TITLE:: FluidBufHPSS
summary:: Buffer-Based Harmonic-Percussive Source Separation Using Median Filtering
categories:: Libraries>FluidDecomposition
related:: Guides/FluCoMa, Guides/FluidDecomposition
(
b = Buffer.read(s,"/Users/owen/Desktop/denoise_stn/sources/01-mix.wav");
h = Buffer.new(s);
p = Buffer.new(s);
)
DESCRIPTION::
It is part of the Fluid Decomposition Toolkit of the FluCoMa project. 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::
FluidBufHPSS.process(s,b,0,1-1,0,-1,h,p,31,17)
METHOD:: process
(describe method here)
p.play;
h.play;
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:: harmBufNum
(describe argument here)
ARGUMENT:: percBufNum
(describe argument here)
ARGUMENT:: pSize
(describe argument here)
ARGUMENT:: hSize
(describe argument here)
ARGUMENT:: winSize
(describe argument here)
ARGUMENT:: hopSize
(describe argument here)
ARGUMENT:: fftSize
(describe argument here)
returns::
Nothing, as the various destination buffers are declared in the function call.
EXAMPLES::
code::
b = Buffer.read(s,"../../../AudioFiles/01-mix.wav".resolveRelative);
b.play
::

@ -3,143 +3,36 @@ 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");
b = Buffer.read(s,"/Users/pa/Documents/documents@hudd/research/projects/fluid corpus navigation/research/fluid_decomposition/AudioFiles/Tremblay-AaS-SynthTwoVoices-M.wav");
c = Buffer.new(s);
x = Buffer.new(s);
y = Buffer.new(s);
~fft_size = 1024;
~frame_size = 512;
~hop_size = 256;
~which_rank = 0;
d = Buffer.new(s);
)
(
// without sources
// with basic params
Routine{
t = Main.elapsedTime;
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);
FluidBufHPSS.process(s, b.bufnum, harmBufNum: c.bufnum, percBufNum: d.bufnum);
s.sync;
(Main.elapsedTime - t).postln;
}.play
);
// with sources only
(
Routine{
t = Main.elapsedTime;
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
)
c.query;
c.play;
d.query;
d.play;
//look at the dictionaries and activations
c.plot;x.plot; y.plot;
//null test of the sum of sources
{(PlayBuf.ar(5,c.bufnum,doneAction:2).sum)+(-1*PlayBuf.ar(1,b.bufnum,doneAction:2))}.play
//nullsumming tests
{(PlayBuf.ar(1,c.bufnum))+(PlayBuf.ar(1,d.bufnum))+(-1*PlayBuf.ar(1,b.bufnum,doneAction:2))}.play
// play around
{Splay.ar(PlayBuf.ar(5,c.bufnum,doneAction:2))}.play
//play a single source
{PlayBuf.ar(5,c.bufnum,doneAction:2)[~which_rank].dup}.play
//play noise through a filter
(
{
var chain;
chain = FFT(LocalBuf(~fft_size), WhiteNoise.ar());
chain = chain.pvcollect(~fft_size, {|mag, phase, index|
[mag * BufRd.kr(5,x.bufnum,DC.kr(index),0,1)[~which_rank]];
});
IFFT(chain);
}.play
)
//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.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]*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]];
});
[0,IFFT(chain)];
}.play
)
// test with stereo input
Buffer.freeAll(s)
(
b = Buffer.read(s,"/Users/pa/Desktop/verystereo.wav");
c = Buffer.new(s);
x = Buffer.new(s);
y = Buffer.new(s);
~fft_size = 1024;
~frame_size = 512;
~hop_size = 256;
)
b.play
// with everything changed to make it much faster
(
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);
FluidBufHPSS.process(s,b.bufnum, 44100, 44100, 0, 0, c.bufnum, d.bufnum, 51, 31 ,2048,512,4096); // need to change these for something sensible
s.sync;
(Main.elapsedTime - t).postln;
}.play
)
//test a single rank
{PlayBuf.ar(10,c.bufnum,doneAction:2)[9].dup}.play
// 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)
(
b = Buffer.read(s,"/Users/pa/Desktop/verystereo.wav");
c = Buffer.new(s);
d = Buffer.new(s);
)
b.play
(
Routine{
t = Main.elapsedTime;
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.bufnum,8810,44100,1,1,d.bufnum,rank:2);
s.sync;
(Main.elapsedTime - t).postln;
}.play
)
c.query
c.play
d.query
d.play
);

@ -36,4 +36,3 @@ Routine{
(Main.elapsedTime - t).postln;
}.play
);

Loading…
Cancel
Save