42 SetEnableResidual(
true);
43 SetEnablePeakArray(
true);
44 SetEnableFundFreq(
true);
45 SetSpectralRange(22050);
47 SetFileName(
"nofile");
49 SetSamplingRate(44100);
56 mInputFundamental(
"Fundamental", this),
57 mInputSinSpectralPeaks(
"Sinusoidal Peaks", this),
58 mInputResSpectrum(
"Residual Spectrum", this)
61 ConnectAndPublishPorts();
67 mInputFundamental(
"Fundamental", this),
68 mInputSinSpectralPeaks(
"Sinusoidal Peaks", this),
69 mInputResSpectrum(
"Residual Spectrum", this)
73 ConnectAndPublishPorts();
83 void SDIFOut::ConnectAndPublishPorts()
145 if(mConfig.GetEnableFundFreq())
147 SDIF::Frame tmpSDIFFrame(
"1FQ0",frame.GetCenterTime(),0);
155 pMatrix->
SetValue(0,0,frame.GetFundamental().GetFreq());
156 tmpSDIFFrame.Add(pMatrix);
157 mpFile->Write(tmpSDIFFrame);
160 if(mConfig.GetEnableResidual())
162 SDIF::Frame tmpSDIFFrame(
"1STF",frame.GetCenterTime(),1);
168 pMatrix->
SetValue(0,0,mConfig.GetSamplingRate());
169 pMatrix->SetValue(0,1,mConfig.GetFrameSize());
170 pMatrix->SetValue(0,2,mConfig.GetSpectrumSize());
171 tmpSDIFFrame.Add(pMatrix);
180 frame.GetResidualSpec().GetType(sflags);
184 frame.GetResidualSpec().SetTypeSynchronize(sflags);
187 frame.GetResidualSpec().ToLinear();
189 Array<Complex>& complexBuffer=frame.GetResidualSpec().GetComplexArray();
190 for (
int r=0;r<pMatrix->Rows();r++)
192 pMatrix->SetValue(r,0,complexBuffer[r].Real());
193 pMatrix->SetValue(r,1,complexBuffer[r].Imag());
195 tmpSDIFFrame.Add(pMatrix);
196 mpFile->Write(tmpSDIFFrame);
199 if(mConfig.GetEnablePeakArray())
205 SDIF::Frame tmpSDIFFrame(
"1TRC",frame.GetCenterTime(),2);
213 DataArray& pkfreqBuffer=tmpPeakArray.GetFreqBuffer();
214 DataArray& pkmagBuffer=tmpPeakArray.GetMagBuffer();
215 DataArray& pkPhaseBuffer=tmpPeakArray.GetPhaseBuffer();
218 IndexArray& pkIndexArray=tmpPeakArray.GetIndexArray();
220 for (
int r=0;r<nElems;r++)
223 pMatrix->
SetValue(r,0,pkIndexArray[r]+1);
225 pMatrix->
SetValue(r,1,pkfreqBuffer[r]);
226 pMatrix->
SetValue(r,2,pkmagBuffer[r]);
227 pMatrix->
SetValue(r,3,pkPhaseBuffer[r]);
232 tmpSDIFFrame.Add(pMatrix);
233 mpFile->Write(tmpSDIFFrame);