How to play audio files as input?
Hello all. I'm looking at playing an audio file as an input. I want to use this to be able to play audio files through discord, and have the other call participants hear it (an audio macro?). Thanks!
About this post
- Posted
- Archived
- Score
- 65 · 93% up
- Kind
- Text
- ID
- klmyec
20 comments
If you don't need your own voice during it, switch the discord recording to the "Monitor of" your audiocard in pulseaudio/pavucontrol.
if you want this more fine grained you'll have to specify a bit more what goals you have. If you just want to record a single program allocate a virtual-sink move the program you want to use as an input to that virtual sink and record from there.
See e.g. this thread https://bbs.archlinux.org/viewtopic.php?id=261326 for a bit of a more extensive example
More links:
module-null-sink: Create a virtual sink to play your audio to. You can use a "Monitor of ..." device to capture from it.
module-loopback: Route audio from a source (microphone) to a sink.
module-combine-sink: Combine two sinks into one.
You can now route your microphone from your microphone to a sink using loopback, combine that sink with a null sink and then capture from the monitor of the combined sink.
Ideally I would want to be able to talk at the same time as i play the input to discord (it only needs to play to discord and nothing else) but thank you.
You could also dabble your feet in Jack, which will make it a lot easier if you ever need to do anything more complicated. Then you can literally just use Carla to plug your sound and mic into the sink and call it a day.
I've done this very recently. Here's how I achieved it:
Create a new file
~/.config/pulse/default.pawith the following content:What this does is setup two null sinks (one for the stuff you want to both hear and share, called virtual1-hearshare, and one for the stuff you want to share, called virtual2-share) and three loopbacks to send stuff in and out of those.
Next, install
pavucontroland restart your session.Open Pavucontrol (aka PulseAudio Volume Control) and go to the playback tab. At the bottom, select "All streams". Make sure that one of the two loopbacks from "Monitor of virtual1-hearshare" goes into your headphones and the other goes into virtual2-share.
Then, go to the recording tab. Make sure that one of the two loopbacks to virtual2-share comes from virtual1-hearshare and the other comes from your microphone.
Nice. Now, when you want to share audio to Discord, do the following:
After doing this, both you and your friends on Discord should be able to hear the audio (not all of the audio going to your headphones, only the audio from the program you selected), and also they should be able to hear you.
This is one of those good replies you sometimes see around. You wouldn't happen to have some good resources? Especially understanding how to setup
default.pa?If you run
man pulse-cli-syntaxyou will find an explanation of the syntax ofdefault.pa. All of those commands can be also run from a shell by prependingpacmdto them.What you will most probably want to do with
default.pais load and configure modules. You can find a list of the modules and their configuration options at https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/Modules/.The two modules used in my answer are
module-null-sinkandmodule-loopback.Be aware that the codec/bandwidth discord uses for speech absolutely butchers non-spoken content (like music or even just TV shows with bgm mixed with voice lines). I've previously tried this as a workaround for discord's lack of support for capturing desktop audio on Linux when streaming to friends but the results were not acceptable to end users even when they were fine if I recorded the monitor stream locally using VLC (and this was after turning off all discord's post processing)
Some more interesting resources:
Thank you! Soundux does exactly what i need :)
I do this constantly for Zoom calls and podcasting.
If you want to do this on the regular, it might be easier to buy a small audio mixer and a dynamic mic. If you get one with USB in/out then that's all the better. I personally own a Yamaha MG10XU and a cheap Behringer dynamic mic for doing podcasts, but I'm upgrading my mic soon. The USB gives you an additional in and out channel, and you can send the USB stereo in on monitor mode so it only goes to your headphones/monitor and not your output.
You can also pick up a 1/8" TRS stereo to RCA cable and plug your cellphone in as a second audio source into the channel 5/6 input, which will give you a dedicated source for your media. I do this by using a second sound card with a hefty bit of pulseaudio config, but you can do it without reconfiguring pulse at all. Anything you mix between your cell and your mic will be used as your audio input to discord.
Note that the USB in from the MG10XU is a bit on the weak side so you'll likely want to boost it in pavucontrol or set up an analog main out into your line in. This second way can be tricky depending on how your sound card is configured. If it comes out sounding crunchy, then the sound card is adding amplification, which you don't want.
So, the configuration will go like this
I think the simplest solution would be to just use Discord's built-in screen-sharing functionality, which I'm pretty sure also shares your computer's audio.
Not on Linux it doesn't - apparently they're waiting for Pipewire to be more widespread.
ah okay, nvm then
Deleted before we saved it.
use a soundboard like voicemod
I would, if it had a linux version