this post was submitted on 19 Apr 2024
45 points (97.9% liked)

Linux

48180 readers
964 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 5 years ago
MODERATORS
 

I've got this idea in my head that I want a tofi based sound board that I can summon on a button press (and maybe fuzzy find through)

Should be fairly simple to do with the way tofi works to make the interface, but as far as I can find there's not a quick and easy way to mix sounds in with mic input using pactl

Is there any single line solution for playing a sound over mic (like a soundboard would) anyone can think of or do I need to mess around with virtual audio devices to achieve this

top 22 comments
sorted by: hot top controversial new old
[–] [email protected] 4 points 6 months ago (1 children)

I do exactly this using rofi to select a clip, pipe it to play (part of SoX), have a qpwGraph profile route the output to a null pw node (along with my mic input), then route that to discord or whatever.

[–] [email protected] 2 points 6 months ago (1 children)

Understood most of the words in that comment individually

What does PW stand for?

[–] [email protected] 5 points 6 months ago* (last edited 6 months ago) (1 children)

Hah, pipewire, sorry.

I was describing my setup from memory, here's what I actually have:

play "`find <path-to-clips> -type f -name "*.wav" | rofi -dmenu -i -fuzzy`"

I then have this bound to a key combo in my qtile config which will pop up a menu so I can fuzzy search for a clip to play. However, this alone will just play the clip. To get it to go through discord, I also have a file ~/.config/pipewire/pipewire.conf.d/50-null-sinks.conf with this in it:

context.objects = [
    {   
	factory = adapter
        args = {
            factory.name     = support.null-audio-sink
            node.name        = "mic-loopback"
            node.description = "Mic Loopback"
            media.class      = Audio/Sink
            audio.position   = [ FL FR ]
            adapter.auto-port-config = {
                mode = dsp
                monitor = true
                position = preserve
            }
        }
    },
    {   
	factory = adapter
        args = {
            factory.name     = support.null-audio-sink
            node.name        = "input-mix"
            node.description = "Input Mix"
            media.class      = Audio/Sink
            audio.position   = [ FL FR ]
            adapter.auto-port-config = {
                mode = dsp
                monitor = true
                position = preserve
            }
        }
    }
]

This creates two new nodes that I can use to combine audio into a single source. I then use a combination of the pavucontrol and qpwgraph GUIs to control what audio streams go where. I wire my actual microphone along with the output ports of "Mic Loopback" to the input ports of "Input Mix". Then whatever app I want to play back through my mic, I wire up to the input ports of "Mic Loopback". To wire SoX up to Mic Loopback, I play a clip that's long enough for me to make the switch, and then it tends to remember that for the next time SoX launches. Finally, I wire Input Mix up to discord or whatever program I'm using.

The rofi/play combo is rock solid, I really like that. The pipewire/qpwgraph/pavucontrol part could probably be improved. It can feel a little non-deterministic, but really I think I don't fully understand what each app involved is doing to manipulate the pipewire graph, or how to configure them so they don't try to override each other when a pw node is added/removed.

Edit: quick note. You might be wondering, what's the point of having both Mic Loopback and Input Mix? Couldn't I just have applications go directly to Input Mix? Yes, but generally you want to also hear the sound yourself, without hearing your own mic, and you want to be able to pick a single output device from within the app (most apps don't let you choose more than one). Having two separate nodes lets you split off the output of Mic Loopback to both Input Mix and the output associated with your headphones/speakers, that way you don't hear yourself too.

[–] [email protected] 2 points 6 months ago

Ah fantastic, will have a look at this properly tomorrow

Turns out I am using pipewire with the pulse module so this should work

[–] [email protected] 5 points 6 months ago (1 children)
[–] [email protected] 2 points 6 months ago

Oooh fantastic thank you

[–] [email protected] 3 points 6 months ago

I believe pipewire should be able to do the routing. Pulseaudio as well.

[–] [email protected] 0 points 6 months ago* (last edited 6 months ago) (1 children)

I use Voicemeter Potato to do virtual mixing of inputs. If you've got an output you should be able to route it through Voicemeter.

... Assuming that it works on Linux.

It looks like somebody was trying to do a Linux version here: https://github.com/theRealCarneiro/pulsemeeter so I assume Voicemeter doesn't work on Linux.

There's probably some way to manipulate PulseAudio to do this as well? But the Pulsemeeter option Is probably your best bet even if the repo hasn't been touched in 2 years.

[–] [email protected] 1 points 6 months ago (1 children)

Last release being 2 years ago is a bit of a red flag for me, and being able to play funny sounds in voice chats is not worth a potential security issue

[–] [email protected] 1 points 6 months ago (1 children)

Fair

But also it shouldn't need any network access. The code is open source and you can look through it if you've got the expertise.

[–] [email protected] 1 points 6 months ago (1 children)

I don't have the expertise to spot if someone's able to pull some dark wizard shit and encode a binary in audio and get it to execute it or something

Seriously though I know enough to know I won't spot some obscure bad practice in someone else's code base, even without network access if someone gets onto my system some other way it could give them a route to escalate

[–] [email protected] 1 points 6 months ago (1 children)

All true. It seems obscure and niche enough to not be a scam. There's only a single contributor and based on his activity elsewhere it seems like it was probably just a passion project.

[–] [email protected] 1 points 6 months ago (1 children)

Oh I have no doubt it's legitimate, my concern is just that it's unmaintained

[–] [email protected] 1 points 6 months ago (1 children)

/shrug

I'd take that bet, but I often am relying on packages that are significantly out of date as a professional Android developer. 2 years is mild.

There's no obvious rootkit unless the developer put it in and if it works with your version of Pulse then I wouldn't see what the issue could be. It's mostly a front end access to your Pulse where you're making and mixing digital.

Security consciousness is good but I think you can trust this one.

But I'm also just a stranger on the Internet ❤️

[–] [email protected] 1 points 6 months ago

I'm not that anal about my security but it's a very trivial thing and if I ended up getting any of my network compromised to make a soundboard there are several people in my life who would shoot me

[–] [email protected] 3 points 7 months ago (1 children)

Soundux comes to mind but it’s not tofi :/

[–] [email protected] 5 points 7 months ago (1 children)

I tried soundux, within 5 minutes of running it it was eating cpu and froze my pc up

Tofi can do the sound searching stuff based on MP3 files in a directory, just need a way to play a sound on top of an input device from the cli

[–] [email protected] 3 points 7 months ago (1 children)

pipewire will do the trick, might be slightly overkill tho

[–] [email protected] 1 points 6 months ago (1 children)

I think I'm using pipewire anyway, how are you thinking?

[–] [email protected] 1 points 6 months ago (1 children)

You mention pactl so I’m not sure if you’re using pipewire, but if you are there is qpwgraph or helvum you could try

[–] [email protected] 1 points 6 months ago (1 children)

I'm using pulse, had thought pipewire ran alongside it but I suppose that's wrong. Will have a look anyway though

[–] [email protected] 1 points 6 months ago

pulse audio and pipewire are mutually exclusive, but pipewire has a pluse module so all your programs can still work even if they dont support pipewire