Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-84565

QAudioInput can't open audio device with more thant 16 channels

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.14.0
    • Multimedia
    • mac os 10.14.6
    • macOS

    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:

      https://forum.qt.io/topic/115299/qiodevice-writedata-is-not-triggered-when-working-with-with-64-channels-qauioformat/11

       

      Thank you!

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            artemiy Artem Dyomin
            thinium thinium ya
            Veli-Pekka Heinonen Veli-Pekka Heinonen
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes