本文整理汇总了C++中Filter::flush方法的典型用法代码示例。如果您正苦于以下问题:C++ Filter::flush方法的具体用法?C++ Filter::flush怎么用?C++ Filter::flush使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Filter
的用法示例。
在下文中一共展示了Filter::flush方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
//.........这里部分代码省略.........
}
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);
// read some stuff from the audio stream
inSamples = audioStream->read(buffer, BUFFERSIZE/**audioStream->getChannels()*/);
LOG4CXX_TRACE(narratorLog, "got " << inSamples << " samples");
//printf("Read %d samples from audio stream\n", inSamples);
if(inSamples != 0) {
filter.write(buffer, inSamples); // One sample contains data for all channels here
writeSamplesToPortaudio( n, portaudio, filter, buffer );
} else {
LOG4CXX_INFO(narratorLog, "Flushing soundtouch buffer");
filter.flush();
}
state = n->getState();
} while (inSamples != 0 && state == Narrator::PLAY && !n->bResetFlag);
if(buffer != NULL) delete [] (buffer);
audioStream->close();
delete audioStream;
}
// Else try opening from database
else {
vector <MessageAudio> vAudioQueue;
// Get a list of MessageAudio objects to play
Message *m = pi.mMessage;
if(m==NULL){
LOG4CXX_ERROR(narratorLog, "Message was null");
}
m->setLanguage(lang);
m->load(pi.mIdentifier, pi.mClass);
if(!m->compile() || !m->hasAudio()) {
LOG4CXX_ERROR(narratorLog, "Narrator translation not found: could not find audio for '" << pi.mIdentifier << "'");
} else {
vAudioQueue = m->getAudioQueue();
}
// Play what we got