comparison src/vamp-hostsdk/PluginBufferingAdapter.cpp @ 421:35fa4733bc5d

Fix compiler warnings, and fix potential mangling of utf8 when downcasing (this is still a nasty and incomplete way to do it though)
author Chris Cannam
date Thu, 14 Apr 2016 11:49:12 +0100
parents 1522e2f6d700
children
comparison
equal deleted inserted replaced
420:99868cd95acb 421:35fa4733bc5d
479 // << ", blockSize " << m_inputBlockSize << " -> " << m_blockSize << std::endl; 479 // << ", blockSize " << m_inputBlockSize << " -> " << m_blockSize << std::endl;
480 480
481 m_buffers = new float *[m_channels]; 481 m_buffers = new float *[m_channels];
482 482
483 for (size_t i = 0; i < m_channels; ++i) { 483 for (size_t i = 0; i < m_channels; ++i) {
484 m_queue.push_back(new RingBuffer(m_blockSize + m_inputBlockSize)); 484 m_queue.push_back(new RingBuffer(int(m_blockSize + m_inputBlockSize)));
485 m_buffers[i] = new float[m_blockSize]; 485 m_buffers[i] = new float[m_blockSize];
486 } 486 }
487 487
488 bool success = m_plugin->initialise(m_channels, m_stepSize, m_blockSize); 488 bool success = m_plugin->initialise(m_channels, m_stepSize, m_blockSize);
489 489
508 m_outputs = m_plugin->getOutputDescriptors(); 508 m_outputs = m_plugin->getOutputDescriptors();
509 } 509 }
510 510
511 PluginBufferingAdapter::OutputList outs = m_outputs; 511 PluginBufferingAdapter::OutputList outs = m_outputs;
512 512
513 for (size_t i = 0; i < outs.size(); ++i) { 513 for (int i = 0; i < int(outs.size()); ++i) {
514 514
515 switch (outs[i].sampleType) { 515 switch (outs[i].sampleType) {
516 516
517 case OutputDescriptor::OneSamplePerStep: 517 case OutputDescriptor::OneSamplePerStep:
518 outs[i].sampleType = OutputDescriptor::FixedSampleRate; 518 outs[i].sampleType = OutputDescriptor::FixedSampleRate;
519 outs[i].sampleRate = m_inputSampleRate / m_stepSize; 519 outs[i].sampleRate = m_inputSampleRate / float(m_stepSize);
520 m_rewriteOutputTimes[i] = true; 520 m_rewriteOutputTimes[i] = true;
521 break; 521 break;
522 522
523 case OutputDescriptor::FixedSampleRate: 523 case OutputDescriptor::FixedSampleRate:
524 if (outs[i].sampleRate == 0.f) { 524 if (outs[i].sampleRate == 0.f) {
525 outs[i].sampleRate = m_inputSampleRate / m_stepSize; 525 outs[i].sampleRate = m_inputSampleRate / float(m_stepSize);
526 } 526 }
527 // We actually only need to rewrite output times for 527 // We actually only need to rewrite output times for
528 // features that don't have timestamps already, but we 528 // features that don't have timestamps already, but we
529 // can't tell from here whether our features will have 529 // can't tell from here whether our features will have
530 // timestamps or not 530 // timestamps or not
593 } 593 }
594 594
595 // queue the new input 595 // queue the new input
596 596
597 for (size_t i = 0; i < m_channels; ++i) { 597 for (size_t i = 0; i < m_channels; ++i) {
598 int written = m_queue[i]->write(inputBuffers[i], m_inputBlockSize); 598 int written = m_queue[i]->write(inputBuffers[i], int(m_inputBlockSize));
599 if (written < int(m_inputBlockSize) && i == 0) { 599 if (written < int(m_inputBlockSize) && i == 0) {
600 std::cerr << "WARNING: PluginBufferingAdapter::Impl::process: " 600 std::cerr << "WARNING: PluginBufferingAdapter::Impl::process: "
601 << "Buffer overflow: wrote " << written 601 << "Buffer overflow: wrote " << written
602 << " of " << m_inputBlockSize 602 << " of " << m_inputBlockSize
603 << " input samples (for plugin step size " 603 << " input samples (for plugin step size "
621 { 621 {
622 // cerr << "adjustFixedRateFeatureTime: from " << feature.timestamp; 622 // cerr << "adjustFixedRateFeatureTime: from " << feature.timestamp;
623 623
624 double rate = m_outputs[outputNo].sampleRate; 624 double rate = m_outputs[outputNo].sampleRate;
625 if (rate == 0.0) { 625 if (rate == 0.0) {
626 rate = m_inputSampleRate / m_stepSize; 626 rate = m_inputSampleRate / float(m_stepSize);
627 } 627 }
628 628
629 if (feature.hasTimestamp) { 629 if (feature.hasTimestamp) {
630 double secs = feature.timestamp.sec; 630 double secs = feature.timestamp.sec;
631 secs += feature.timestamp.nsec / 1e9; 631 secs += feature.timestamp.nsec / 1e9;
654 } 654 }
655 655
656 // pad any last samples remaining and process 656 // pad any last samples remaining and process
657 if (m_queue[0]->getReadSpace() > 0) { 657 if (m_queue[0]->getReadSpace() > 0) {
658 for (size_t i = 0; i < m_channels; ++i) { 658 for (size_t i = 0; i < m_channels; ++i) {
659 m_queue[i]->zero(m_blockSize - m_queue[i]->getReadSpace()); 659 m_queue[i]->zero(int(m_blockSize) - m_queue[i]->getReadSpace());
660 } 660 }
661 processBlock(allFeatureSets); 661 processBlock(allFeatureSets);
662 } 662 }
663 663
664 // get remaining features 664 // get remaining features
687 687
688 void 688 void
689 PluginBufferingAdapter::Impl::processBlock(FeatureSet& allFeatureSets) 689 PluginBufferingAdapter::Impl::processBlock(FeatureSet& allFeatureSets)
690 { 690 {
691 for (size_t i = 0; i < m_channels; ++i) { 691 for (size_t i = 0; i < m_channels; ++i) {
692 m_queue[i]->peek(m_buffers[i], m_blockSize); 692 m_queue[i]->peek(m_buffers[i], int(m_blockSize));
693 } 693 }
694 694
695 long frame = m_frame; 695 long frame = m_frame;
696 RealTime timestamp = RealTime::frame2RealTime 696 RealTime timestamp = RealTime::frame2RealTime
697 (frame, int(m_inputSampleRate + 0.5)); 697 (frame, int(m_inputSampleRate + 0.5));
747 } 747 }
748 748
749 // step forward 749 // step forward
750 750
751 for (size_t i = 0; i < m_channels; ++i) { 751 for (size_t i = 0; i < m_channels; ++i) {
752 m_queue[i]->skip(m_stepSize); 752 m_queue[i]->skip(int(m_stepSize));
753 } 753 }
754 754
755 // increment internal frame counter each time we step forward 755 // increment internal frame counter each time we step forward
756 m_frame += m_stepSize; 756 m_frame += m_stepSize;
757 } 757 }