diff --git a/fdNMF.cpp b/fdNMF.cpp index a8425b7..b5f03db 100644 --- a/fdNMF.cpp +++ b/fdNMF.cpp @@ -68,7 +68,9 @@ void BufNMF(World *world, struct SndBuf *dstBuf, struct sc_msg_iter *msg) } // make a vector of doubles for the samples - std::vector audio_in(srcFrameCount); + // padding by half a fft frame each sides + std::vector audio_in(srcFrameCount+fftSize); + long halfFftSize = fftSize / 2; //copied as is from max source (setting up the different variables and processes) STFT stft(windowSize, fftSize, hopSize); @@ -81,7 +83,7 @@ void BufNMF(World *world, struct SndBuf *dstBuf, struct sc_msg_iter *msg) for (int j=0;j<1;j++){ //copies and casts to double the source samples for (int i=0;idata[(i*srcChanCount)+j]; + audio_in[i+halfFftSize] = srcBuf->data[(i*srcChanCount)+j]; } Spectrogram spec = stft.process(audio_in); @@ -104,7 +106,7 @@ void BufNMF(World *world, struct SndBuf *dstBuf, struct sc_msg_iter *msg) //writes the output for (int k=0;kdata[(k*rank)+i] = (float)result[k]; + dstBuf->data[(k*rank)+i] = (float)result[k+halfFftSize]; } } } diff --git a/tests.scd b/tests.scd index 140948a..92d205d 100644 --- a/tests.scd +++ b/tests.scd @@ -19,4 +19,8 @@ b.fdNMF(e,5, 150, 2048,1024,256,{|x| "itworks".postln; x.postln;}) // read to check e.plot; -{Splay.ar(PlayBuf.ar(5,e.bufnum,doneAction:2))}.play \ No newline at end of file +{Splay.ar(PlayBuf.ar(5,e.bufnum,doneAction:2))}.play + +// nulltest + +{(PlayBuf.ar(5,e.bufnum,doneAction:2).sum)+(-1*PlayBuf.ar(1,b.bufnum,doneAction:2))}.play