now working with the right SC interface (buffer/rank/fftsize/windowsize/hopsize)

nix
Pierre Alexandre Tremblay 8 years ago
parent 22c21782aa
commit d9cf021745

@ -13,8 +13,10 @@ void BufNMF(World *world, struct SndBuf *dstBuf, struct sc_msg_iter *msg)
int dstChanCount = dstBuf->channels; int dstChanCount = dstBuf->channels;
uint32 srcBufNum = msg->geti(); uint32 srcBufNum = msg->geti();
int repetitions = msg->geti(); uint32 rank = msg->geti();
uint32 rank = 5; uint32 fftSize = msg->geti();
uint32 windowSize = msg->geti();
uint32 hopSize = msg->geti();
if (srcBufNum >= world->mNumSndBufs){ if (srcBufNum >= world->mNumSndBufs){
Print("fdNMF is not happy because the source buffer does not exist.\n"); Print("fdNMF is not happy because the source buffer does not exist.\n");
@ -31,8 +33,6 @@ void BufNMF(World *world, struct SndBuf *dstBuf, struct sc_msg_iter *msg)
int srcFrameCount = srcBuf->frames; int srcFrameCount = srcBuf->frames;
int srcChanCount = srcBuf->channels; int srcChanCount = srcBuf->channels;
Print("dstChanCount = %d\n",dstChanCount);
// if (dstChanCount < rank) { // if (dstChanCount < rank) {
// Print("fdNMF is not happy because the destination buffer has a lower channel count than the number of ranks.\n"); // Print("fdNMF is not happy because the destination buffer has a lower channel count than the number of ranks.\n");
// return; // return;
@ -42,8 +42,8 @@ void BufNMF(World *world, struct SndBuf *dstBuf, struct sc_msg_iter *msg)
std::vector<double> tmp_vec(srcFrameCount); std::vector<double> tmp_vec(srcFrameCount);
//construct STFT processors //construct STFT processors
stft::STFT stft(1024, 2048, 256); stft::STFT stft(windowSize, fftSize, hopSize);
stft::ISTFT istft(1024, 2048, 256); stft::ISTFT istft(windowSize, fftSize, hopSize);
//for each channels //for each channels
for (int j=0;j<srcChanCount;j++){ for (int j=0;j<srcChanCount;j++){

@ -1,7 +1,7 @@
// adds an instance method to the Buffer class // adds an instance method to the Buffer class
+ Buffer { + Buffer {
fdNMF { arg dstBuf, repetitions = 0; fdNMF { arg dstBuf, rank = 1, fftSize = 2048, windowSize = 2048, hopSize = 512;
if(bufnum.isNil) { Error("Cannot call % on a % that has been freed".format(thisMethod.name, this.class.name)).throw }; if(bufnum.isNil) { Error("Cannot call % on a % that has been freed".format(thisMethod.name, this.class.name)).throw };
server.listSendMsg([\b_gen, dstBuf.bufnum, "BufNMF", bufnum, repetitions]) server.listSendMsg([\b_gen, dstBuf.bufnum, "BufNMF", bufnum, rank, fftSize, windowSize, hopSize])
} }
} }

@ -7,7 +7,7 @@ b.plot;
c = Buffer.alloc(s,50000); c = Buffer.alloc(s,50000);
// run the code // run the code
b.fdNMF(c); b.fdNMF(c, 5, 2048, 1024, 256);
// read to check // read to check
c.plot c.plot
Loading…
Cancel
Save