From 22c21782aab3dd0770df179ea5b88192258dd464 Mon Sep 17 00:00:00 2001 From: Pierre Alexandre Tremblay Date: Wed, 11 Jul 2018 19:00:56 +0100 Subject: [PATCH] now with working stft return trip --- fdNMF.cpp | 28 +++++++++++----------------- tests.scd | 14 +++++--------- 2 files changed, 16 insertions(+), 26 deletions(-) diff --git a/fdNMF.cpp b/fdNMF.cpp index 81ebe0c..5809815 100644 --- a/fdNMF.cpp +++ b/fdNMF.cpp @@ -33,14 +33,18 @@ void BufNMF(World *world, struct SndBuf *dstBuf, struct sc_msg_iter *msg) Print("dstChanCount = %d\n",dstChanCount); - if (dstChanCount < rank) { - Print("fdNMF is not happy because the destination buffer has a lower channel count than the number of ranks.\n"); - return; - } + // if (dstChanCount < rank) { + // Print("fdNMF is not happy because the destination buffer has a lower channel count than the number of ranks.\n"); + // return; + // } // make a vector of doubles for the samples std::vector tmp_vec(srcFrameCount); + //construct STFT processors + stft::STFT stft(1024, 2048, 256); + stft::ISTFT istft(1024, 2048, 256); + //for each channels for (int j=0;jdata[(i*srcChanCount)+j]; } - //dumb vector process with c++ syntax - for(double& value : tmp_vec){ - value *= -1; - } - - // //dumb vector process with c syntax - // for(int i=0;i out_vec = istft.process(spec); + stft::Spectrogram spec = stft.process(tmp_vec); + std::vector out_vec = istft.process(spec); //writes the output for (int i=0;idata[(i*srcChanCount)+j] = (float)tmp_vec[i]; + dstBuf->data[(i*srcChanCount)+j] = (float)out_vec[i]; } } } diff --git a/tests.scd b/tests.scd index fdfb487..a991072 100644 --- a/tests.scd +++ b/tests.scd @@ -1,17 +1,13 @@ s.quit s.boot // allocates a 16-sample buffer and fills it with ascending values -b = Buffer.alloc(s,16); -c = Buffer.alloc(s,16,5); -b.setn(0, Array.series(16,-8,1)); - -// read to check -b.getn(0,16, {|msg| msg.postln}); -c.getn(0,16, {|msg| msg.postln}); +b = Buffer.alloc(s,50000); +b.sine1([0,0,0,0,0,0,0,0,0,1],true,false); +b.plot; +c = Buffer.alloc(s,50000); // run the code b.fdNMF(c); // read to check -b.getn(0,16, {|msg| msg.postln}); -c.getn(0,16, {|msg| msg.postln}); +c.plot \ No newline at end of file