<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[QAudioOutput start() takes too much time]]></title><description><![CDATA[<p dir="auto">Hello,</p>
<p dir="auto">I'm working on a audio app that aims raspberry pi and mobile phones.<br />
It consists of 8 audio channels loading samples and allowing to play live or using internal sequencer.</p>
<p dir="auto">Each channel has its own QAudioOutput and store sample in QByteArray / QBuffer in a way that when I need to play a sample I just need to do this :</p>
<pre><code>if (m_buffer.isOpen()) {
        m_buffer.close();
    }

    m_buffer.setData(m_noteBuffer[value]);
    m_buffer.open(QIODevice::ReadOnly);

    std::chrono::high_resolution_clock::time_point before = std::chrono::high_resolution_clock::now();
    m_audioOutput-&gt;start(&amp;m_buffer);
    qDebug() &lt;&lt; "Play " &lt;&lt; m_index &lt;&lt; ": " &lt;&lt; std::chrono::duration_cast&lt;std::chrono::microseconds&gt;(std::chrono::high_resolution_clock::now() - before).count();
</code></pre>
<p dir="auto">m_buffer is a QBuffer<br />
m_noteBuffer is an array of QByteArray containing various pitched versions of my sample.</p>
<p dir="auto">As you can see I measured the time needed to call QAudioOutput start and I took between 500 - 1000 microseconds on my powerfull dev PC.</p>
<p dir="auto">When I play multiple channels at the same time on Android for example, I can clearly hear that they are not perfectly sync (on Dev PC no problem as 1ms is ok but QAudiuoOutput start is probably much longer on Android).</p>
<p dir="auto">I already put each channels in separated threads and use signal ans slots to parallelize this part but It didn't helped a lot.<br />
I think that the problem is the time consumed by QAudioOutput start.</p>
<p dir="auto">I tried to avoid using start by just calling seek(0) on the buffer and call resume on QAudioOutput but even if the time consumed is really lower (20-80 microseconds), the resulting audio has more latency :/</p>
<ul>
<li>Is there a way to reduce time consummed by QaudioOutput start ?</li>
<li>Any idea on another way to do this ?</li>
</ul>
<p dir="auto">Thanks for you help</p>
]]></description><link>https://forum.qt.io/topic/114754/qaudiooutput-start-takes-too-much-time</link><generator>RSS for Node</generator><lastBuildDate>Thu, 24 Sep 2026 19:07:25 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/114754.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 13 May 2020 10:10:19 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to QAudioOutput start() takes too much time on Wed, 13 May 2020 21:09:35 GMT]]></title><description><![CDATA[<p dir="auto">Some more info about the latency problem. I just measured the time taken by the QAudioOutput start on my android phone.<br />
Time varies from ~650 micro-seconds at best, to more than 5000 micro-seconds for the same played sample in the exact same conditions.</p>
<p dir="auto">I think this confirm what I was thinking.<br />
Such a time variation (near 1 to 10 ratio) is probably due to Android, maybe some battery life optimisations or something like that.</p>
<p dir="auto">I'm now searching for Android manifest config that could reduce the problem.</p>
<p dir="auto">Any suggestion would be welcome :)</p>
]]></description><link>https://forum.qt.io/post/594562</link><guid isPermaLink="true">https://forum.qt.io/post/594562</guid><dc:creator><![CDATA[Gauthier]]></dc:creator><pubDate>Wed, 13 May 2020 21:09:35 GMT</pubDate></item></channel></rss>