diff --git a/fdNMF.cpp b/fdNMF.cpp index f5e7080..ec77ec1 100644 --- a/fdNMF.cpp +++ b/fdNMF.cpp @@ -18,13 +18,17 @@ void BufNMF(World *world, struct SndBuf *srcBuf, struct sc_msg_iter *msg) size_t srcFrameCount = srcBuf->frames; size_t srcChanCount = srcBuf->channels; - size_t dstBufNum = msg->geti(); + long dstBufNum = msg->geti(); + long dictBufNum = msg->geti(); + long actBufNum = msg->geti(); size_t rank = msg->geti(); size_t iterations = msg->geti(); size_t fftSize = msg->geti(); size_t windowSize = msg->geti(); size_t hopSize = msg->geti(); + Print("%i %i %i\n", dstBufNum, dictBufNum, actBufNum); + if (dstBufNum >= world->mNumSndBufs){ Print("fdNMF is not happy because the destination buffer does not exist.\n"); return; diff --git a/fdfNMF.sc b/fdfNMF.sc index e2ab467..d4f7aee 100644 --- a/fdfNMF.sc +++ b/fdfNMF.sc @@ -1,6 +1,6 @@ // adds an instance method to the Buffer class + Buffer { - fdNMF { arg dstBuf, rank = 1, iterations = 100, fftSize = 2048, windowSize = 2048, hopSize = 512, action; + fdNMF { arg dstBuf, dictBuf, actBuf, rank = 1, iterations = 100, fftSize = 2048, windowSize = 2048, hopSize = 512, action; var resp; if(bufnum.isNil) { Error("Cannot call % on a % that has been freed".format(thisMethod.name, this.class.name)).throw }; @@ -13,6 +13,6 @@ }); }, '/done', server.addr); - server.listSendMsg([\b_gen, bufnum, "BufNMF", dstBuf.bufnum, rank, iterations, fftSize, windowSize, hopSize]) + server.listSendMsg([\b_gen, bufnum, "BufNMF", if(dstBuf.isNil, -1, {dstBuf.bufnum}), if(dictBuf.isNil, -1, {dictBuf.bufnum}), if(actBuf.isNil, -1, {actBuf.bufnum}), rank, iterations, fftSize, windowSize, hopSize]) } } diff --git a/tests.scd b/tests.scd index 11be1f8..94ed39b 100644 --- a/tests.scd +++ b/tests.scd @@ -5,8 +5,11 @@ s.reboot b = Buffer.read(s,"/Users/pa/Documents/documents@hudd/research/projects/fluid corpus navigation/research/denoise_stn/sources/01-mix.wav"); b.play; c = Buffer.alloc(s,b.numFrames,5); +x = Buffer.alloc(s,b.numFrames,5); +y = Buffer.alloc(s,b.numFrames,5); -d = Main.elapsedTime; b.fdNMF(c,5, 100, 1024,1024,256,{e = Main.elapsedTime; (e-d).postln}) + +d = Main.elapsedTime; b.fdNMF(c, x, nil, 5, 100, 1024,1024,256,{e = Main.elapsedTime; (e-d).postln}) {(PlayBuf.ar(5,c.bufnum,doneAction:2).sum)+(-1*PlayBuf.ar(1,b.bufnum,doneAction:2))}.play {Splay.ar(PlayBuf.ar(5,c.bufnum,doneAction:2))}.play @@ -14,6 +17,8 @@ d = Main.elapsedTime; b.fdNMF(c,5, 100, 1024,1024,256,{e = Main.elapsedTime; (e- {PlayBuf.ar(5,c.bufnum,doneAction:2)[0].dup}.play + + //////////////////////////// // test for osc clutter