当前位置: 首页>>代码示例>>C++>>正文


C++ AudioStream::getRate方法代码示例

本文整理汇总了C++中AudioStream::getRate方法的典型用法代码示例。如果您正苦于以下问题:C++ AudioStream::getRate方法的具体用法?C++ AudioStream::getRate怎么用?C++ AudioStream::getRate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AudioStream的用法示例。


在下文中一共展示了AudioStream::getRate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: if


//.........这里部分代码省略.........
            pthread_mutex_unlock(n->narratorMutex);
            continue;
        }
        string lang = n->mLanguage;
        pthread_mutex_unlock(n->narratorMutex);

        // If trying to play a file, open it
        if(pi.mClass == "file") {
            LOG4CXX_DEBUG(narratorLog, "Playing file: " << pi.mIdentifier);

            AudioStream *audioStream;

            std::string fileExtension = getFileExtension(pi.mIdentifier);
            if (fileExtension == "ogg")
            {
                audioStream = new OggStream;
            }
            else if (fileExtension == "mp3")
            {
                audioStream = new Mp3Stream;
            }
            else
            {
                LOG4CXX_ERROR(narratorLog, "extension '" << fileExtension << "' not supported");
                continue;
            }

            if(!audioStream->open(pi.mIdentifier)) {
                LOG4CXX_ERROR(narratorLog, "error opening audio stream: " << pi.mIdentifier);
                audioStream->close();
                continue;
            }

            if (portaudio.getRate() != audioStream->getRate())
            {
                long waitms = portaudio.getRemainingms();
                if (waitms != 0)
                {
                    LOG4CXX_DEBUG(narratorLog, "Waiting for current playback to finish");
                    while (waitms > 0)
                    {
                        usleep(100000);
                        waitms -= 100;
                    }
                }
            }

            if(!portaudio.open(audioStream->getRate(), audioStream->getChannels())) {
                LOG4CXX_ERROR(narratorLog, "error initializing portaudio, (rate: " << audioStream->getRate() << " channels: " << audioStream->getChannels() << ")");
                continue;
            }

            if(!filter.open(audioStream->getRate(), audioStream->getChannels())) {
                LOG4CXX_ERROR(narratorLog, "error initializing filter");
                continue;
            }

            LOG4CXX_DEBUG(narratorLog, "Audio stream has " << audioStream->getChannels() << " channel(s) and rate " << audioStream->getRate() << " Hz");

            int inSamples = 0;
            soundtouch::SAMPLETYPE* buffer = new soundtouch::SAMPLETYPE[audioStream->getChannels()*BUFFERSIZE];
            //buffer = (short*)malloc(sizeof(short) * 2 * BUFFERSIZE);
            // long totalSamplesRead = 0;
            do {
                // change gain, tempo and pitch
                adjustGainTempoPitch(n, filter, gain, tempo, pitch);
开发者ID:kolibre,项目名称:libkolibre-narrator,代码行数:67,代码来源:Narrator.cpp


注:本文中的AudioStream::getRate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。