maemo (N900) 上的 Qt 应用程序中的同步音频流

发布于 2024-10-15 21:37:09 字数 1794 浏览 8 评论 0原文

请问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);

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

I wonder if it is possible to perform voice streaming on N900 phone? I need to buffer voice samples from the micrphone and symultanously send voice from other buffer to speaker?
Do you thing it is possible and how?
now i am using files to record and play audio. but this is not synchronized.

recording:

 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);

palying:

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);

I need to buffer voice samples from the micrphone and symultanously send voice from other buffer to speaker. how i can do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文