TEST_FIXTURE(VibratoData, VibVaryingBlocksize) { m_pVibrato->setParam(CVibrato::kParamModFreqInHz, 2); m_pVibrato->setParam(CVibrato::kParamModWidthInS, .1F); process(); m_pVibrato->resetInstance(); m_pVibrato->initInstance(m_fMaxModWidth,m_fSampleRate,m_iNumChannels); m_pVibrato->setParam(CVibrato::kParamModFreqInHz, 2); m_pVibrato->setParam(CVibrato::kParamModWidthInS, .1F); { int iNumFramesRemaining = m_kiDataLength; while (iNumFramesRemaining > 0) { int iNumFrames = std::min(iNumFramesRemaining, rand()/RAND_MAX*17000); for (int c = 0; c < m_iNumChannels; c++) { m_ppfInputTmp[c] = &m_ppfInputData[c][m_kiDataLength - iNumFramesRemaining]; } m_pVibrato->process(m_ppfInputTmp, m_ppfInputTmp, iNumFrames); iNumFramesRemaining -= iNumFrames; } } for (int c = 0; c < m_iNumChannels; c++) CHECK_ARRAY_CLOSE(m_ppfInputData[c], m_ppfOutputData[c], m_kiDataLength, 1e-3); }
TEST_FIXTURE(CombFilterData, Inplace) { //Fir m_pCombFilter->init(CCombFilterIf::kCombFIR, m_fMaxDelayLength, m_fSampleRate, m_iNumChannels); for (int c = 0; c < m_iNumChannels; c++) CSynthesis::generateSine (m_ppfInputData[c], 387.F, m_fSampleRate, m_iDataLength, .8F, static_cast<float>(c*M_PI_2)); m_pCombFilter->setParam(CCombFilterIf::kParamGain, m_fGain); m_pCombFilter->setParam(CCombFilterIf::kParamDelay, m_fDelay); TestProcess(); m_pCombFilter->reset(); m_pCombFilter->init(CCombFilterIf::kCombFIR, m_fMaxDelayLength, m_fSampleRate, m_iNumChannels); m_pCombFilter->setParam(CCombFilterIf::kParamGain, m_fGain); m_pCombFilter->setParam(CCombFilterIf::kParamDelay, m_fDelay); TestProcessInplace(); for (int c = 0; c < m_iNumChannels; c++) CHECK_ARRAY_CLOSE(m_ppfInputData[c], m_ppfOutputData[c], m_iDataLength, 1e-3); m_pCombFilter->reset(); // Iir m_pCombFilter->init(CCombFilterIf::kCombIIR, m_fMaxDelayLength, m_fSampleRate, m_iNumChannels); for (int c = 0; c < m_iNumChannels; c++) CSynthesis::generateSine (m_ppfInputData[c], 387.F, m_fSampleRate, m_iDataLength, .8F, static_cast<float>(c*M_PI_2)); m_pCombFilter->setParam(CCombFilterIf::kParamGain, m_fGain); m_pCombFilter->setParam(CCombFilterIf::kParamDelay, m_fDelay); TestProcess(); m_pCombFilter->reset(); m_pCombFilter->init(CCombFilterIf::kCombIIR, m_fMaxDelayLength, m_fSampleRate, m_iNumChannels); m_pCombFilter->setParam(CCombFilterIf::kParamGain, m_fGain); m_pCombFilter->setParam(CCombFilterIf::kParamDelay, m_fDelay); TestProcessInplace(); for (int c = 0; c < m_iNumChannels; c++) CHECK_ARRAY_CLOSE(m_ppfInputData[c], m_ppfOutputData[c], m_iDataLength, 1e-3); }
TEST_FIXTURE(FftData, Inplace) { CSignalGen::generateNoise(m_pfTime, m_iFftLength, 1.F); // compute fft inplace and compare m_pCFftInstance->doFft(m_pfFreq, m_pfTime); CUtil::copyBuff(m_pfTmp, m_pfTime, m_iFftLength); m_pCFftInstance->doFft(m_pfTmp, m_pfTmp); CHECK_ARRAY_CLOSE(m_pfFreq, m_pfTmp, m_iFftLength, 1e-3); // get magnitude in-place and compare m_pCFftInstance->getMagnitude(m_pfReal, m_pfFreq); CUtil::copyBuff(m_pfTmp, reinterpret_cast<float*>(m_pfFreq), m_iFftLength); m_pCFftInstance->getMagnitude(m_pfTmp, m_pfTmp); CHECK_ARRAY_CLOSE(m_pfReal, m_pfTmp, m_pCFftInstance->getLength(CFft::kLengthMagnitude), 1e-3); // get phase in-place and compare m_pCFftInstance->getPhase(m_pfReal, m_pfFreq); CUtil::copyBuff(m_pfTmp, reinterpret_cast<float*>(m_pfFreq), m_iFftLength); m_pCFftInstance->getPhase(m_pfTmp, m_pfTmp); CHECK_ARRAY_CLOSE(m_pfReal, m_pfTmp, m_pCFftInstance->getLength(CFft::kLengthPhase), 1e-3); }
TEST_FIXTURE(VibratoData, VibZeroInput) { m_pVibrato->setParam(CVibrato::kParamModFreqInHz, 20); m_pVibrato->setParam(CVibrato::kParamModWidthInS, 0); for (int c = 0; c < m_iNumChannels; c++) CVector::setZero(m_ppfInputData[c], m_kiDataLength); process(); int iDelay = CUtil::float2int<int>(m_fMaxModWidth*m_fSampleRate+1); for (int c = 0; c < m_iNumChannels; c++) CHECK_ARRAY_CLOSE(m_ppfInputData[c], &m_ppfOutputData[c][iDelay], m_kiDataLength-iDelay, 1e-3F); }
TEST_FIXTURE(VibratoData, VibDc) { m_pVibrato->setParam(CVibrato::kParamModFreqInHz, 2); m_pVibrato->setParam(CVibrato::kParamModWidthInS, .1F); for (int c = 0; c < m_iNumChannels; c++) { CSynthesis::generateDc(m_ppfInputData[c], m_kiDataLength, (c+1)*.1F); } process(); int iDelay = CUtil::float2int<int>(m_fMaxModWidth*m_fSampleRate+1); for (int c = 0; c < m_iNumChannels; c++) CHECK_ARRAY_CLOSE(m_ppfInputData[c], &m_ppfOutputData[c][iDelay], m_kiDataLength-iDelay, 1e-3F); }
TEST_FIXTURE(PPM, DelayedImpulse) { int count=0; resetValues(); std::string line; for (int c = 0; c < m_iNumChannels; c++) { CVector::setZero(m_ppfInputData[c], m_iDataLength); m_ppfInputData[c][f_iBlockLength*2]=1; } AlphaATChange(0.01); AlphaRTChange(1.5); process(); std::ifstream myfile; myfile.open(Address+"DelayedImpulse.txt"); for (int i = 0; i<m_iNumChannels; i++) { if (myfile.is_open()) { while (getline(myfile,line) ) { m_ppfOutputCheck[i][count]=std::stof(line,NULL); //std::cout <<m_ppfOutputCheck[i][count] << " " <<m_ppfOutputData[i][count] << " " <<m_ppfInputData[i][count]<<std::endl; count++; } } } myfile.close(); for (int c = 0; c < m_iNumChannels; c++) CHECK_ARRAY_CLOSE(m_ppfOutputCheck[c], m_ppfOutputData[c], 60, 1e-3F); }
TEST_FIXTURE(PPM, AlphaATChange) { resetValues(); int count=0; std::string line; for (int c = 0; c < m_iNumChannels; c++) { CSynthesis::generateDc(m_ppfInputData[c], m_iDataLength); for(int l=0;l<m_iDataLength;l++) { if(l > 50*f_iBlockLength && l< m_iDataLength) m_ppfInputData[c][l]=0; } } AlphaATChange(0.5); process(); std::ifstream myfile; myfile.open(Address+"AlphaATVPPM.txt"); for (int i = 0; i<m_iNumChannels; i++) { if (myfile.is_open()) { while (getline(myfile,line) ) { m_ppfOutputCheck[i][count]=std::stof(line,NULL); // std::cout <<m_ppfOutputCheck[i][count] << " " <<m_ppfOutputData[i][count] << " " <<m_ppfInputData[i][count]<<std::endl; count++; } } } myfile.close(); for (int c = 0; c < m_iNumChannels; c++) CHECK_ARRAY_CLOSE(m_ppfOutputCheck[c], m_ppfOutputData[c], 60, 1e-3F); }
TEST_FIXTURE(FftData, SimpleCos) { CSignalGen::generateSine(m_pfTime, 2.F, 1.F*m_iFftLength, m_iFftLength, 1.F, static_cast<float>(M_PI_2)); m_pCFftInstance->doFft(m_pfFreq, m_pfTime); m_pCFftInstance->getPhase (m_pfTmp, m_pfFreq); CHECK_CLOSE(0, m_pfTmp[2], 1e-3); m_pCFftInstance->getMagnitude (m_pfTmp, m_pfFreq); for (int i=0; i < m_iFftLength/2+1; i++) { if (i!=2) { CHECK_CLOSE(0, m_pfTmp[i], 1e-3); } else { CHECK_CLOSE(.5, m_pfTmp[i], 1e-3); } } m_pCFftInstance->splitRealImag (m_pfReal, m_pfImag, m_pfFreq); for (int i=0; i < m_iFftLength/2; i++) CHECK_CLOSE(0, m_pfImag[i], 1e-3); for (int i=0; i < m_iFftLength/2+1; i++) { if (i!=2) { CHECK_CLOSE(0, m_pfReal[i], 1e-3); } else { CHECK_CLOSE(.5, m_pfReal[i], 1e-3); } } m_pCFftInstance->mergeRealImag (m_pfFreq, m_pfReal, m_pfImag); m_pCFftInstance->doInvFft(m_pfTmp, m_pfFreq); CHECK_ARRAY_CLOSE(m_pfTime, m_pfTmp, m_iFftLength, 1e-3); }
TEST_FIXTURE(PPM, SamplingFreqChange) { int count=0; resetValues(); std::string line; for (int c = 0; c < m_iNumChannels; c++) CSynthesis::generateSine(m_ppfInputData[c], 330, m_fSamplingFreq/2, m_iDataLength); C_PPm->initPeakMeter(m_fSamplingFreq/2, m_iNumChannels); AlphaATChange(0.01); AlphaRTChange(1.5); process(); std::ifstream myfile; myfile.open(Address+"AlphaSampChange.txt"); for (int i = 0; i<m_iNumChannels; i++) { if (myfile.is_open()) { while (getline(myfile,line) ) { m_ppfOutputCheck[i][count]=std::stof(line,NULL); // std::cout <<m_ppfOutputCheck[i][count] << " " <<m_ppfOutputData[i][count] << " " <<m_ppfInputData[i][count]<<std::endl; count++; } } } myfile.close(); for (int c = 0; c < m_iNumChannels; c++) CHECK_ARRAY_CLOSE(m_ppfOutputCheck[c], m_ppfOutputData[c], 60, 1e-3F); }
TEST_FIXTURE(PPM, DCInput) { resetValues(); int count=0; std::string line; for (int c = 0; c < m_iNumChannels; c++) { CSynthesis::generateDc(m_ppfInputData[c], m_iDataLength); CVector::setZero(m_ppfOutputCheck[c], 60); } process(); std::ifstream myfile; myfile.open(Address+"DCVPPM.txt"); for (int i = 0; i<m_iNumChannels; i++) { if (myfile.is_open()) { count=0; while ( getline (myfile,line) ) { m_ppfOutputCheck[i][count]=std::stof(line,NULL); //std::cout <<m_ppfOutputCheck[i][count]<<" " <<m_ppfOutputData[i][count] <<std::endl; count++; } } } myfile.close(); for (int c = 0; c < m_iNumChannels; c++) { CHECK_ARRAY_CLOSE(m_ppfOutputCheck[c], m_ppfOutputData[c], 60, 1e-3F); } }
TEST_FIXTURE(CombFilterData, VaryingBlocksize) { //Fir m_pCombFilter->init(CCombFilterIf::kCombFIR, m_fMaxDelayLength, m_fSampleRate, m_iNumChannels); for (int c = 0; c < m_iNumChannels; c++) CSynthesis::generateSine (m_ppfInputData[c], 387.F, m_fSampleRate, m_iDataLength, .8F, static_cast<float>(c*M_PI_2)); m_pCombFilter->setParam(CCombFilterIf::kParamGain, m_fGain); m_pCombFilter->setParam(CCombFilterIf::kParamDelay, m_fDelay); TestProcess(); m_pCombFilter->reset(); m_pCombFilter->init(CCombFilterIf::kCombFIR, m_fMaxDelayLength, m_fSampleRate, m_iNumChannels); m_pCombFilter->setParam(CCombFilterIf::kParamGain, m_fGain); m_pCombFilter->setParam(CCombFilterIf::kParamDelay, m_fDelay); { int iNumFramesRemaining = m_iDataLength; while (iNumFramesRemaining > 0) { int iNumFrames = std::min(static_cast<float>(iNumFramesRemaining), static_cast<float>(rand())/RAND_MAX*17000); for (int c = 0; c < m_iNumChannels; c++) { m_ppfInputTmp[c] = &m_ppfInputData[c][m_iDataLength - iNumFramesRemaining]; } m_pCombFilter->process(m_ppfInputTmp, m_ppfInputTmp, iNumFrames); iNumFramesRemaining -= iNumFrames; } } for (int c = 0; c < m_iNumChannels; c++) CHECK_ARRAY_CLOSE(m_ppfInputData[c], m_ppfOutputData[c], m_iDataLength, 1e-3); //Iir m_pCombFilter->init(CCombFilterIf::kCombIIR, m_fMaxDelayLength, m_fSampleRate, m_iNumChannels); for (int c = 0; c < m_iNumChannels; c++) CSynthesis::generateSine (m_ppfInputData[c], 387.F, m_fSampleRate, m_iDataLength, .8F, static_cast<float>(c*M_PI_2)); m_pCombFilter->setParam(CCombFilterIf::kParamGain, m_fGain); m_pCombFilter->setParam(CCombFilterIf::kParamDelay, m_fDelay); TestProcess(); m_pCombFilter->reset(); m_pCombFilter->init(CCombFilterIf::kCombIIR, m_fMaxDelayLength, m_fSampleRate, m_iNumChannels); m_pCombFilter->setParam(CCombFilterIf::kParamGain, m_fGain); m_pCombFilter->setParam(CCombFilterIf::kParamDelay, m_fDelay); { int iNumFramesRemaining = m_iDataLength; while (iNumFramesRemaining > 0) { int iNumFrames = std::min(static_cast<float>(iNumFramesRemaining), static_cast<float>(rand())/RAND_MAX*17000); for (int c = 0; c < m_iNumChannels; c++) { m_ppfInputTmp[c] = &m_ppfInputData[c][m_iDataLength - iNumFramesRemaining]; } m_pCombFilter->process(m_ppfInputTmp, m_ppfInputTmp, iNumFrames); iNumFramesRemaining -= iNumFrames; } } for (int c = 0; c < m_iNumChannels; c++) CHECK_ARRAY_CLOSE(m_ppfInputData[c], m_ppfOutputData[c], m_iDataLength, 1e-3); }