我需要以高采样率= 192 kHz从麦克风捕获声音。
函数supportedSampleRates()返回QList [8000,11025,22050,44100,48000,96000]。我使用Realtek ALC887并将设置的采样率设置为192 kHz。
1)为什么QList中没有192 kHz?
如果我使用48000而且一切都会有效。
但如果我选择96000信号stateChanged(QAudio :: State)给出StoppedState。
这是我的代码。
const int sampleRate=96000;
void initializeAudio()
{
m_format.setSampleRate(sampleRate);
m_format.setChannels(1);
m_format.setSampleSize(16);
m_format.setSampleType(QAudioFormat::SignedInt);
m_format.setByteOrder(QAudioFormat::LittleEndian);
m_format.setCodec("audio/pcm");
m_device=QAudioDeviceInfo::defaultInputDevice();
QAudioDeviceInfo info(QAudioDeviceInfo::defaultInputDevice());
if (!info.isFormatSupported(m_format))
{
qWarning() << "Default format not supported - trying to use nearest";
m_format = info.nearestFormat(m_format);
}
m_audioInfo = new AudioInfo(m_format, this);
connect(m_audioInfo, SIGNAL(update()), SLOT(refreshDisplay()));
createAudioInput();
}
void RecieverPlot::createAudioInput()
{
m_audioInput = new QAudioInput(m_device, m_format, this);
connect(m_audioInput, SIGNAL(notify()), SLOT(notified()));
connect(m_audioInput, SIGNAL(stateChanged(QAudio::State)),SLOT(stateChanged(QAudio::State)));
m_audioInfo->start();
m_audioInput->start(m_audioInfo);
qint64 len=m_audioInput->bytesReady();
}