comparison data/fft/FFTDataServer.cpp @ 272:8bbc9e336475

* avoid trying to calculate fft from incomplete decoded audio file in spectrum
author Chris Cannam
date Mon, 02 Jul 2007 14:57:01 +0000
parents 260032c26c4f
children f1f47660483d
comparison
equal deleted inserted replaced
271:822bd7fd526c 272:8bbc9e336475
501 { 501 {
502 #ifdef DEBUG_FFT_SERVER 502 #ifdef DEBUG_FFT_SERVER
503 std::cerr << "FFTDataServer(" << this << " [" << (void *)QThread::currentThreadId() << "])::FFTDataServer" << std::endl; 503 std::cerr << "FFTDataServer(" << this << " [" << (void *)QThread::currentThreadId() << "])::FFTDataServer" << std::endl;
504 #endif 504 #endif
505 505
506 //!!! end is not correct until model finished reading -- what to do???
507
506 size_t start = m_model->getStartFrame(); 508 size_t start = m_model->getStartFrame();
507 size_t end = m_model->getEndFrame(); 509 size_t end = m_model->getEndFrame();
508 510
509 m_width = (end - start) / m_windowIncrement + 1; 511 m_width = (end - start) / m_windowIncrement + 1;
510 m_height = m_fftSize / 2 + 1; // DC == 0, Nyquist == fftsize/2 512 m_height = m_fftSize / 2 + 1; // DC == 0, Nyquist == fftsize/2
988 void 990 void
989 FFTDataServer::fillColumn(size_t x) 991 FFTDataServer::fillColumn(size_t x)
990 { 992 {
991 Profiler profiler("FFTDataServer::fillColumn", false); 993 Profiler profiler("FFTDataServer::fillColumn", false);
992 994
995 if (!m_model->isReady()) {
996 std::cerr << "WARNING: FFTDataServer::fillColumn("
997 << x << "): model not yet ready" << std::endl;
998 return;
999 }
1000
993 if (!m_fftInput) { 1001 if (!m_fftInput) {
994 std::cerr << "WARNING: FFTDataServer::fillColumn(" << x << "): " 1002 std::cerr << "WARNING: FFTDataServer::fillColumn(" << x << "): "
995 << "input has already been completed and discarded?" 1003 << "input has already been completed and discarded?"
996 << std::endl; 1004 << std::endl;
997 return; 1005 return;
1140 FFTDataServer::FillThread::run() 1148 FFTDataServer::FillThread::run()
1141 { 1149 {
1142 m_extent = 0; 1150 m_extent = 0;
1143 m_completion = 0; 1151 m_completion = 0;
1144 1152
1153 while (!m_server.m_model->isReady() && !m_server.m_exiting) {
1154 sleep(1);
1155 }
1156 if (m_server.m_exiting) return;
1157
1145 size_t start = m_server.m_model->getStartFrame(); 1158 size_t start = m_server.m_model->getStartFrame();
1146 size_t end = m_server.m_model->getEndFrame(); 1159 size_t end = m_server.m_model->getEndFrame();
1147 size_t remainingEnd = end; 1160 size_t remainingEnd = end;
1148 1161
1149 int counter = 0; 1162 int counter = 0;