comparison audioio/AudioGenerator.cpp @ 460:49c89950b06d simple-fft-model

Rework audio file reader API to prefer using std containers
author Chris Cannam
date Mon, 15 Jun 2015 12:19:47 +0100
parents 3485d324c172
children 1020db1698c0
comparison
equal deleted inserted replaced
458:ea30a8c4cb93 460:49c89950b06d
437 } 437 }
438 438
439 sv_frame_t got = 0; 439 sv_frame_t got = 0;
440 440
441 if (startFrame >= fadeIn/2) { 441 if (startFrame >= fadeIn/2) {
442 got = dtvm->getMultiChannelData(0, modelChannels - 1, 442
443 startFrame - fadeIn/2, 443 auto data = dtvm->getMultiChannelData(0, modelChannels - 1,
444 frames + fadeOut/2 + fadeIn/2, 444 startFrame - fadeIn/2,
445 m_channelBuffer); 445 frames + fadeOut/2 + fadeIn/2);
446
447 for (int c = 0; c < modelChannels; ++c) {
448 copy(data[c].begin(), data[c].end(), m_channelBuffer[c]);
449 }
450
451 got = data.size();
452
446 } else { 453 } else {
447 sv_frame_t missing = fadeIn/2 - startFrame; 454 sv_frame_t missing = fadeIn/2 - startFrame;
448
449 for (int c = 0; c < modelChannels; ++c) {
450 m_channelBuffer[c] += missing;
451 }
452 455
453 if (missing > 0) { 456 if (missing > 0) {
454 cerr << "note: channelBufSiz = " << m_channelBufSiz 457 cerr << "note: channelBufSiz = " << m_channelBufSiz
455 << ", frames + fadeOut/2 = " << frames + fadeOut/2 458 << ", frames + fadeOut/2 = " << frames + fadeOut/2
456 << ", startFrame = " << startFrame 459 << ", startFrame = " << startFrame
457 << ", missing = " << missing << endl; 460 << ", missing = " << missing << endl;
458 } 461 }
459 462
460 got = dtvm->getMultiChannelData(0, modelChannels - 1, 463 auto data = dtvm->getMultiChannelData(0, modelChannels - 1,
461 startFrame, 464 startFrame,
462 frames + fadeOut/2, 465 frames + fadeOut/2);
463 m_channelBuffer);
464
465 for (int c = 0; c < modelChannels; ++c) { 466 for (int c = 0; c < modelChannels; ++c) {
466 m_channelBuffer[c] -= missing; 467 copy(data[c].begin(), data[c].end(), m_channelBuffer[c] + missing);
467 } 468 }
468 469
469 got += missing; 470 got = data.size() + missing;
470 } 471 }
471 472
472 for (int c = 0; c < m_targetChannelCount; ++c) { 473 for (int c = 0; c < m_targetChannelCount; ++c) {
473 474
474 int sourceChannel = (c % modelChannels); 475 int sourceChannel = (c % modelChannels);