Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.14.0
-
mac os 10.14.6
Description
Hi Qt team!
I want to route audio signal from Soundflower 64channels into my Qt app to visualize the audio signal. But I realize the QAudioInput only works when QAudioFormat has channel counts <= 16. In the QAudioDeviceInfo it's hard-coded that the supported channels are up to 16 as shown below. Is there a reason why it's only up to 16 channels? I believe that it shouldn't be a problem to support 64 channels. Maybe it should be at least hard-coded to 64?
QList<int> CoreAudioDeviceInfo::supportedChannelCounts() { static QList<int> supportedChannels; if (supportedChannels.isEmpty()) { // If the number of channels is not supported by an audio device, Core Audio will // automatically convert the audio data. for (int i = 1; i <= 16; ++i) supportedChannels.append(i); } return supportedChannels; }
Here is my code snippet to show what I try to do:
void MyWidget::deviceChanged (const QAudioDeviceInfo &deviceInfo) { if (m_audioInput) { m_audioInput->stop(); delete m_audioInput; } if (m_streamReader) { m_streamReader->stop(); delete m_streamReader; } QAudioFormat format = deviceInfo.preferredFormat(); // this line shows the original format: QAudioFormat(44100Hz, 32bit, channelCount=64, sampleType=SignedInt, byteOrder=BigEndian, codec="audio/pcm") qDebug() << "original format:" << format; // in order to make QIODevice::writeData(const char *data, qint64 len) being triggered, I need to manually set the channel count to anything less than 16, if the channel count is more than 15, the QIODevice:writeData won't be triggered format.setChannelCount(8); m_audioInput = new QAudioInput(deviceInfo, format); // StreamReader is a subclass of QIODevice m_streamReader = new StreamReader(m_audioInput->format(), this); m_streamReader->start(); m_audioInput->start(m_streamReader); qDebug() << m_audioInput->state(); }
If I didn't manually set channel count to <= 16, the audio input state will be in StoppedState.
Here is a related discussion in the Qt forum:
Thank you!