comparison audioio/AudioCallbackPlaySource.cpp @ 22:80126455d169

* add samplerate parameter to timestretcher (not properly used yet), and update credits
author Chris Cannam
date Fri, 15 Sep 2006 13:35:37 +0000
parents 3715efc38f95
children e74f508db18c
comparison
equal deleted inserted replaced
21:7da85e0b85e9 22:80126455d169
601 return; 601 return;
602 } 602 }
603 603
604 if (factor != 1) { 604 if (factor != 1) {
605 PhaseVocoderTimeStretcher *newStretcher = new PhaseVocoderTimeStretcher 605 PhaseVocoderTimeStretcher *newStretcher = new PhaseVocoderTimeStretcher
606 (getTargetChannelCount(), 606 (getTargetSampleRate(),
607 getTargetChannelCount(),
607 factor, 608 factor,
608 sharpen, 609 sharpen,
609 lrintf(getTargetBlockSize() / factor)); 610 lrintf(getTargetBlockSize() / factor));
610 m_timeStretcher = newStretcher; 611 m_timeStretcher = newStretcher;
611 } else { 612 } else {
710 } 711 }
711 } 712 }
712 713
713 ts->getOutput(buffer, count); 714 ts->getOutput(buffer, count);
714 715
715
716 /*!!!
717 for (size_t ch = 0; ch < getTargetChannelCount(); ++ch) {
718
719 RingBuffer<float> *rb = getReadRingBuffer(ch);
720
721 if (rb) {
722
723 float ratio = ts->getRatio();
724
725 // std::cout << "ratio = " << ratio << std::endl;
726
727 size_t available;
728
729 while ((available = ts->getAvailableOutputSamples()) < count) {
730
731 size_t reqd = lrintf((count - available) / ratio);
732 reqd = std::max(reqd, ts->getRequiredInputSamples());
733 if (reqd == 0) reqd = 1;
734
735 float ib[reqd];
736 size_t got = rb->read(ib, reqd);
737
738 #ifdef DEBUG_AUDIO_PLAY_SOURCE_PLAYING
739 std::cout << "AudioCallbackPlaySource::getSamples: got " << got << " samples on channel " << ch << " (reqd=" << reqd << ", count=" << count << ", ratio=" << ratio << ", got*ratio=" << got * ratio << "), running time stretcher" << std::endl;
740 #endif
741
742 if (got < reqd) {
743 std::cerr << "WARNING: Read underrun in playback ("
744 << got << " < " << reqd << ")" << std::endl;
745 }
746
747 ts->putInput(ib, got);
748
749 if (got == 0) break;
750
751 if (ts->getAvailableOutputSamples() == available) {
752 std::cerr << "WARNING: AudioCallbackPlaySource::getSamples: Added " << got << " samples to time stretcher, created no new available output samples" << std::endl;
753 break;
754 }
755 }
756
757 ts->getOutput(buffer[ch], count);
758 }
759 }
760 */
761 m_condition.wakeAll(); 716 m_condition.wakeAll();
762 717
763 return count; 718 return count;
764 } 719 }
765 720