本文整理汇总了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);