bool SpectralAnalysisTest::performTest(int nSamples, int windowSize) { cout << "Testing ceilPowerOfTwo:" << endl; unsigned int r1 = AudioData::ceilPowerOfTwo(257); unsigned int r2 = AudioData::ceilPowerOfTwo(256); cout << "ceilPowerOfTwo(257) = " << r1 << endl; cout << "ceilPowerOfTwo(256) = " << r2 << endl; if (r1 != 512 || r2 != 256) return false; const double overlap = 0.5; double* data = new double[nSamples]; const double pi = 4.0 * atan(1.0); srand((unsigned int) time(0)); cout << "Original data:" << endl; for (int i = 0; i < nSamples; i++) { data[i] = sin(pi * i / (nSamples - 1)); cout << data[i] << " "; } cout << endl << endl; AudioData audioData(vector<double*>(1, data), nSamples, 1000); // Actually, the Testsuite is single-threaded, but to be 100% sure we use // a mutex here. // We don't use the BasicApplication method since this is a component test // for AudioData. fftwMutex.lock(); pair<Matrix*, Matrix*> spectrogram = audioData.computeSpectrogram(SqHannFunction, windowSize, overlap, 0); auto_ptr<Matrix> pAmplitudeMatrix(spectrogram.first); auto_ptr<Matrix> pPhaseMatrix(spectrogram.second); cout << "Amplitude spectrogram:" << endl; cout << *pAmplitudeMatrix << endl; cout << "Phase spectrogram:" << endl; cout << *pPhaseMatrix << endl; auto_ptr<AudioData> pAudioData2(AudioData::fromSpectrogram(*pAmplitudeMatrix, *pPhaseMatrix, SqHannFunction, windowSize, overlap, 1000)); fftwMutex.unlock(); cout << "Result data:" << endl; const double* data2 = pAudioData2->getChannel(0); for (unsigned int i = 0; i < pAudioData2->nrOfSamples(); i++) { cout << data2[i] << " "; } cout << endl; return true; }
void CScanTool2Dlg::ReleaseData() { g_lfmExamList.lock(); EXAM_LIST::iterator itExam = g_lExamList.begin(); for (; itExam != g_lExamList.end();) { pEXAMINFO pExam = *itExam; itExam = g_lExamList.erase(itExam); SAFE_RELEASE(pExam); } g_lfmExamList.unlock(); SAFE_RELEASE(_pModel_); }
void UnlockStartupStore() { CritSec_StartupStore.unlock(); }