Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QAudioInput start delay
Forum Updated to NodeBB v4.3 + New Features

QAudioInput start delay

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 441 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mark Durkot
    wrote on last edited by
    #1

    Hello guys,

    I'm using QAudioInput for my app. I do real time sound processing. I'm also using build in microphone.
    But when I call audioInput->start() for the first time since the program started I get a delay by starting the QAudioInput. On my computer (iMac 2019 running Mojave (10.14.6)) the delay is about 5 sec. But the audioInput->start() takes forever to start sampling on a MacBook Pro (mid 2012 also running Mojave). I have to say it just doesn't start :))).
    Here is my code how I initialize the QAudioInput

    format_.setSampleRate(SampelRate);
    format_.setChannelCount(1);
    format_.setSampleSize(16);
    format_.setSampleType(QAudioFormat::SignedInt);
    format_.setByteOrder(QAudioFormat::LittleEndian);
    format_.setCodec("audio/pcm");
    
    QAudioDeviceInfo inputInfo(QAudioDeviceInfo::defaultInputDevice());
    if (!inputInfo.isFormatSupported(format_)) {
        format_ = inputInfo.nearestFormat(format_);
    }
    audioInput_ = new QAudioInput(QAudioDeviceInfo::defaultInputDevice(), format_, this);
    

    And this is how I connect readReady() signal to my slot

    inputDevice_ = audioInput_->start();
    connect(inputDevice_, SIGNAL(readyRead()), this, SLOT(readMore()));
    

    So back to my computer where I have 5 sec delay. I checked the state of the audioInput right after I started it, it says "IdleState". After approximately 5 sec it switches to "ActiveState" and I start getting data from microphone.

    I couldn't find any answer on the internet so I'm asking this by you guys. I don't know if it's the problem of the device, my code, or the QAudioInput.

    I would be very thankful of any help of you!
    Mark :)

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Since you want to do real-time audio, I would rather go with a library that has less latency.

      I remember having had good results with PortAudio.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      M 1 Reply Last reply
      2
      • M Offline
        M Offline
        Mark Durkot
        wrote on last edited by
        #3
        This post is deleted!
        1 Reply Last reply
        0
        • SGaistS SGaist

          Hi,

          Since you want to do real-time audio, I would rather go with a library that has less latency.

          I remember having had good results with PortAudio.

          M Offline
          M Offline
          Mark Durkot
          wrote on last edited by
          #4

          @SGaist
          Hi,
          I very appreciate your answer! Thank you so much, I'm gonna try PortAudio as soon as I get back to my project! And tell you how it went)
          Thank you:)

          Best regards
          Mark

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved