Real-time audio processing in Fatdog64

versatile 64-bit multi-user Linux distribution

Moderators: kirk, jamesbond, p310don, JakeSFR, step, Forum moderators

Post Reply
jamesbond
Posts: 534
Joined: Tue Aug 11, 2020 3:02 pm
Location: The Pale Blue Dot
Has thanked: 71 times
Been thanked: 291 times

Real-time audio processing in Fatdog64

Post by jamesbond »

This thread and this thread by @geo_c are interesting.

Interestingly, it is possible to do the same thing in Fatdog, without using pipewire. Instead, we can use the real JACK server (which is included in the base).

In Fatdog 901 you can do this with aloopd. All you need is to launch JACK server using qjackctl, and configure Fatdog to use aloopd. In aloopd's configuration, then configure it to run with JACK bridge. In this mode, aloopd will auto-connect any ALSA apps (e.g. browser) to JACK output automatically. You can then modify the connection using qjackctl to insert the various JACK filters as discussed in geo_c's posts.

But this is a temporary connection and when then ALSA app stops the sound, the connection is lost and when you start the music again, you will have to re-do the connection (not much, only two ports need to be re-configured in the qjackctl graph, everything else stays).

In next iteration of Fatdog (whenever it is released), it will be possible to setup a permanent connection for ALSA apps, so we can save and load the connection again at next start. In fact you don't have to wait for it, because it's so very easy to do it. It can be done manually, or I can post the updated aloopdcfg.sh, if any of you are interested.

It's really nice to be able to pipe the output of freetube through Calf's equaliser and limiter, for example (screenshot attached). In this particular setup, the JACK processing load is less than 8% (that's using buffer size of 64). Everything is very smooth even though I'm only using Fatdog standard low-latency kernel (not RT kernel). And this is on an old 2018 laptop.

Attachments
xscreenshot-20240202T182111.jpg
xscreenshot-20240202T182111.jpg (145.25 KiB) Viewed 533 times
out.gif
out.gif (288.19 KiB) Viewed 533 times
geo_c
Posts: 2495
Joined: Fri Jul 31, 2020 3:37 am
Has thanked: 1794 times
Been thanked: 705 times

Re: Real-time audio processing in Fatdog64

Post by geo_c »

Before setting up an exclusively pipewire-jack environment on KLV-airedale, I spent a couple weeks playing with an install of both running pipewire-jack and native jack running side by side. Both were available to use, and that worked well actually. The KLV-jackpipe experiment found here: https://forum.puppylinux.com/viewtopic. ... 20#p108720

One thing I can say, after using native jack for years, running it side by side with pipewire, and running pipewire exclusively with jack applications, is that native jack certainly shows it strengths. And I hope it never goes away completely.

Perhaps the one thing it won't do as well as pipewire is handle different audio devices siimultaneously, so in otherwords mixing different soundcards simultaneously. In jack you basically choose which device to use, whereas pipewire gives you all soundcards that are enabled simultaneously. Whether that's a better arrangement or not is task specific. With a pipewire-jack setup you could do things like use the built-in audio card to monitor a video through headphones while sound from a music player is being played through a second sound interface to a set of speakers in another room. That kind of thing is probably possible with ALSA/native-jack, and I think would need alsa configs to be edited, which I'm not fluent in. With pipewire/pipewire-pulse/pipwire-jack all of those things work out-of-the-box.

Fortunately in our kennel distros we can have all of these setups available with a simple choice of persistent save at boot time!

geo_c
Old School Hipster, and Such

jamesbond
Posts: 534
Joined: Tue Aug 11, 2020 3:02 pm
Location: The Pale Blue Dot
Has thanked: 71 times
Been thanked: 291 times

Re: Real-time audio processing in Fatdog64

Post by jamesbond »

Thanks for the feedback, geo_c.

geo_c wrote: Fri Feb 02, 2024 3:08 pm

In jack you basically choose which device to use, whereas pipewire gives you all soundcards that are enabled simultaneously.

You can run multiple instances of JACK server, one for each hardware device, if you really want to. I can take the input from one device, and pass it around and output it on the second device - both devices under JACK control.

With a pipewire-jack setup you could do things like use the built-in audio card to monitor a video through headphones while sound from a music player is being played through a second sound interface to a set of speakers in another room. That kind of thing is probably possible with ALSA/native-jack,

It is definitely possible. I can use JACK to play freetube with Calf equaliser (the exact setup of the first post) output to the USB audio while using use Zoom to confcall on the internal soundcard (not running JACK), at the same time.

geo_c
Posts: 2495
Joined: Fri Jul 31, 2020 3:37 am
Has thanked: 1794 times
Been thanked: 705 times

Re: Real-time audio processing in Fatdog64

Post by geo_c »

jamesbond wrote: Fri Feb 02, 2024 4:51 pm

Thanks for the feedback, geo_c.

You can run multiple instances of JACK server, one for each hardware device, if you really want to. I can take the input from one device, and pass it around and output it on the second device - both devices under JACK control.

It is definitely possible. I can use JACK to play freetube with Calf equaliser (the exact setup of the first post) output to the USB audio while using use Zoom to confcall on the internal soundcard (not running JACK), at the same time.

I've never done that dual instances of jack, or even heard of it. I'll have to try it sometime. If you combined dual jack servers with alsaloops for non-jack apps, you's be getting what pipewire does out of the box. It might get a bit complicated though!

geo_c
Old School Hipster, and Such

User avatar
dr__Dan
Posts: 74
Joined: Tue Jul 28, 2020 5:06 am
Has thanked: 45 times
Been thanked: 25 times

Re: Real-time audio processing in Fatdog64

Post by dr__Dan »

jamesbond wrote: Fri Feb 02, 2024 8:00 am

But this is a temporary connection and when then ALSA app stops the sound, the connection is lost and when you start the music again, you will have to re-do the connection (not much, only two ports need to be re-configured in the qjackctl graph, everything else stays).

In next iteration of Fatdog (whenever it is released), it will be possible to setup a permanent connection for ALSA apps, so we can save and load the connection again at next start. In fact you don't have to wait for it, because it's so very easy to do it. It can be done manually, or I can post the updated aloopdcfg.sh, if any of you are interested.

I am interested. Thank you for the improvements.

Dan

8 years on with Fatdog64. :D

geo_c
Posts: 2495
Joined: Fri Jul 31, 2020 3:37 am
Has thanked: 1794 times
Been thanked: 705 times

Re: Real-time audio processing in Fatdog64

Post by geo_c »

dr__Dan wrote: Fri Feb 02, 2024 11:08 pm
jamesbond wrote: Fri Feb 02, 2024 8:00 am

to do it. It can be done manually, or I can post the updated aloopdcfg.sh, if any of you are interested.

I am interested. Thank you for the improvements.

Dan

Yes I'm very interested in that also.

geo_c
Old School Hipster, and Such

jamesbond
Posts: 534
Joined: Tue Aug 11, 2020 3:02 pm
Location: The Pale Blue Dot
Has thanked: 71 times
Been thanked: 291 times

Re: Real-time audio processing in Fatdog64

Post by jamesbond »

Here are the steps.

0. Make sure snd-aloop is loaded (modprobe snd-aloop).

1. Please use Fatdog Set Default Soundcard to use aloopd, but do not actually start the aloopd (if it is already running then stop it).

2. Launch qjackctl and configure the JACK as needed (I'm skipping the details because I'm assuming you all know how to do this already).

3. Instead, open terminal and launch "alsa_in -d aloopd -j aloopd". A new "capture device" will show up in JACK's graph.

That's it. Any ALSA apps will now output its audio into JACK's "aloopd" capture device and you can route the audio as you want, e.g. passing it through Calf or other various JACK filters using JACK graph.

I'm withholding the update of aloopdcfg.sh (which would only help to automate step 3), as I'm finding an even better way of doing it, using JACK audioadapter. With the audioadapter, it is possible to grab input from freetube, filter it, and output to two different soundcards at the same time - all within a single JACK instance (see screenshot: the "internal" is my laptop's internal soundcard, while "system" is the USB audio). Connections can be changed on the fly without affecting running applications; jack_mixer manages the individual volume control. I can even mix in the mic input sources (from two different soundcards) if I want to. I wasn't aware that JACK is this powerful until now. I need to test this further. By the look of it, it can certainly do what other audio servers do.

Attachments
xscreenshot-20240203T132703.png
xscreenshot-20240203T132703.png (173.68 KiB) Viewed 337 times
jamesbond
Posts: 534
Joined: Tue Aug 11, 2020 3:02 pm
Location: The Pale Blue Dot
Has thanked: 71 times
Been thanked: 291 times

Re: Real-time audio processing in Fatdog64

Post by jamesbond »

Or you can even go overboard, attach another USB audio (for a total of 2 USB audio + 1 internal laptop speaker) and use Calf crossover to make 3-way speaker system :lol: It's not an everyday setup but just to highlights what JACK can really do. Fun stuff.

Attachments
xscreenshot-20240203T144703.png
xscreenshot-20240203T144703.png (212.84 KiB) Viewed 328 times
geo_c
Posts: 2495
Joined: Fri Jul 31, 2020 3:37 am
Has thanked: 1794 times
Been thanked: 705 times

Re: Real-time audio processing in Fatdog64

Post by geo_c »

jamesbond wrote: Sat Feb 03, 2024 4:56 am

Or you can even go overboard, attach another USB audio (for a total of 2 USB audio + 1 internal laptop speaker) and use Calf crossover to make 3-way speaker system :lol: It's not an everyday setup but just to highlights what JACK can really do. Fun stuff.

The question I have is: are all non-jack apps basically routed to the one snd-aloop output? If so, and you want individual outs on the alsa applications, is it possible to create multiple aloops?

geo_c
Old School Hipster, and Such

jamesbond
Posts: 534
Joined: Tue Aug 11, 2020 3:02 pm
Location: The Pale Blue Dot
Has thanked: 71 times
Been thanked: 291 times

Re: Real-time audio processing in Fatdog64

Post by jamesbond »

geo_c wrote: Sat Feb 03, 2024 7:11 am

The question I have is: are all non-jack apps basically routed to the one snd-aloop output?

Yes in the example.

If so, and you want individual outs on the alsa applications, is it possible to create multiple aloops?

By default there are 8 aloops created when you do the modprobe. So you will have 8 possible inputs (and output) to ALSA apps.

User avatar
wiak
Posts: 3627
Joined: Tue Dec 03, 2019 6:10 am
Location: Packing - big job
Has thanked: 56 times
Been thanked: 994 times
Contact:

Re: Real-time audio processing in Fatdog64

Post by wiak »

Whilst there are lots of ways to skin a cat, and that includes going as close to system level as possible, which has an advantage for some systems including for example embedded (as an ex-electronics-engineer, that was the area I once programmed in). However, for typical computer system users I have a feeling that pipewire will become the most convenient mechanism. The only reason against it would be if for example low-enough latency could not be achieved, but from what I read, pipewire seems capable of similar low-latency performance to jack + alsa?

https://www.tinylinux.info/
DOWNLOAD wd_multi for hundreds of 'distros' at your fingertips: viewtopic.php?p=99154#p99154
Αξίζει να μεταφραστεί;

geo_c
Posts: 2495
Joined: Fri Jul 31, 2020 3:37 am
Has thanked: 1794 times
Been thanked: 705 times

Re: Real-time audio processing in Fatdog64

Post by geo_c »

wiak wrote: Sun Feb 04, 2024 9:47 am

Whilst there are lots of ways to skin a cat, and that includes going as close to system level as possible, which has an advantage for some systems including for example embedded (as an ex-electronics-engineer, that was the area I once programmed in). However, for typical computer system users I have a feeling that pipewire will become the most convenient mechanism. The only reason against it would be if for example low-enough latency could not be achieved, but from what I read, pipewire seems capable of similar low-latency performance to jack + alsa?

Which is true, I was running pipewire-jack at a buffer of 32 quite comfortably. But of course fatdog isn't currently running pipewire, and I believe this aloop information is applicable in that it may solve some persistent connection issues running pipewire-pulse, which I will be exploring further.

Whether running jack, pulse, or pipewire they are all talking to alsa ultimately, so understanding how to get the most versatility out of alsa is an effective way to handle the development and use-cases of these three audio/media frameworkl layers.

One thing running pipewire-jack has showed me, after having used native-jack for years, is how strong a straight jack-alsa system really is, though it takes a little more understanding and configuration to set up.

I think between all the topics we have going on this subject currently, we can get the most out of all of them and push the mulimedia capabilities of all the forum distros forward.

Pipewire will go one level further when it's video stream capabilities are tapped and fully developed, also it's wayland compatibility.

geo_c
Old School Hipster, and Such

jamesbond
Posts: 534
Joined: Tue Aug 11, 2020 3:02 pm
Location: The Pale Blue Dot
Has thanked: 71 times
Been thanked: 291 times

Re: Real-time audio processing in Fatdog64

Post by jamesbond »

Buffer size of 64 is the lowest I can get on JACK for my USB audio. For my internal soundcard it is 32. I wasn't interested in pipewire because in geo_c's other posts he said he was originally running it at 1024 bytes buffer, and later managed to tweak it to run at 512 bytes.

But if pipewire can run at 32 bytes - same as JACK - then perhaps it is worth considering. To that extent I have built pipewire for Fatdog and when time permits will play with it to see if it offers improvements over JACK.

geo_c
Posts: 2495
Joined: Fri Jul 31, 2020 3:37 am
Has thanked: 1794 times
Been thanked: 705 times

Re: Real-time audio processing in Fatdog64

Post by geo_c »

jamesbond wrote: Sat Feb 10, 2024 6:30 am

Buffer size of 64 is the lowest I can get on JACK for my USB audio. For my internal soundcard it is 32. I wasn't interested in pipewire because in geo_c's other posts he said he was originally running it at 1024 bytes buffer, and later managed to tweak it to run at 512 bytes.

But if pipewire can run at 32 bytes - same as JACK - then perhaps it is worth considering. To that extent I have built pipewire for Fatdog and when time permits will play with it to see if it offers improvements over JACK.

Once I learned where to go for it, I set it to 512 from 1024 in the pipewire jack.conf, and the reason for not going lower is that as a general setting 512 is low enough for me to play virtual instruments comfortably but still high enough to run a DAW loaded with 50 plugins without jamming up the processor and getting xruns. And when I mix, I'm running 4-6 plugins on every track, which might be 10-20 tracks, as well as the master bus. The project usually gets very large in the final stages.

But just to see what it could do I set the buffer at 32 for running an instrument or two and a basic 4 or 5 track Ardour project with a few plugins.

So, there are different use cases. For playing virtual instruments in a live setting I would certainly run it at 32. For mixing a large project in Ardour I would run it higher. And it also depends on the particular machine and speed of usb ports etc. Pipewire has no problem with latency that I have noticed so far. The great thing is that some jack apps and tools can set the buffer, so it's easy to change it on the fly without having to edit the config, so that's why I went conservative in the config.

I'm not really missing jack at this point, because I'm still using all the same applications, like the jack_mixer and Carla, and it's just like jack but with even more capabilities easily accessed. In other words there's nothing I was doing using jack that I'm not doing in pipewire, but there are things I'm doing in pipewire that I was not doing just using jack/alsa, like mixing browser audio with jack application audio without using aloop.

EDIT: But I do think using aloop would be a good way to have more control over autoconnections in the pipewire-pulse side of things.

geo_c
Old School Hipster, and Such

Post Reply

Return to “FatDog64”