comparison audioio/PhaseVocoderTimeStretcher.cpp @ 26:d88d117e0c34

* Add mono timestretch toggle button; some more work on getting blocksize etc parameters through to plugins
author Chris Cannam
date Mon, 18 Sep 2006 16:43:17 +0000
parents e74f508db18c
children 37af203dbd15
comparison
equal deleted inserted replaced
25:e74f508db18c 26:d88d117e0c34
37 m_n2sum(0), 37 m_n2sum(0),
38 m_mutex(new QMutex()) 38 m_mutex(new QMutex())
39 { 39 {
40 initialise(); 40 initialise();
41 41
42 std::cerr << "PhaseVocoderTimeStretcher: channels = " << m_channels
43 << ", ratio = " << m_ratio
44 << ", n1 = " << m_n1 << ", n2 = " << m_n2 << ", wlen = "
45 << m_wlen << ", max = " << maxProcessInputBlockSize
46 << ", outbuflen = " << m_outbuf[0]->getSize() << std::endl;
47 } 42 }
48 43
49 PhaseVocoderTimeStretcher::~PhaseVocoderTimeStretcher() 44 PhaseVocoderTimeStretcher::~PhaseVocoderTimeStretcher()
50 { 45 {
51 std::cerr << "PhaseVocoderTimeStretcher::~PhaseVocoderTimeStretcher" << std::endl; 46 std::cerr << "PhaseVocoderTimeStretcher::~PhaseVocoderTimeStretcher" << std::endl;
164 } 159 }
165 m_n1 = m_n2 / m_ratio; 160 m_n1 = m_n2 / m_ratio;
166 } 161 }
167 162
168 m_transientThreshold = m_wlen / 4.5; 163 m_transientThreshold = m_wlen / 4.5;
164
165 m_totalCount = 0;
166 m_transientCount = 0;
167 m_n2sum = 0;
168
169
170 std::cerr << "PhaseVocoderTimeStretcher: channels = " << m_channels
171 << ", ratio = " << m_ratio
172 << ", n1 = " << m_n1 << ", n2 = " << m_n2 << ", wlen = "
173 << m_wlen << ", max = " << m_maxProcessInputBlockSize << std::endl;
174 // << ", outbuflen = " << m_outbuf[0]->getSize() << std::endl;
169 } 175 }
170 176
171 void 177 void
172 PhaseVocoderTimeStretcher::cleanup() 178 PhaseVocoderTimeStretcher::cleanup()
173 { 179 {
514 m_prevTransientMag[i] = sqrmag; 520 m_prevTransientMag[i] = sqrmag;
515 } 521 }
516 522
517 bool isTransient = false; 523 bool isTransient = false;
518 524
519 if (count > m_transientThreshold && 525 // if (count > m_transientThreshold &&
520 count > m_prevTransientScore * 1.2) { 526 // count > m_prevTransientScore * 1.2) {
527 if (count > m_prevTransientScore &&
528 count > m_transientThreshold &&
529 count - m_prevTransientScore > m_wlen / 20) {
521 isTransient = true; 530 isTransient = true;
522 std::cerr << "isTransient (count = " << count << ", prev = " << m_prevTransientScore << ")" << std::endl; 531
532
533 std::cerr << "isTransient (count = " << count << ", prev = " << m_prevTransientScore << ", diff = " << count - m_prevTransientScore << ", ratio = " << (m_totalCount > 0 ? (float (m_n2sum) / float(m_totalCount * m_n1)) : 1.f) << ", ideal = " << m_ratio << ")" << std::endl;
534 // } else {
535 // std::cerr << " !transient (count = " << count << ", prev = " << m_prevTransientScore << ", diff = " << count - m_prevTransientScore << ")" << std::endl;
523 } 536 }
524 537
525 m_prevTransientScore = count; 538 m_prevTransientScore = count;
526 539
527 return isTransient; 540 return isTransient;