by captainmuon · 3y ago · 0 comments
I know the Asahi-Linux people are very correct, but I'd be tempted to just throw the Apple libraries into Ghidra and see what they do.
And a completely unreleated thought, maybe it is possible to remove the safetly limits on speakers of other brands and apply the same strategy to get better sound?
> I wonder how they model the energy output of the speakers.
Simple. The speaker codecs (special made for Apple, but e.g. compatible to https://www.ti.com/product/TAS2764) give you current/voltage measurements you can calculate the power from. It's what they call I/V sense.
> In principle you could have a function that calculates the energy of the spectrum and integrate that over time.
Right. You don't want to do the calculation in frequency domain since that would be wasteful. You can integrate the power of the samples straight away (here by multiplying the instantaneous voltage and current, if we didn't have that, we could at least estimate it by assuming a constant resistance of the speaker coils).
> If you put out too much energy, what do you do? Reduce the overall volume, apply a frequency cutoff, or a low-pass-filter?
You model the coil's temperature. If it comes near a dangerous level, you reduce the volume on the particular speaker. You don't need to worry too much about this since usually you don't hit the limits, you are merely guarding against especially nasty sound input.
> I feel there are so many variables here, and it is going to be hard to replicate what Apple does.
We don't need to replicate what Apple does. Though we are stealing the parameters for the coil temperature model Apple is using (at least for some machines).
The Asahi people usually reverse engineer things like the audio system by running macOS under the m1n1 hypervisor, which lets you inspect interactions with the hardware using a Python API
(Nobody does maths with opamps any more, it's less area and lower power to ADC the signals you want and do it in digital. It's also much easier to tune)
- Any number of excellent in-ear monitors under $100 - Truthear Zero ($50)
- Quite a few good-to-excellent headphones under $200, and under $50 if you can run a convolver equalizer for them - Superlux 668B ($35)
- Several excellent powered monitor speakers regularly on sale under $450/pair (JBL 305, 308, Kali LP8v2)
Laptop speakers are for getting your attention from across the room so you can plug in something appropriate.
> And a completely unreleated thought, maybe it is
> possible to remove the safetly limits on speakers
> of other brands and apply the same strategy to get
> better sound?
That’s a really interesting topic. I hope an audiophile
shows up to give some thoughts..
Probably want an audio engineer instead of an audiophile hobbyist, for a more proper and informed opinion. =)However, as an audiophile hobbyist, getting good sound from bad hardware (or excellent sound from good hardware) via DSP is definitely a thing! In fact, it's essentially the reason why anything sounds any good at all these days, and why things like tiny laptop speakers and tiny portable Bluetooth speakers can sound halfway decent. Even inexpensive factory car audio can sound great these days, because you can throw a cheap DSP chip in front of not-very-special speakers.
I would suspect that many laptop manufacturers are doing some hardware/firmware/software magic already, in order to get decent sound from their hardware.
Hobbyists can do this as well. You can buy e.g. cheap speakers, measure their output with a microphone, and create a DSP profile to fix much of what they're doing wrong. The underlying principle here is that "good" sound is absolutely measurable, and it essentially is nothing more low-distortion playback that is tonally correct. The results can sound excellent. Here's an example of the process: http://noaudiophile.com/Micca_Club_3/
However, there are some physical limitations to this. Much of the sound we hear is reflected, not direct, and therefore part of a speaker sounding "good" is that it is emitting "correct" sound in a wide enough angle. If a speaker is shooting correct sound directly at you, but various and incorrect sound off at various angles, the result will not sound great because what actually reaches your ears is going to be a mixture of good (the direct sound) and bad (the indirect, reflected) sound. If a speaker is bad at this, that is not something that can really be fixed by DSP, so you need to get some elements of the physical design correct in the first place.
The software power management aspects of Apple's secret sauce ("you can dump more than max power into the speakers for x milliseconds, but after that, back off") are also beyond the limits of simple DSP solutions. There would presumably need to be some kind of stateful solution there like Asahi is doing.
There are also other things that Apple does in hardware. Their 16-inch laptops actually have six drivers. Two tweeters, and two pairs of dual-opposed woofers. Dual-opposed woofers give you twice the sound pressure and drastically reduce distortion caused via vibration. This of course takes more room, more hardware engineering, more expense, and isn't something we can software our way around. You actually don't see this in commercial subwoofers until you get up around the $2000 price level, though you could also build one yourself for much less if you don't mind DIY work. https://us.kef.com/products/kf92-subwoofer
Acknowledging this lifts you out of the category of "audiophile" into "person who actually knows about audio" ;) There's a lot of what I can only describe as outdated prejudice about what can be achieved with class D systems. Your explanations in this thread are excellent.
> I would suspect that many laptop manufacturers are doing some hardware/firmware/software magic already, in order to get decent sound from their hardware.
Correct, especially in mobile phones. My employer has some products in this area, e.g. https://www.cirrus.com/products/cs35l41/ , which has exactly the sort of speaker protection under discussion done by on-chip DSP.
If you're willing to go in the other direction, and tolerate bigger speakers, you can have very very enjoyable sound from the sorts of dumb big-box speakers folks commonly had in their living rooms up through the 1980s or so.
are you talking about hardware or software DSP?
You could do it either way. Hardware solution like a MiniDSP, although it appears they have unfortunately discontinued their more affordable products. Or a software solution like EqualizerAPO (Windows) or SoundSource (Mac). If I had a pair of decent speakers and a microphone hooked up to my PC
Quick summary.1. You need a calibrated microphone like the uMik from MiniDSP or one from Dayton Audio. That's about $100, though, so that sort of kills the value equation in a lot of situations.[1]
2. You then measure the speaker's output with something such as a free tool called Room EQ Wizard: https://www.roomeqwizard.com/
3. REQ can then output the necessary DSP configuration files, that can be then be used by a MiniDSP, EqualizerAPO, etc. Or it can just tell you the necessary corrections that can then be manually typed into anything that supports parametric EQ settings.
Here's a video fully demonstrating all of that: https://www.youtube.com/watch?v=T1aYsjPc2m4&t=2s
____
[1] There are community efforts to take these kinds of measurements and open source them so everybody can benefit. The largest I'm aware of is these open-sourced headphone measurements (which require a different sort of measurement rig) and corrections: https://github.com/jaakkopasanen/AutoEq/tree/master/results/...
For speakers, there are the measurements and EQ corrections published by places like AudioScienceReview.com and NoAudiophile.com
If you do software EQ and use other peoples' measurements you can do this for $0, without the grunt work of measurements.
Blatant plug: https://github.com/erdewit/HiFiScan