1

我想知道是否可以在 N900 手机上执行语音流?我需要缓冲来自麦克风的语音样本并同时将语音从其他缓冲区发送到扬声器?你觉得这是可能的吗?怎么做?现在我正在使用文件来录制和播放音频。但这不是同步的。

记录:

 outputFile.setFileName("/tmp/test.raw");
   outputFile.open( QIODevice::WriteOnly | QIODevice::Truncate );

   QAudioFormat format;

   format.setFrequency(8000);
   format.setChannels(1);
   format.setSampleSize(16);
   format.setSampleType(QAudioFormat::SignedInt);
   format.setByteOrder(QAudioFormat::LittleEndian);
   format.setCodec("audio/pcm");

   QAudioDeviceInfo info(QAudioDeviceInfo::defaultInputDevice());

   qDebug() << info.availableDevices(QAudio::AudioInput).at(1).deviceName();


   if (!info.isFormatSupported(format)) {
       qWarning() << "Default format not supported - trying to use nearest";
       format = info.nearestFormat(format);
   }

   /////////////////////////////




   audio = new QAudioInput(info,format, this);
   QTimer::singleShot(5000, this, SLOT(stopRecording()));
   audio->start(&outputFile);

播放:

inputFile.setFileName("/tmp/test.raw");
inputFile.open( QIODevice::ReadOnly );

QAudioFormat format;
format.setFrequency(8000);
format.setChannels(1);
format.setSampleSize(16);
format.setSampleType(QAudioFormat::SignedInt);
format.setByteOrder(QAudioFormat::LittleEndian);
format.setCodec("audio/pcm");

QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice());
if (!info.isFormatSupported(format)) {
    qWarning()<<"raw audio format not supported by backend, cannot play audio.";
    format = info.nearestFormat(format);
}
audio2 = new QAudioOutput(format, this);
connect(audio2,SIGNAL(stateChanged(QAudio::State)),SLOT(finishedPlaying(QAudio::State)));
audio2->start(&inputFile);

我需要缓冲来自麦克风的语音样本,并同时将语音从其他缓冲区发送到扬声器。我怎么能这样做?

4

0 回答 0