私の目的は、生のフォーマット(サンプルのみ)、8kHz、16bit(リトルエンディアン)、1chのサウンドを録音したいのです。次に、それらのサンプルをウィンドウに転送し、QAudioOutputで再生したいと思います。 QAudioInputで音声を録音するプログラムと、いくつかのサンプルが含まれているファイルを提供するプログラムの2つのプログラムがあり、QAudioOutputで再生します。以下はQAudioInputとQAudioOutputを作成するための私のソースコードです。QAudioInputでlinuxに録音してWindowsで再生する
//Initialize audio
void AudioBuffer::initializeAudio()
{
m_format.setFrequency(8000); //set frequency to 8000
m_format.setChannels(1); //set channels to mono
m_format.setSampleSize(16); //set sample sze to 16 bit
m_format.setSampleType(QAudioFormat::UnSignedInt); //Sample type as usigned integer sample
m_format.setByteOrder(QAudioFormat::LittleEndian); //Byte order
m_format.setCodec("audio/pcm"); //set codec as simple audio/pcm
QAudioDeviceInfo infoIn(QAudioDeviceInfo::defaultInputDevice());
if (!infoIn.isFormatSupported(m_format))
{
//Default format not supported - trying to use nearest
m_format = infoIn.nearestFormat(m_format);
}
QAudioDeviceInfo infoOut(QAudioDeviceInfo::defaultOutputDevice());
if (!infoOut.isFormatSupported(m_format))
{
//Default format not supported - trying to use nearest
m_format = infoOut.nearestFormat(m_format);
}
createAudioInput();
createAudioOutput();
}
void AudioBuffer::createAudioOutput()
{
m_audioOutput = new QAudioOutput(m_Outputdevice, m_format, this);
}
void AudioBuffer::createAudioInput()
{
if (m_input != 0) {
disconnect(m_input, 0, this, 0);
m_input = 0;
}
m_audioInput = new QAudioInput(m_Inputdevice, m_format, this);
}
これらのプログラムは、WindowsとLinuxでは別々に動作します。しかし、私はLinuxに音声を録音してWindowsで再生すると、騒音が大きくなります。
WindowsとLinuxでキャプチャされたサンプルが異なることがわかります。最初の画像はLinuxでキャプチャされたサウンドに関連し、2番目の画像はウィンドウで使用されます。
のWindowsでキャプチャサウンド:Linuxでのサウンドキャプチャ
の詳細については、WindowsとLinuxでの沈黙が異なることです。私は両方のプラットフォームでリトルエンディアンを設定していましたが、バイトのスワップを含む多くのことを試しました。
今、私はalsaの設定について疑問があります。設定がありませんか?
QAudioInputを使用せずに音声を直接録音する方が良いと思いますか?
どちらの場合でも 'isFormatSupported'がtrueであることを確認できますか? – UmNyobe
入力と出力の両方が真です! – Ari
'nearestFormat'コードを計算し、代わりに' abort() 'を置いた両方の行を削除し、linuxに新しいファイルを記録し、ファイルをウィンドウに移動して再試行してください。変更が適用され、freshmeat_linux/Linux]のマシンから転送された新しくキャプチャされたファイルを再生している両方で新鮮なビルドを使用することを確認してください。 –