Speaker Support in Asahi Linux
github.com
github.com
I imagine it will be incorporated into other distros soon as a result.
Of course, this will never rival an actual "serious" amp and speakers, but it can drastically improve matters. Anecdotally, my HP laptop has a pretty crappy sound under Linux, but under Windows with the Realtek drivers, it sounds OK. The soundcard itself doesn't seem too bad: if I use a pair of nice headphones or plug it into my dedicated stereo, even under Linux I hear no difference compared to using an external DAC connected through USB.
The speakers safety thing seems like a completely new thing, though.
All sounds like an absolute nightmare to anyone even remotely into audio. But I guess tiny speakers are occasionally useful.
Phones, laptops, tablets. The tiny speakers built into TVs, much smaller than even built-in speakers on CRT TVs used to be. Ear buds of various sorts, and smallish headphones. That’s most audio-listening accounted for (except in cars).
Hell, I’ve got a good hi-fi setup and (separately) a probably-top-couple-percent 7.2 home theater audio situation (in one room… but not on the other TV) and even so I listen to things on tiny speakers more than on big ones.
Hmm... I think you're probably right, but the one thing that gives me pause is the enormous market for Bluetooth speakers. I see Bluetooth speakers everywhere! I suppose most Bluetooth speakers are still "small" in the grand scheme of things, but they're certainly larger than phone and laptop speakers.
Earbuds are similarly omnipresent. I'm not sure it's accurate to classify those as "tiny speakers"; the physics are different, because they only need to be loud enough to hear when they're next to your ears.
It's not only useful for tiny speakers: everything from home audio to big PA installations for concert halls can benefit from DSP optimisations. It's a way to squeeze more sound from the same speakers.
However, most people will probably not go out of their way to use this, and also, having a DSP tailored to the specific speakers and enclosure is nice. But I agree there should be a way to completely disable this, at least when using the line out jack, be it for headphones or an external audio system.
> But I guess tiny speakers are occasionally useful.
They are to me. My laptop is much easier to carry on planes than my audio system, and I don't always like having headphones on, for example when watching a movie in bed.
According to Marcan on mastodon, the DSP is only enabled when you use the internal speakers.
I have a custom-made subwoofer that can hit 12Hz (measured), and creating a DSP profile to compensate for my room + speaker acoustics has significantly improved the listening experience.[1][2]
[1] https://www.hifiberry.com/shop/boards/beocreate-4-channel-am... [2] https://github.com/hifiberry/hifiberry-dsp/blob/master/doc/r...
The hifiberry DSP does primarily three things: - equalization for speaker + room acoustics - customizable crossover frequency for speakers (in my case a 2.1 setup) - loudness equalization across speakers
There may be a latency compensation module, but that's not something I needed in my case.
None of this is rocket science, but audio does sound significantly better after compensation. Specifically, my living room geometry was causing standing waves in the ~200 Hz range, making the low-end sound unpleasantly boomy. The calibrated compensation pretty much eliminated this, without needing to invest in physical sound traps and the like.
This is a fun little project for really not much money. I recommend it to everyone who likes tinkering, all you need is a <$100 measurement mic, REW, and a tiny bit of patience.
EQing out bass if you sit in an antinode is definitely better than nothing, though.
That leaves it up to the laptop vendor to implement hardware to perform DSP (and the quality of this varies tremendously from poor to OK). Apple doesn't use hardware for their speaker DSP (it's all software) and their speakers sound better than anything else out there. Linux now has similar functionality thanks to Asahi, and it will only get better over time.
I don't know how common this arrangement is in other laptops, but it's the kind of hardware/software integration that Apple is known for.
- Bad sound and nothing you can do about it
- No sound at all
- Carry external speakers with you all the time
Where in the past it was impossible to both have physically small devices and good sound, technological advances have enabled us to do more with less. So adding that technology means we can now have better sound than in the past.Rightly or wrongly, Apple does it in software on the CPU but until now this wasn't replicated in linux. So the Asahi project (which is for macs with M1/2/3 CPUs), has added this feature to linux[1] and is working on adding DSP models for each model of Mx Mac. In Asahi Linux Speakers have been disabled by default on all models until this feature as well as the specific DSP for each model is ready. Now they have reached the point where speakers are enabled for the first model, which is a huge milestone.
[1] I originally wrote "linux kernel" but it is actually done in user space, with interlocks in the kernel to fall back to simple aggressive volume limiting.
Do they have a very very conservative profile by default?
Apple provides a system that drives the speakers within those bounds as close to the actual bounds as possible to get the most out of the system that they realistically can.
Asahi is trying to do the same but are choosing a profile that is far more conservative than apple to start with while they get things ironed out. This profile they have is still an improvement over the worst case bounds but it has very sharp/jarring "safeties" that trigger when the system suspects it might be close to damaging the hardware (dropping immediately to a much lower, safe level vs apple's profile which gradually shifts the audio to a safe point without making it obvious that it is doing so).
It’s ok to be quite loud for any one peak for a short amount of time (let’s say 50dB for 10ms) but for indefinite time periods much less is ok (let’s say 30dB but these are totally made up numbers). There are also limits to how much energy you can put into the speaker before it overheats. There also may be some frequencies with different limits (this is total speculation on my part). So the DSP models the behavior of the speakers and tweaks the input to prevent them from overheating (in my understanding). Normally you won’t notice this unless you are trying to play a single tone at max volume. Without this advanced DSP, you would have to just limit the output to 30dB which in practice means high volume parts of your audio are clipped or you limit to a very low volume to have enough headroom to play the louder components of your audio. Considering how loud and good modern macbooks, smartphones and smart speakers sound compared to similar sized speakers from even 10 years ago I think the effect is pretty great.
If it does, can we "import" it to linux?
Unfortunately, this isn't shippable for distros. The biggest issue is acquiring proper impulse-response data. In theory, it has to be tuned per-model, and turning basically requires pro-grade equipment and a recording studio. However, apparently many people assume Dolby is using the same profile for all laptops, so just copy-paste the same file here and there. Not really sure which is the real case.
Anyways, Asahi can ship DSP turned on by default because the distro is specific to Apple. That's how Apple boosts the quality of its hardware, and the same applies to a distro dedicated to it.
[1]: https://github.com/wwmm/easyeffects
[2]: https://stackoverflow.com/questions/27122564/which-version-o...
I’ve been waiting decades for a Linux distro that just buys a few commonly produced laptops that are likely to be produced for a few years, and then tests the crap out of them and applies this sort of polish.
Current gen thinkpads probably would have fit the bill for the last ~30 years, for example. I was hoping the pinebook pro would be this, but it has a few severe hardware issues (suspend battery life, DSP noise) that don’t look like they’ll be fixed. Similarly, the XPS line has the capacitor whine problem, and are based on Intel (which has been exclusively shipping power hungry hot messes for the last 10 years).
If the M[1-3] end up being the models where Linux finally gains stable support for reasonable laptop hardware, then so be it.
I suspect that the laptop market is far too fragmented to make this worthwhile
They make for cheap pickups on the secondhand market too. And Dell already does a bunch of testing/fixing for free as they ship them with Ubuntu.
Top 6 vendors by number of units shipped, 2022
1 Lenovo 24.1%
2 HP 19.4%
3 Dell 17.5%
4 Apple 9.8%
5 Asus 7.2%
6 Acer 6.5%
Others 15.5%
https://en.wikipedia.org/wiki/Market_share_of_personal_compu...https://canonical.com/blog/dell-xps-13-plus-developer-editio...
There are companies that buy and build hardware that supports Linux, and sell it to you with support. Why not just buy from them?
Of course, it lacked Linux support on launch, but that's why the Asahi project is so great. It's providing that missing component of system integration.
Framework, System76, etc. are producing some cool laptops, and I'd consider them if I were looking to buy a new laptop today - but I'm not. I have an M1 Pro MBP in my hands right now, and I have no need to upgrade it any time soon.
You can start that if you want to!
nearly every major distribution does this to some degree and has had for years and years; whether or not you're happy with that level of 'polish' is another thing, though.
So who is going to do all that work?
I bought a laptop that has RGB LEDs in the keyboard. I didn't particularly mind not having control over them on Linux but the problem was they defaulted to the brightest purest blue color imaginable. Booting Windows just to run the shitty manufacturer's software was unsustainable so I reverse engineered it and made a Linux user space driver with libusb.
That took a significant amount of time and effort. Just a bunch of LEDs, it seemed like a simple task. I actually had to record the USB messages with wireshark and then figure out what they meant, correlating the bits sent with my physical inputs. Hundreds of LEDs.
I simply can't fathom what it would take to apply polish like speaker safety to my own laptop. I honestly didn't even know there was a safety risk involved before I read this thread. Do these Linux distributions really have so much money in the bank that users can expect them to buy hardware to test stuff like this on? It's hard enough to ship software that works at all.
Aww, so you don't think other distros will ship this even once upstream is figured out?
Kernels already ship hardware-specific drivers, but I suppose that just comes with the Linux kernel, whereas this needs support on both the kernel and userspace sides...
If a distro is expecting you to install onto the rando asus gaming laptop you got at staples? not going to work.
The thing about M-series apple macs is there are only like 10 models total to record profiles for. You can't realistically do that and ship profiles for every x86 laptop under the sun.
You maintain profiles in a repo and package them like anything else. No one has indicated how this cannot usually be zero config via hardware probing.
That means sitting down in front of every single model with decent measurement equipment and running a test. This doesn't scale, especially not for a distro with limited resources.
It's not like this is hypothetical. https://openprinting.github.io/
it seems like precisely the contrary to an Apple-specific distribution.
There are a fuck of a lot of rando x86 laptops, and you need to record a different profile for every single one of them. That means sitting down in front of every single laptop model you want to ship a profile for and running tests with a measurement-grade microphone and equipment.
Marcan did that for the handful of M-series mac laptops that exist. Good luck physically testing even 0.01% of the x86 laptops that exist.
I have no data on this, but I would guess that the top 10 or 20 best-selling x86 laptops comprise a very significant portion of the overall market. So profile those, ignore the others, and you've helped a lot of users!
And the system needs to be fail-safe, so that the speakers don't get blown out if the daemon crashes or hangs.
---
As a separate topic, I disagree that this isn't shippable for distros. Distros already have a bunch of hardware-specific stuff. Libinput, for example, has a hardware database to correctly handle or work around quirks for all sorts of input hardware.
There's absolutely nothing which would prevent Ubuntu from providing speakersafetyd's hardware database, either as an optional package, or, if out-of-the-box Mac support is important, as a package that's installed by default.
As a complete aside unrelated to the broader discussion, libinput is my nemesis and it has degraded my user experience of Linux.
I hate, hatehatehatehate one finger tap to click. It's a huge misclick generator, and libinput used to have it off by default for good reason.
However, libinput gates all actually useful and not very error-prone gestures like two and three finger taps to right and middle click and multifinger swipes behind having one finger tap to click enabled. You either take it all or you get nothing.
This is a huge regression from the old Synaptics interface which let the user freely assign different actions to taps with different amounts of fingers.
The worst is that it's completely intentional and has been the case for over five years because the old maintainer didn't want to write tests.
I also dislike how there's no global libinput config file. I get that it's supposed to be a library, and the user of the library (GNOME, KDE, Sway, whatever) is supposed to expose those options, but in practice, a lot of useful options aren't exposed to the user. GNOME is especially bad about that.
There are also weird choices, like: when you press down with two fingers and then move those fingers together (double click and drag), the cursor moves at twice the normal speed.
Linux input isn't universally better now than it was a decade ago and that sucks.
And you don't need a recording studio to enable it on more hardware. marcan did the measurements for the MacBooks with a cheap measurement mic.
So you can have great audio on any hardware by just doing the measurements and including them in the asahi-audio package, _in upstream fedora_.
Source: marcan on mastodon[1]
[1]: https://social.treehouse.systems/@marcan/111398502380681345
EDIT: Also, about recording IRS: both the mic and the room environment impact the response data. Using cheap mic in your room does introduce distortion.
However, I realized I was kinda making an assumption that IRS was being recorded for effects. If you're just flattening the response curve, they should work mostly fine. This can become an issue if it's used for effects (e.g. mimicking 2ch Dolby Atmos) because the distortion can be amplified by the environment.
Also, in the long term, using a standardized setup helps with maintaining the quality of IRS. You really want to be able to reproduce the setup, so that you can further improve the data. It's better than subjectively keep fiddling with EQ sliders.
With real speakers or headphones the difference is extremely striking.
If you are interested, there are corresponding frequency response measurements from a measurement microphone in a sibling thread.
The first (DSP processed) clip still sounds much better to me. The first time the unprocessed clip is played it's rather noisy for some reason, that could be room noise picked up in the microphone though. The high end is missing from the second clip almost entirely (anything above 5 khz).
However the DSP clip isn't without significant problems. It sounds distorted to my ear, and slightly pitch shifted as well. It's rather "tinny" sounding. I'd rate both clips extremely annoying to listen to in comparison to the original which seems pretty well mastered if you like this sort of thing: https://youtu.be/ZRtdQ81jPUQ?t=52
It's hard to tell how much of this is due to it being a quick and dirty recording. Also, being able to play audio at higher volumes is supposed to be one of the big advantages of using this DSP chain, since temperature spikes created by transients are managed in software. (Just speaking for myself personally, I've never felt that my non-Apple laptop speakers needed to be louder, even without DSP.)
Each to their own I guess.
One sounds way “fuller” (more bass perhaps) than the other, but I’m just looking at the timeline hoping the torture will end soon.
If the status page is to be believed, it’s getting extremely close to daily driver status for me.
Dell / Realtek / MaxxAudio (not sure who to attribute it to) offers such an implementation with mixed results. Some people go to great lengths to remove it and replace with something that offers a flat response -- personally, I didn't mind the alterations it introduced and the speakers "feel" quieter without it installed.
-----
Our DSP profiles aim to provide a balanced sound, with the features that people expect from high-quality laptop/small-speaker audio. In particular, we aim for:
• A balanced (neutral) tone at moderate listening volumes, with a mostly flat frequency response from a typical listening position
• Reasonably high peak volume with acceptable sound degradation (compression, limiting, etc.)
• "Fake bass" processing to make audible frequencies that cannot be physically reproduced by the speakers, extending the perceived frequency response of the system.
• Equal-loudness volume compensation, so that the sound does not become noticeably tinny as the system master volume is lowered.
[...] Our goal is explicitly not to clone the full/exact macOS audio experience. We consider the macOS speaker DSP processing to be too tryhard.
-----So I suspect Asahi's implementation will be far more conservative than the systems you're referencing. It's also worth noting Marcan is a musician.
- Custom response curves for the built-in speaker as well as some brand speakers/headphones (responsible for the "what did you just plug in?" dialog that annoys many users)
- User-adjustable EQ
- Compression, limiter, AVL, "night mode", loudness: I'm lumping these together in one basket as I don't know what components were in use behind the scenes
- Reverb: for cases where you want to listen to music that comes out of a PVC drain pipe of a concert hall's restroom
- Possibly downmixing multi-channel audio for headphone users, but I'm not sure in this one either.
Anyway, once speaker support arrives for the M2’s I’ll try switching back to Linux for my daily driver (almost all my dev work happens in an ARM VM under MacOS as it is…)
i have seen all the "tables showing compatibility" but how is it in real life? i should i buy a machine solely to daily drive asahi?
Missing features, so you can decide if those matter to you:
- improved external monitor support
- hardware video decoding - mainly for better battery life, because the CPU is more than fast enough for real-time software decoding. (This is work-in-progress.)
- fingerprint sensor
- No sound from the speakers (unless you have an M1 as can be seen from this post). But headphones work.
- No external screen support
- No Thunderbolt
- No Fingerprint sensor
- No Video decoding/encoding acceleration. But the CPU is strong enough to easily keep up with 4k 60FPS. So you "just" pay for it with shorter battery life.
- No support for some important GPU APIs (Vulkan, OpenCL, newer openGL) which some application you use might need.
The above list is the current state and even a few months from now will probably look different.
I suppose if you're using headphones anyway (since the M2 doesn't have speaker support) they may come with a microphone, but they may not...
I guess there's reason to wonder whether malware might also be able to set the whole machine on fire.
that was one of my favorite parts of Mr. Robot
It's not something laptop specific: you can damage any pair of plain regular speakers (say hi-fi speakers) by sending them the right (meaning wrong) audio signals to them: burn the voice coil, fry the tweaters, etc. Audio engineers take certain precautions to what they send the speakers.
Laptop speakers have software control of the speakers for protecting them from this, and to allow better performance as long as the components aren't overheating, etc.
But also, there have been many bugs in the past which bypassed SIP.
You could for example blow all the efuses in anything with signed firmware versioning - meaning there would be no firmware release that will boot anymore.
You can also typically increase system voltages to cause failure, erase flash so many times it fails in a few minutes, overwrite bootloaders in peripherals so they can't be fixed without a soldering iron, etc.
https://social.treehouse.systems/@marcan/111379933565349212
https://social.treehouse.systems/@marcan/111369113203280839
https://social.treehouse.systems/@marcan/111368139961624028
https://social.treehouse.systems/@marcan/111363323102625920
https://social.treehouse.systems/@marcan/111356347520217702
https://social.treehouse.systems/@marcan/111351807108120657
https://social.treehouse.systems/@marcan/111322854564301468
https://social.treehouse.systems/@marcan/111312763506327704
https://social.treehouse.systems/@marcan/111305404286878529
https://social.treehouse.systems/@marcan/111275789631652315
https://social.treehouse.systems/@marcan/111274712520670628
https://social.treehouse.systems/@marcan/111274302586522319
(And if not that, I am mildly surprised ChromeOS/Chromebooks don't do much of this either.)
A good example of different approach is laptops branded with "Harman Kardon" speakers - Harman-Kardon has a patent on exactly this but involving separate DSP running transparently to the OS. Similarly there are various other solutions to improve sound quality of small speakers being done, and for some of that modern SoCs are bringing in dedicated DSPs onboard.
(I still do genuinely wonder what's going on inside of SOF on modern Intel laptops, too. That's not separate from the chipset and I don't think it gets tuned for specific laptop acoustics. So what does that do?)
I’m not an expert, but probably used for speaker DSP as well as mic/speech processing (think for Cortana/etc).
Manufacturers of laptops probably provide their own firmware to load onto these cores as part of a driver.
[0] https://www.cadence.com/en_US/home/tools/ip/tensilica-ip/hif...
Some of the older Thinkpads — W510, T400, and T410, so beloved and praised by Linux enthusiasts, used to suffer from the same problem — their speakers could get destroyed after a few minutes of playing audio. Just wondering if Lenovo’s drivers for Windows 7 included similar safeguards.
You're right that if you're missing that context, it's kind of hard to tell just from this issue alone.
So software devs are going to drive the speakers past the worst-case safe volume level that was presumably set by hardware engineers? And they are going to do it with software running in a OS that isn't realtime safe?
Anyone else see a problem here?
Also-- does anyone know what Asahi is using to test the safety of what they're doing?
No.
The worst case safe volume levels are levels determined by the speaker manufactures that if you never exceed, you can never harm the hardware (due to overheating, etc).
You can and should exceed those levels to use the hardware as it is intended by the manufacturers however if are doing so, you are now moving from a static system (one set of safe levels) to a dynamic system where the safe levels are determined by a multitude of variables and as such you need to have software or hardware monitoring those variables to keep the system within those safe bounds.
If you keep careful track of the audio going through the speakers and the energy in each frequency range, you can figure out exactly what the temperature is at any given moment and make sure it stays under the limit. However, this requires a ton of math.
Alternatively, you can just put a hard cap on the volume, such that no combination of frequencies could ever overheat the speakers. This is safe, but sounds like crap. It's a far, far less nuanced way to do things and results in restricting how hard you can drive the speakers far more than is actually nesisary.
How it works with the kernel side of things: https://social.treehouse.systems/@marcan/111398084943456556
but so far no finally usable implementation exists even for m1 macbooks and they age quickly, and I doubt people will see anything usable in the end (yeah, you might get a fully working Linux on your old dusty m1 when you buy m7, happy?).
so far it is achievements for the sake of achievements
so far it is achievements for the sake of achievements
We are people, and we need to feel that our hard work isn’t for nothing. Sharing achievements and getting some praise for it is one way to keep our ambition.Asahi devs are reading these comments. Don’t shit on their work for no good reason.
> so far it is achievements for the sake of achievements
People are daily driving Asahi today, so that's incorrect.
I'm not sure what you mean, I've been running Asahi on my M1 for about a year now. I have enabled sound (without the safeties, but I'm not listening to anything remotely loud) and the only thing annoying is the lack of microphone (I have to plug headphones when I need a micro).
It's been totally usable for at least a year.
> Our implementation, speakersafetyd, monitors feedback signals from the amplifiers, estimates speaker voice coil temperature using a two-stage thermal model, and reduces the hardware speaker volumes when the speakers get too warm. We also have kernel-side interlocks to disable or limit speaker volumes if speakersafetyd is not running or non-responsive.
This is the only part that seems to need to be low-level, anything else could be done at a higher one, generally EQ type settings like 'loudness'.
It’s likely much easier for the open source people to do the work to deal with the underlying physics once, and then port it to all hardware. The laptop models are all essentially the same (they have a few electromagnets, cones and a few sounding boards). Each one has different parameters in their mostly-linear response curves. My guess is that after the first few models work well all the others will rapidly fall into line.
Something similar happened with printers 20 years ago. The open source stack implemented state of the art dithering and font hinting once and ended up producing higher quality output than the commercial windows drivers for the same printers.
But that already is the only part that is low level. The EQ stuff is done with PipeWire.
I guess/hope amplifier clipping is also accounted for, as the sudden rise in harmonic content can easily damage tweeters (which I think macbooks have?).
> These [DSP profiles] are all techniques that are in wide use in consumer microspeaker systems in tablets and phones, though sadly not common on laptops from most non-Apple brands.
As anyone who has bought a laptop less than 10 years old can attest, practically _all_ laptops ship with "DSP effects for tiny speakers", to varying results. Microsoft has even standarized an API in Windows 10/11 so that you literally can shop for different implementors in the Windows store (e.g. Sonic, B&O, etc.).
> EasyEffects
Article itself mentions previous work on DSP effects...
> we also have the world's first (as far as we know) open source "smart amp" implementation.
Old Nokia devices shipped with xprot which is about a decade old. Speaker protection, DSP, noise cancelling, etc. back when pulseaudio was just renamed from polypaudio. https://blog.linuxplumbersconf.org/2009/slides/Jyri-Sarha-au...
(And all of this is ignoring the bunch of Android stuff which while Linux doesn't classify as "desktop Linux").
This has never existed as an OOTB experience. In Apple's case, it's absolutely necessary to avoid blowing up the speakers - hence why they disabled speaker output before the audio chain was done.