<?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[hear only noises with QAudioOutput]]></title><description><![CDATA[<p dir="auto">Hi, I work with audio capture from microphone.</p>
<p dir="auto">This is server</p>
<pre><code>    QAudioRecorder* recorder = new QAudioRecorder();
    QAudioProbe* probe = new QAudioProbe;

    connect(probe, SIGNAL(audioBufferProbed(QAudioBuffer)), this, SLOT(processBuffer(QAudioBuffer)));
    

    QAudioEncoderSettings audioSettings;
    audioSettings.setCodec("audio/mpeg");
    audioSettings.setQuality(QMultimedia::HighQuality);

    recorder-&gt;setEncodingSettings(audioSettings);

    
    qDebug() &lt;&lt; "probe ritorna " &lt;&lt; probe-&gt;setSource(recorder); // Returns true, hopefully.
    //qDebug() &lt;&lt; "" &lt;&lt; recorder-&gt;setOutputLocation(QUrl::fromLocalFile("test"));

    recorder-&gt;record(); // Now we can do things like calculating levels or performing an FFT    
    
    myAudioServer = new MyAudioServer();
    myAudioServer-&gt;startServer();
</code></pre>
<p dir="auto">This is the way as trasfer to socket</p>
<pre><code>void QtVideoWidgetsIssueTrack::processBuffer(const QAudioBuffer&amp; buffer){
    QByteArray byteArr;
    byteArr.append(buffer.constData&lt;char&gt;(), buffer.byteCount());
    QByteArray Data = byteArr;
    qDebug() &lt;&lt; myAudioServer-&gt;isListening();
    QTcpSocket* myAudioClient = myAudioServer-&gt;getSocket();
    qDebug() &lt;&lt; myAudioClient;
    qDebug() &lt;&lt; "in processBuffer";
    if (myAudioClient != nullptr) {
        myAudioClient-&gt;write(Data, Data.count());
        myAudioClient-&gt;waitForBytesWritten();
    }
}
</code></pre>
<p dir="auto">Now the client</p>
<pre><code>void MyThreadAudioTcpSocket::readyRead()
{

    

    while (socket-&gt;bytesAvailable() &gt; 0) {

        //fare il play da QByteArray
          // get default output device
        QByteArray* yourSoundData = new QByteArray(socket-&gt;readAll());
        QBuffer* buffer = new QBuffer;
        buffer-&gt;setData(yourSoundData-&gt;data(),yourSoundData-&gt;size());
        buffer-&gt;open(QBuffer::ReadOnly);
        
        QAudioFormat format;
        format.setSampleSize(16);
        format.setSampleRate(22050);
        format.setChannelCount(1);
        format.setCodec("audio/mpeg");
        format.setByteOrder(QAudioFormat::LittleEndian);
        format.setSampleType(QAudioFormat::UnSignedInt);

        QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice());
        if (!info.isFormatSupported(format)) {
            format = info.nearestFormat(format);
            qDebug() &lt;&lt; "formato non supportato";
        }
       
        QAudioOutput *output = new QAudioOutput(format);
        output-&gt;moveToThread(this);
        output-&gt;start(buffer);
    }
}
</code></pre>
<p dir="auto">I attach what I hear, only noise... !<br />
<a href="https://filelink.org/okVit4Lw9aFeXWQ" target="_blank" rel="noopener noreferrer nofollow ugc">wav file</a></p>
<p dir="auto">Someone can You help me to understand where wrong in source code.</p>
]]></description><link>https://forum.qt.io/topic/140076/hear-only-noises-with-qaudiooutput</link><generator>RSS for Node</generator><lastBuildDate>Thu, 05 Nov 2026 02:31:26 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/140076.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 15 Oct 2022 03:44:53 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to hear only noises with QAudioOutput on Sat, 15 Oct 2022 11:30:56 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/zabitqt">@<bdi>zabitqt</bdi></a> said in <a href="/post/732780">hear only noises with QAudioOutput</a>:</p>
<blockquote>
<p dir="auto">It's my first project in c++</p>
</blockquote>
<p dir="auto">Then please start with something easier - the <a href="https://doc.qt.io/qt-6/qtexamplesandtutorials.html" target="_blank" rel="noopener noreferrer nofollow ugc">Qt examples</a> are a good start</p>
]]></description><link>https://forum.qt.io/post/732781</link><guid isPermaLink="true">https://forum.qt.io/post/732781</guid><dc:creator><![CDATA[Christian Ehrlicher]]></dc:creator><pubDate>Sat, 15 Oct 2022 11:30:56 GMT</pubDate></item><item><title><![CDATA[Reply to hear only noises with QAudioOutput on Sat, 15 Oct 2022 11:29:29 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/christian-ehrlicher">@<bdi>Christian-Ehrlicher</bdi></a> Ok but I don't think the problem are memleaks... I don't realease Memory correctly and close connection but... Can you suggest me how improve code please. It's my first project in c++</p>
]]></description><link>https://forum.qt.io/post/732780</link><guid isPermaLink="true">https://forum.qt.io/post/732780</guid><dc:creator><![CDATA[zabitqt]]></dc:creator><pubDate>Sat, 15 Oct 2022 11:29:29 GMT</pubDate></item><item><title><![CDATA[Reply to hear only noises with QAudioOutput on Sat, 15 Oct 2022 11:21:15 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/zabitqt">@<bdi>zabitqt</bdi></a> said in <a href="/post/732748">hear only noises with QAudioOutput</a>:</p>
<blockquote>
<p dir="auto">void MyThreadAudioTcpSocket::readyRead()<br />
{</p>
<pre><code>while (socket-&gt;bytesAvailable() &gt; 0) {

    //fare il play da QByteArray
      // get default output device
    QByteArray* yourSoundData = new QByteArray(socket-&gt;readAll());
    QBuffer* buffer = new QBuffer;
    buffer-&gt;setData(yourSoundData-&gt;data(),yourSoundData-&gt;size());
    buffer-&gt;open(QBuffer::ReadOnly);
    
    QAudioFormat format;
    format.setSampleSize(16);
    format.setSampleRate(22050);
    format.setChannelCount(1);
    format.setCodec("audio/mpeg");
    format.setByteOrder(QAudioFormat::LittleEndian);
    format.setSampleType(QAudioFormat::UnSignedInt);

    QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice());
    if (!info.isFormatSupported(format)) {
        format = info.nearestFormat(format);
        qDebug() &lt;&lt; "formato non supportato";
    }
   
    QAudioOutput *output = new QAudioOutput(format);
    output-&gt;moveToThread(this);
    output-&gt;start(buffer);
}
</code></pre>
<p dir="auto">}</p>
</blockquote>
<p dir="auto">Are you serious? If there ould be a contest to create as much memleaks as possible this would be probably under the top ten.</p>
]]></description><link>https://forum.qt.io/post/732778</link><guid isPermaLink="true">https://forum.qt.io/post/732778</guid><dc:creator><![CDATA[Christian Ehrlicher]]></dc:creator><pubDate>Sat, 15 Oct 2022 11:21:15 GMT</pubDate></item><item><title><![CDATA[Reply to hear only noises with QAudioOutput on Sat, 15 Oct 2022 10:32:45 GMT]]></title><description><![CDATA[<p dir="auto">Someone help me</p>
]]></description><link>https://forum.qt.io/post/732775</link><guid isPermaLink="true">https://forum.qt.io/post/732775</guid><dc:creator><![CDATA[zabitqt]]></dc:creator><pubDate>Sat, 15 Oct 2022 10:32:45 GMT</pubDate></item></channel></rss>