<?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[Using QAudioOutput as Input]]></title><description><![CDATA[<p dir="auto">Hello. I want to record audiooutput into a .wav-file. All I got is a empty file. Here is my code:</p>
<pre><code>QAudioOutput *my_audioOutput = new QAudioOutput();
QMediaCaptureSession *my_session = new QMediaCaptureSession();
QMediaRecorder *my_recorder = new QMediaRecorder();
bool recording = false;
...
...
...
void MainWindow::on_pushButtonRecord_clicked()
{
    if(recording == true) {
        my_recorder-&gt;stop();
        recording = false;
    }
    else {
        // RECORD
        my_audioInput = new QAudioInput();
        my_audioInput-&gt;setDevice(my_audioOutput-&gt;device());    // &lt;-- This does not work
        my_session-&gt;setAudioInput(my_audioInput);
        my_session-&gt;setRecorder(my_recorder);
        my_recorder-&gt;setMediaFormat(QMediaFormat::Wave);
        my_recorder-&gt;setOutputLocation(QUrl::fromLocalFile("/home/thomas/Projects/mymp3player/test"));
        my_recorder-&gt;setAudioSampleRate(48000);
        my_recorder-&gt;setAudioChannelCount(2);
        my_recorder-&gt;record();
        recording = true;
    }
}
</code></pre>
<p dir="auto">Can someone help me on this?</p>
]]></description><link>https://forum.qt.io/topic/161029/using-qaudiooutput-as-input</link><generator>RSS for Node</generator><lastBuildDate>Sat, 19 Sep 2026 06:23:37 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/161029.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 17 Feb 2025 20:14:22 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Using QAudioOutput as Input on Tue, 18 Feb 2025 11:47:10 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/bonnie">@<bdi>Bonnie</bdi></a> This... is... great! Thank you very much.<br />
I came up with following commands:</p>
<pre><code>pactl load-module module-null-sink sink_name=my_sink_mix sink_properties=device.description=my_sink_mix
pactl load-module module-loopback latency_msec=60 adjust_time=6 source=alsa_output.pci-0000_00_1b.0.analog-stereo.monitor sink=my_sink_mix
pactl load-module module-remap-source master=my_sink_mix.monitor source_name=vmic source_properties=device.description=virtual_mic
</code></pre>
<p dir="auto">So, all I have to do is to write something with QProcess with these commands. And then use "vmic" as QAudioInput and "my_sink_mix" as QAudioOutput and voila! I can hear the audiostream and save it to disc simultaneously.</p>
<p dir="auto">Again: Thank you very much!</p>
]]></description><link>https://forum.qt.io/post/820865</link><guid isPermaLink="true">https://forum.qt.io/post/820865</guid><dc:creator><![CDATA[Wolfspirit]]></dc:creator><pubDate>Tue, 18 Feb 2025 11:47:10 GMT</pubDate></item><item><title><![CDATA[Reply to Using QAudioOutput as Input on Tue, 18 Feb 2025 08:12:42 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/wolfspirit">@<bdi>Wolfspirit</bdi></a> said in <a href="/post/820823">Using QAudioOutput as Input</a>:</p>
<blockquote>
<p dir="auto">There must be some way to do this in QT.......</p>
</blockquote>
<p dir="auto">What Qt can do is to just open and read your existing audio input devices.<br />
If your system has a loopback input device, then Qt can open it. If not then Qt can't.</p>
<p dir="auto">I don't use linux often but I remember having loopback-like ones when printing the names of all the audio input devices using Qt, not sure this is soundcard-related or not. So maybe you can first try listing the input devices using Qt to see if there's one.</p>
<p dir="auto">If there's not, as I googled, this loopback thing can be set by command line (reference: <a href="https://forums.debian.net/viewtopic.php?t=110440" target="_blank" rel="noopener noreferrer nofollow ugc">https://forums.debian.net/viewtopic.php?t=110440</a> or <a href="https://huma.id/pa-loopback/" target="_blank" rel="noopener noreferrer nofollow ugc">https://huma.id/pa-loopback/</a>). But that has nothing to do with Qt. You can make Qt to run a command script before opening the device if you find out how to set that by script.</p>
]]></description><link>https://forum.qt.io/post/820833</link><guid isPermaLink="true">https://forum.qt.io/post/820833</guid><dc:creator><![CDATA[Bonnie]]></dc:creator><pubDate>Tue, 18 Feb 2025 08:12:42 GMT</pubDate></item><item><title><![CDATA[Reply to Using QAudioOutput as Input on Mon, 17 Feb 2025 21:30:56 GMT]]></title><description><![CDATA[<p dir="auto">Seems like I have to change the input device via pavucontrol:<br />
<a href="https://wiki.debian.org/audio-loopback" target="_blank" rel="noopener noreferrer nofollow ugc">Audio Loopback Recording with PulseAudio</a></p>
<p dir="auto">But I don't want to do this every time manually for my application. There must be some way to do this in QT.......</p>
]]></description><link>https://forum.qt.io/post/820823</link><guid isPermaLink="true">https://forum.qt.io/post/820823</guid><dc:creator><![CDATA[Wolfspirit]]></dc:creator><pubDate>Mon, 17 Feb 2025 21:30:56 GMT</pubDate></item></channel></rss>