Mercurial > hg > sonic-visualiser
comparison audioio/PhaseVocoderTimeStretcher.cpp @ 18:c1aee08c60b1
* avoid using n2 in processBlock
author | Chris Cannam |
---|---|
date | Thu, 14 Sep 2006 09:24:57 +0000 |
parents | 67d54627efd3 |
children | f17798a555df |
comparison
equal
deleted
inserted
replaced
17:67d54627efd3 | 18:c1aee08c60b1 |
---|---|
230 assert(got == m_wlen); | 230 assert(got == m_wlen); |
231 | 231 |
232 bool thisChannelPercussive = | 232 bool thisChannelPercussive = |
233 processBlock(c, m_dbuf, m_mashbuf[c], | 233 processBlock(c, m_dbuf, m_mashbuf[c], |
234 c == 0 ? m_modulationbuf : 0, | 234 c == 0 ? m_modulationbuf : 0, |
235 m_prevPercussive); | 235 m_prevPercussive ? m_n1 : m_n2); |
236 | 236 |
237 if (thisChannelPercussive && c == 0) { | 237 if (thisChannelPercussive && c == 0) { |
238 isPercussive = true; | 238 isPercussive = true; |
239 } | 239 } |
240 | 240 |
320 | 320 |
321 bool | 321 bool |
322 PhaseVocoderTimeStretcher::processBlock(size_t c, | 322 PhaseVocoderTimeStretcher::processBlock(size_t c, |
323 float *buf, float *out, | 323 float *buf, float *out, |
324 float *modulation, | 324 float *modulation, |
325 bool lastPercussive) | 325 size_t lastStep) |
326 { | 326 { |
327 size_t i; | 327 size_t i; |
328 bool isPercussive = false; | 328 bool isPercussive = false; |
329 | 329 |
330 // buf contains m_wlen samples; out contains enough space for | 330 // buf contains m_wlen samples; out contains enough space for |
373 } | 373 } |
374 | 374 |
375 m_prevPercussiveCount[c] = count; | 375 m_prevPercussiveCount[c] = count; |
376 } | 376 } |
377 | 377 |
378 size_t n2 = m_n2; | |
379 if (lastPercussive) n2 = m_n1; | |
380 | |
381 for (i = 0; i < m_wlen; ++i) { | 378 for (i = 0; i < m_wlen; ++i) { |
382 | 379 |
383 float mag; | 380 float mag; |
384 | 381 |
385 if (m_sharpen && c == 0) { | 382 if (m_sharpen && c == 0) { |
397 | 394 |
398 float phaseError = princargf(phase - expectedPhase); | 395 float phaseError = princargf(phase - expectedPhase); |
399 | 396 |
400 float phaseIncrement = (omega + phaseError) / m_n1; | 397 float phaseIncrement = (omega + phaseError) / m_n1; |
401 | 398 |
402 float adjustedPhase = m_prevAdjustedPhase[c][i] + n2 * phaseIncrement; | 399 float adjustedPhase = m_prevAdjustedPhase[c][i] + |
400 lastStep * phaseIncrement; | |
403 | 401 |
404 if (isPercussive) adjustedPhase = phase; | 402 if (isPercussive) adjustedPhase = phase; |
405 | 403 |
406 float real = mag * cosf(adjustedPhase); | 404 float real = mag * cosf(adjustedPhase); |
407 float imag = mag * sinf(adjustedPhase); | 405 float imag = mag * sinf(adjustedPhase); |