Unsolved QAudioInput start delay
-
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 QAudioInputformat_.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 :) -
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.
-
This post is deleted! -
@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