Like with almost everything else too, when setting up Linux for audio work, NixOS could be the ideal solution for the unneccesary decision between control/customization
and reproduceability and could become the go-to OS for these kind of tasks.
Right now though it's counter-intuitive and hacky to setup an hybrid system via NixOS configuration, even more than on many other distros.
[ ] re-invent a more unified but also more flexible sound configuration (deprecate at least some of: hardware.pulseaudio, sound.mediaKeys, sound.extraConfig, services.jack.alsa, services.jack.loopback, nixpkgs.config.pulseaudio), rethinking audio backend composing, make sound backends able to depend on - instead of fighting against each other.
[ ] replace pkgs.jack2: Distinct between jack2 and jack2dbus, (pkgs.jack2 should be normal jackd and not jackdbus, which should be called pkgs.jack2dbus,
and the confusing plain alias pkgs.jack2Full should be deprecated or re-assigned.
[ ] jack2: 1.9.12 -> 1.9.13 releases [first release after two years, upstream 11d ago]
[ ] init/upgrade/repackage/integrate: zita-* jack tools
[ ] integrate and obsolete https://github.com/musnix/musnix
[ ] improve nixpkgs.config.jack, nixpkgs.config.pulseaudio, etc.
[ ] sort/sub-categorize & upgrade some audio pkgs in nixpkgs
[ ] first-class support for TidalCycles, [Vivid]
(https://hackage.haskell.org/package/vivid), [SuperDirt]
(https://github.com/musikinformatik/SuperDirt)
and friends/dependencies, tested in [neo]vim & Atom,
(won't start bothering with emacs for this)
[ ] optimally package real-time kernel (+ nvidia-unfree support ?)
[ ] optimally solve https://github.com/NixOS/nixpkgs/issues/6860
[ ] HTML 5 web browser with Jack support
[ ] anything regarding Mac OSX
[ ] persuade the author of this great piece of software to set it open-source:
https://cancel.fm/ripcord/ (Discord alternative client, based on Qt and ALSA) Author's Official Discord Server xD
More to come...
random / related / cinda kool:
https://tidalcycles.org/index.php/Welcome
https://github.com/tidalcycles/Tidal/wiki/Notes
https://veda.gl/
https://butterchurnviz.com/
Are you aware of https://github.com/musnix/musnix.git ?
I choose NixOS for that same exact reason: it's the perfect DAW OS.
I've been happily using it as such since 2014.
Could you say a bit more about what you mean by:
As for your advice questions:
Are you aware of https://github.com/musnix/musnix.git ?
Are you aware of the fifth paragraph of my "What I'm currently starting to work on" list?
My plan is to make musnix configuration directly available in nixpkgs, so that it gets more attention of contributors, of course I'd mention the source in every file and of course those changes would become their own git branch and of course I will mention it to musnix authors before I push those changes to Nixpgs. IMO, it's just not the right kind of Nix expression that should be staying outsourced in another repository. There are no real rapid changes like in firefox nightly and it's not a lot of complex, interdependent or unfree code. Look for example at the environment settings for LV plugins or rtirq.
The kernel will be the last though that I will integrate of this list.
Mac OSX: very general question, so I'm gonna give a very general advice:
Don't use closed source software, at all! ;)
I agree, my idea was to completely erase the Mac related code, that other contributors later, if necessary, add again as an automatic overlay instead of direct changes to the expressions.
I think this seperation of NixOS-related stuff and non-NixOS-related extra code should be done with the whole nixpkgs repo, will open an issue about that if not already done already.
which zita tools are we missing or can be upgraded?
for example i see zita-njbridge, but where is zita-ajbridge.
The offical Discord client sucks because it works with neither Alsa nor apulse, only pulseaudio, and because it's written in HTML and javascript, it's slow and inefficient. I just wanted to mention, maybe we could even get the author of an alternative, Qt- & Alsa-based client to release the source, because he can't really have a financial incentive, and it would accelerate Ripcords development extremely. I would for a example add Jack connectivity then.
@MDeltaX do you have an idea how PipeWire will fit into your plan? It seems to be the solution media processing and it's currently being used for video capture on wayland (sway, KDE, Gnome) and will be available in desktops that move away from X11. It would be nice to use it as a foundation and put Jack/Pulse on top of it. But I'm not at all familiar with the whole Linux audio situation.
@ivegotasthma To be perfectly honest, thinking of PipeWire, this comes to mind...
;)
@magnetophon on one hand yes, on the other, it provides a lot of benefits and it's not just another standard. Its aim is to be interoperable with other technologies in the same space. https://github.com/PipeWire/pipewire/wiki/FAQ
@MDeltaX says:
integrate and obsolete https://github.com/musnix/musnix
@magnetophon says:
I'd also like musnix to be integrated, but even though I started it, @henrytill did most of the work, and he feels it's not ready for integration. Maybe open an issue over there?
Just wanted to chime in and say that I currently have no reservations about migrating musnix or adding a musnix-like config to nixpkgs, if someone is willing to take on the task of the migration and maintenance of such a thing. On the contrary, that would be fantastic!
I haven't had as much time to maintain the project recently, and have had to rely on the work of contributors, so I am pleased to hear that @MDeltaX is ready to carry the torch and obsolete us.
Good to hear, thanks @henrytill!
Sorry for the delay.
Great to hear that @henrytill !
I just very recently finished my own setup to a degree I'm content with, it uses
jack2 (w/o dbus) -> zita-ajbridge -> snd-aloop -> module-alsa-(source/sink) -> pulseaudio
so that a system-run jack and a user-run pulseaudio work independently from each other, which works and sounds very well. (module-jack-sink wasn't reliable enough in my tests.)
My configs also include
I hope to find the time to push all of it in the next days to then further refine it to modules & overlays that can be successively merged into nixpkgs.
Great, hope you'll manage to push soon!
Any news on this?
@MDeltaX wrote:
I just very recently finished my own setup to a degree I'm content with
...
I hope to find the time to push all of it in the next days
Exciting stuff! Before you've pushed, are you comfortable sharing your configuration.nix file(s)?
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/declarative-audio-config-using-jack/5458/1
Exciting stuff! Before you've pushed, are you comfortable sharing your configuration.nix file(s)?
Update: I found the config that @magnetophon uses, and have emulated some of its top-level .nix files, but still can't use JACK.
Hey, well, I had got night terrors because of the high dependency on pulseaudio and the double-resampling.
I've been experimenting further, with disabling pulseaudio, but that requires too much fine-tuning, my goal is a plug-and-play experience, and some apps or bluetooth speakers don't work at all.
Right now I'm setting up a minimal no-resampling system pulseaudio configuration with static alsa devices and bluetooth.
After that I'll be confident with releasing it.
Expect a usable nixpkgs overlay, with batteries-included jackd, finally today!
@JeffreyBenjaminBrown Some commensts on your audio.nix:
Did you just copy the soundcardPciId or did you run the command to find it?
I have bad experiences with jackdbus; I just start it manually.
So maybe try disabling the service and configuring/starting it with qjackctl.
Speaking of which: you don't need the packageOverrides unless you want to run 2 qjackctl instances on the same x-server. Unlikely.
Note: the only suggestion I made that actually might help with your problem is to start jack via qjackctl.
Lemme know how it goes.
Get your jackd settings (to be set in the qjackctl GUI) from elsewhere, for example the Arch Pro Audio wiki page.
Lemme know how it goes!
@magnetophon, per your suggestion, I'm responding here to everything you wrote to me in other issues.
I did not realize latency and stability are all Musnix is for! I thought it configured stuff like JACK, ALSA, and pulseaudio for you.
If I'm not using Musnix, should I still set the PCI ID and the irq names? If so, how?
At the moment the musnix rt kernel is broken, and I managed to fix it in a hacky way, that only works for one kernel at a time. I chose to "fix" the one that unstable non-rt is using.
So if I do end up needing an RT kernel, should I first switch from nixos-19.09 to nixos-unstable, and from nixpkgs to nixpkgs-unstable? (That's how I'm interpreting the Wiki page on channels.)
I've tried building the 4.19 rt kernel a couple times using Musnix, and sure enough, after about an hour it breaks. I was surprised that it has to repeat all the full hour of work each time -- I thought Nix was in general very conservative about maintaining intermediate work until instructed to collect garbage explicitly.
I wrote a synth in Haskell designed to be triggered by a monome grid controller in realtime. Latency in that context does matter to me. (My other main music coding project, a fork of Tidal with a more flexible representation of time and events, doesn't require low latency, just good timing.)
I missed a question.
Did you just copy the soundcardPciId or did you run the command to find it?
I used the first eight characters of the result of lspci | grep -i audio, per the musnix readme.
If I'm not using Musnix, should I still set the PCI ID and the irq names?
No, those are musnix settings.
So if I do end up needing an RT kernel, should I first switch from nixos-19.09 to nixos-unstable, and from nixpkgs to nixpkgs-unstable?
No, if anything, the other way around. I think the kernels are actually only broken for unstable.
Also: the nixos version is what determines the version of everything you configure in configuration.nix, and the nixpkgs version is for everything you install ad-hoc, via nix-env.
So no need to change both.
I thought Nix was in general very conservative about maintaining intermediate work until instructed to collect garbage explicitly.
Nix keeps all finished store paths until garbage collected. There's no point in keeping unfinished and/or broken paths, so it doesn't.
Latency in that context does matter to me.
Fair enough. Still: give it a go without a complicated setup first.
Read up on jack and how to set it's latency.
You didn't reply on the main point though: did you get jack running?
pulse is being pita, one day delay.
@MDeltaX looking forward to it!
did you get jack running?
I did! Now I have a new question :)
My new setup and procedures are described in the last section of this comment, in case they are of archival interest.
I can start Qjackctl and get Supercollider to make sound. But it's still true that if I try opening Cadence it tells me "jackdbus is not available" and grays out all choices under System. (That's true whether or not Qjackctl is running.) Side question: That seems strange, because I thought Cadence was just a heavier alternative to Qjackctl when it came to managing JACK.
On my old Ubuntu system I used Catia for routing -- e.g. to send soundcard input 1 to the microphone track in Ardour. Catia can be launched as a standalone app or from Cadence. But now, either way I launch it, Catia says, "JACK is not available in this system, cannot use this application."
Here's a [permalink to my latest config](https://github.com/JeffreyBenjaminBrown/nixos-experiments/tree/1e8a24018ab39f8a57bc8ea5381213fb9a5dd3cb
I'm no longer using musnix. I also disabled these lines that I had copied from @magnetophon's config:
# services.tlp.enable = false;
# services.jack.jackd.enable = true;
I believe the entirety of my audio-related settings are now these:
security.sudo.extraConfig = ''
jeff ALL=(ALL) NOPASSWD: ${pkgs.systemd}/bin/systemctl
'';
sound.enable = true;
nixpkgs.config.packageOverrides = pkgs: rec {
qjackctl = pkgs.stdenv.lib.overrideDerivation pkgs.qjackctl (
oldAttrs: { configureFlags =
# "fix bug for remote running" (says magnetophon's config).
# Allows you to run multiple instances; probably unnecessary.
"--enable-jack-version --disable-xunique";
}); };
(The qjackctl override is harmless, right?)
Get your jackd settings (to be set in the qjackctl GUI) from elsewhere, for example the Arch Pro Audio wiki page.
@magnetophon, you meant this page, right?
I checked /proc/asound/card0/codec#0 and every device listed supports 44.1 kHz (each line includes the word "rates").
I'm sure there are better configurations -- for instance, I'm using way more frames per period than the Arch wiki suggests as a reasonable starting point -- and I'll work on that once I'm in a position to feel it. But anyway these settings got SuperCollider to be audible:
Congrats on getting sound!
How do you do routing?
With qjackctl.
(The qjackctl override is harmless, right?)
I think so. It almost certainly is pointless though!
you meant this page, right?
Yup, that's the one!
I can live code! Montevideo lives again!
But I'm running into, I think, a permissions problem using SuperCollider.
SuperCollider is producing the following complaints before starting:
Cannot lock down 82280346 byte memory area (Cannot allocate memory)
...
Cannot use real-time scheduling (RR/5)(1: Operation not permitted)
Then it starts as normal, but with 11ms output latency -- pretty high. And I'm worried that if I start synths of any complexity (right now it's just a sine wave) it'll run out of memory. In fact I think that's happening -- patterns that used to run fine on the old system are now seeing dropped voices.
82280346 bytes is less than 80 MB, so this seems like a permissions problem, not a resources problem.
On Ubuntu, apparently, the solution is to modify /etc/security/limits.conf -- which file doesn't exist on my system.
Here's waht looks like a related NixOS issue, but I see no way to use security.pam.loginLimits to specify a particular group.
This probably doesn't matter, but I'm running a tiny bash script that calls SuperCollider as described in the documentation for vivid-synth (a Haskell API for SuperCollider).
export SC_JACK_DEFAULT_INPUTS="system"
export SC_JACK_DEFAULT_OUTPUTS="system"
scsynth -u 57110
[jeff@jbb-dell:~/code/music/montevideo]$ bash sc-start.sh
[jeff@jbb-dell:~/code/music/montevideo]$ bash sc-start.sh
Cannot lock down 82280346 byte memory area (Cannot allocate memory)
JackDriver: client name is 'SuperCollider'
SC_AudioDriver: sample rate = 48000.000000, driver's block size = 256
Cannot use real-time scheduling (RR/5)(1: Operation not permitted)
JackClient::AcquireSelfRealTime error
JackDriver: connected system:capture_1 to SuperCollider:in_1
JackDriver: connected system:capture_2 to SuperCollider:in_2
JackDriver: connected SuperCollider:out_1 to system:playback_1
JackDriver: connected SuperCollider:out_2 to system:playback_2
SuperCollider 3 server ready.
JackDriver: max output latency 10.7 ms
systemd-cgtop showsIn the NixOS manual chapter on control groups it mentions that running systemd-cgtop will show how much memory groups are using. If I run that, I don't see the jackaudio or audio groups anywhere in that list:
Control Group Tasks %CPU Memory Input/s Output/s
/ 793 34.6 5.6G - -
user.slice 627 32.5 4.8G - -
user.slice/user-1000.slice 623 32.5 4.7G - -
user.slice/user-1000.slice/session-2.scope 621 32.5 4.7G - -
system.slice 85 4.3 633.7M - -
system.slice/display-manager.service 6 3.6 251.8M - -
system.slice/docker.service 30 0.6 191.6M - -
system.slice/rngd.service 1 0.0 4.5M - -
system.slice/NetworkManager.service 4 0.0 15.6M - -
system.slice/ModemManager.service 3 - 6.9M - -
system.slice/cups.service 1 - 7.4M - -
system.slice/dbus.service 1 - 9.9M - -
system.slice/dev-hugepages.mount - - 372.0K - -
system.slice/dev-mqueue.mount - - 32.0K - -
system.slice/nix-daemon.service 5 - 5.9M - -
system.slice/nscd.service 11 - 2.7M - -
system.slice/polkit.service 8 - 18.0M - -
system.slice/sys-kernel-debug.mount - - 12.0K - -
system.slice/system-getty.slice 1 - 904.0K - -
system.slice/system-getty.slice/[email protected] 1 - 904.0K - -
system.slice/system-systemd\x2dbacklight.slice - - 112.0K - -
system.slice/systemd-journald.service 1 - 38.9M - -
system.slice/systemd-logind.service 1 - 2.2M - -
system.slice/systemd-timesyncd.service 2 - 1.5M - -
system.slice/systemd-udevd.service 1 - 34.7M - -
system.slice/udisks2.service 5 - 11.9M - -
system.slice/upower.service 3 - 4.3M - -
system.slice/wpa_supplicant.service 1 - 4.4M - -
user.slice/user-1000.slice/[email protected] 2 - 2.8M - -
user.slice/user-175.slice 4 - 93.8M - -
user.slice/user-175.slice/session-c1.scope 2 - 90.3M - -
user.slice/user-175.slice/[email protected] 2 - 3.4M - -
@JeffreyBenjaminBrown Well, now would be a good time to look into musnix.
You mean including the RT kernel, or would it do me any good even without that? (Building the RT kernel isn't working for me, as described on this comment to a preexisting thread about the PREEMPT option.)
First see if you can get it working well enough without the kernel.
Using musnix should fix the errors you mentioned.
musnix should fix the errors you mentioned
It did! Thanks!
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/declarative-audio-config-how-to-start-and-maybe-use-jack/5458/3
@MDeltaX Any updates?
Am I the only one that sees a pattern in the way several jack clients fail to connect to the jack server? I'd like to contribute to this overall effort if we can get resolution to that.
I'd also like to get Tidal onboard!
Hey guys, checking in again. I have a built and running version of 5.6 running with the RT_PREEMPT patchset. You can see the overlay I use in my personal configuration here, but it's obviously not fit for nixpkgs inclusion as it is. As you can see from the overlay, the upstream patch expects a change to the modDirVersion so adding it in a programmatic way would require more careful work than most patches require. For the moment I don't want to do this, but if anyone is either interested in using this or helping write it my mind could be changed.
@6AA4FD Thanks! Could you tell us a bit more about that code?
For example what's the difference with the musnix kernel, apart from the version?
What is polyphone?
@magnetophon It's really just a version bump. It also overrides the modDirVersion so I can use the fix version (y in x.x.y) nixpkgs has even if it's different from the patch which might be inadvisable. Is adding -rtX to buildLinux.version fixing the modDirVersion issue in musnix?
The rest of the differences are just pruning the deadline patch, getting rid of kernel.optimize (you should probably package that kind of thing as a kernel patch with an extraConfig attr), getting rid of latency_top. Debatably either "cleaning up" or lazily removing useful stuff.
Polyphone is irrelevant to the kernel, this is just the overlay for my whole audio configuration module. It's a program for writing .sf2 files which is useful for some sampling workflows if you want to program them with midi. Think water droplets or desk slaps.
Can someone please post a complete sound configuration for using Jack, with QJackCtrl, etc, possibly with support for multiple input and output devices? I'm in a place right now where I just feel there is no hope for me :)
I would gladly, but it hasn't worked for me for months. I'm stranded back
on a very old generation.
On Tue, Oct 27, 2020 at 10:16 PM Dustin Lacewell notifications@github.com
wrote:
Can someone please post a complete sound configuration for using Jack,
with QJackCtrl, etc, possibly with support for multiple input and output
devices? I'm in a place right now where I just feel there is no hope for me
:)—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/NixOS/nixpkgs/issues/71283#issuecomment-717651263,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AABUYZ7KENQYIG5LIZSWRTTSM55I5ANCNFSM4JBYLEUQ
.
--
"I have delusions of grandeur. I believe myself to be Steve Jones"
@dustinlacewell What is it that you want, exactly? I'm using NixOS with jack, QJackCtrl, all the musnix tweaks and a realtime kernel. Is that what you want? What problems are you having?
@sjfloat What doesn't work for you on the newer generations?
Here's my config. I use JACK and QjackCtl. I have to switch between PulseAudio to JACK manually by starting and stopping QjackCtl, which application I open manually each time I boot. I don't know if that's optimal but it works.
The repo also includes a lot of stuff to ignore that's just me learning NixOS.
@JeffreyBenjaminBrown
I have to switch between PulseAudio to JACK manually by starting and stopping QjackCtl, which application I open manually each time I boot. I don't know if that's optimal but it works.
Have you ever tried starting QjackCtl as pasuspender qjackctl? It should stop PulseAudio, and restart it as soon as qjackctl is stopped.
pasuspender qjackctl... should stop PulseAudio, and restart it as soon as qjackctl is stopped.
That's already what happens. I launch qjackctl from KDE's launcher in the corner, and nothing changes until I press play on QJackCtl, at which point JACK is on and PulseAudio is off, and then when I stop QJackCtl the reverse happens.
Most helpful comment
Hey, well, I had got night terrors because of the high dependency on pulseaudio and the double-resampling.
I've been experimenting further, with disabling pulseaudio, but that requires too much fine-tuning, my goal is a plug-and-play experience, and some apps or bluetooth speakers don't work at all.
Right now I'm setting up a minimal no-resampling system pulseaudio configuration with static alsa devices and bluetooth.
After that I'll be confident with releasing it.
Expect a usable nixpkgs overlay, with batteries-included jackd, finally today!