Fortitude Posted December 30, 2021 Share Posted December 30, 2021 Hello everyone, I’m finishing up an AppleALC patch for my Alienware Area 51m R2 laptop, and was wondering if anyone on this website has had experience with AppleHDA’s signal processing parameters?. I’ve got a significant amount of audio production experience, and feel that I’m very capable of doing an excellent job if I had some insight: My speakers currently sound like a vintage radio, and I’d specifically like to apply a ton of equalization to my signal. I’ve generated a template for my internal speakers, and was hoping to translate this data into my layout file: It seems that this should be possible to do. The problem is that I cannot find information on AppleHDA's signal processing anywhere (at least in English), and I’d imagine that someone out there has to know how the EQ parameters work other than the software engineers at Apple. The good news though is that I was able to reverse engineer the names of the parameters by using Ida Pro, and they seem to be almost identical to what you’d find in a Logic Pro stock EQ plugin. However, I have yet to understand what the values for the parameters actually mean because the numbers that I’m seeing in different layout-ids look like gibberish to me: 2 - Channel Select 3 - Band Index 4 - Bypass Band 5 - Filter Type 6 - Frequency 7 - Q 8 - Gain Has anyone figured out what the parameter values mean, or if there’s an associated algorithm with it? I'm used to dealing with decibels/hertz/etc, and don't know what the heck is going on with these numbers! I’m surprised that no one’s asked a question like this before (at least in English as far as I can tell), and I don’t know if that’s because no one knows what the parameters mean, or if there’s a writeup in another language. Link to comment Share on other sites More sharing options...
Guest 5T33Z0 Posted December 31, 2021 Share Posted December 31, 2021 Some of the EQ curves (especially 1 to 4) you want to apply to the whole output are pretty drastic and unreasonable from am audio engineering perspective. Curve 6 is just a gain change… I wouldn't use an EQ Preset for that. I don't know if AppleALC even supports applying EQ curves. From my understanding, all apple ALC does is handling the routing from the Codec to the physical outputs of the device, so I don't know where the data for these EQ curves (once converted) woul/could/should be entered. But I am pretty sure @MacPeet knows more about that. Link to comment Share on other sites More sharing options...
MacPeet Posted December 31, 2021 Share Posted December 31, 2021 (edited) Ich antworte hier mal in meiner Sprache. Es ist so, wie @5T33Z0 schon geschrieben hat, in der AppleHDA, bzw. AppleALC werden ja nur die Knoten für's Audio bereitgestellt. Feineinstellungen sind hier kaum bis wenig möglich, ein wenig vielleicht im Audio-Midi-Setup. Die Zahlen in AppleALC sind ja nur die PinConfig's und Knotenketten zum Onboard-Audio, was ja ohnehin analog Audio ist. Wenn die LayoutID schlecht ist, dann kann der Output an den Boxen schon mal schlecht klingen. Vielleicht wäre hier SPDIF (Digital-Audio) eine bessere Wahl. Für den Musikbereich wäre sicher auch eine OOB-USB-7.1-Lösung besser, denke ich. Da gibt's ja einiges. Mit EQ kenne ich mich aber auch nicht aus, wobei dies ohnehin eine Sache von Zusatzsoftware ist. Ist bei Windows zwar teils schon in die Treiber mit eingebaut, ist aber letztlich auch nur Software. Ich glaube nicht, dass Du EQ-Werte in der AppleHDA, bzw. in der AppleALC konfigurieren kannst. Edit: Hat der Laptop evtl. auch eine Bassbox, welche nicht konfiguriert ist? Vielleicht klingen die Boxen deshalb so schlecht, weil nur Speaker l/r gehen ohne Bass. Edited December 31, 2021 by MacPeet Link to comment Share on other sites More sharing options...
Fortitude Posted January 2, 2022 Author Share Posted January 2, 2022 Signal Processing is literally built into the AppleHDA kext, and it can be configured in the layout(#).xml file. However, there seems to be no information publicly available on how it works. By using Zlib, I’ve extracted a prime example from the AppleHDA kext on macOS Big Sur (layout-7) which contains several instances of DSP processing on a pair of speakers: You can clearly see that for the equalization, you’re allowed to add as many “filters” as you want in order to alter a signal. Trial and error seems to be the way to calculate the values for 2-5 (this part doesn’t seem very brutal), but 6-8 need to be reverse engineered from the AppleHDA source code itself (this is where I could strongly use some help). I derived the parameters for the equalization from an AppleHDA plugin called “DspFuncLib.kext,” which is stored in: /System/Library/Extensions/AppleHDA.kext/Contents/PlugIns This kext appears to be responsible for DSP processing on certain layout-ids. By using Ida Pro (or any similar program), you can decompile the executable stored in: /System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/DspFuncLib.kext/Contents/MacOS And you will see that along with EQ, there are many other signal processing elements available (similar to plugins in Logic Pro) that you can use in order to master your inputs/outputs, and many functions to describe how they work. There appears to be specific functions within the DspFuncEQ class that tell you what the equalization parameters stand for, and give you the calculations necessary. I have yet to tinker with the values for these parameters, and reboot my computer a bajillion times, but here’s my initial assumptions for 2-8: ChSelect - Lets you select left/right channel, and possibly both (inputs mainly appear to have a value of 2 while output values are mainly 0/1). BandIndex - Sequential parameter (dependent on ChSelect parameter) which seems to increase with more filters. BypassBand - Enables/Disables Filter FilterType - There’s five types within a Logic Pro equalizer, and technically eight are available within the plugin. I have no doubt that they’re the same over here. Frequency - Originally in hertz and converted using an algorithm. Q - Originally a decimal value that’s less than 1 and converted using an algorithm. Gain - Originally in decibels and converted using an algorithm. I’d love it if any AppleHDA/AppleALC programmers within the community are interested in working together with me in order to solve this mystery, and report their findings. This is because I’m not the best reverse engineerer in the world, and still have plenty to learn. Overall, I’d love to write a guide in the future on AppleHDA’s signal processing, but because I’m assuming that this is unexplored territory, a lot of testing will be involved first. Link to comment Share on other sites More sharing options...
Rocky12 Posted January 2, 2022 Share Posted January 2, 2022 maybe you can gather some information Link to comment Share on other sites More sharing options...
Fortitude Posted January 11, 2022 Author Share Posted January 11, 2022 (edited) I’ve got exciting news to share with everybody, I solved the mystery, and managed to EQ the hell out of my computer! (I'll eventually submit my patch to the AppleALC repo, but I have to iron out some bugs and run some additional tests first.) In conclusion, CoreAudio contains a 32 bit DSP processor, and accepts floating point values represented as 32 bit signed integers. It looks like there’s also hexadecimal representations within different signal processing parameters, however I’m certain that the conversion can’t be too difficult. This is a very huge discovery for the AppleHDA/AppleALC community which will allow musicians/audio production experts, and just anybody who wants to give this type of thing a shot, the ability to fine tune their codec patches! I plan to write an advanced guide for everybody on configuring AppleHDA DSP parameters sometime in the future once I learn how to tweak a few more plugins. Here are the parameters/values specifically for the EQ plugin: 2 - ChSelect - 0 (Left Channel), 1 (Right Channel), 2 (Both L+R Channels) 3 - BandIndex - Increases with more filters and dependent on ChSelect Parameter 4 - BypassBand - Enables/Disables Filters 5 - FilterType: 1 - High Pass 2 - Low Pass 3 - Bandstop 4 - Bandpass 5 - Low Shelf 6 - High Shelf 6 - Frequency - HZ translated from float->32uint 7 - Q - Dimensionless Unit Translated from float->32uint. 8 - Gain - DB translated from float->32uint I wrote some sample code in C that you can plug into a compiler which will allow you to generate/translate 32 bit signed int values for DSP processing. (Maybe the next release of Hackintool could include something like this.) Once this program compiles, you can interface with it through the command window. // AppleHDA Value Converter // Created by Fortitude #include <stdio.h> void float_to_int(void) { float value = 1.0f; while (value != 0) { printf("Enter a floating point value to be converted:\n"); printf("(0) Main Menu\n"); scanf("%f", &value); if (value != 0) { int a = *(int*)(&value); printf("The int value is %d\n\n", a); } else { printf("\n"); } } return; } void int_to_float(void) { int value = 1; while (value != 0) { printf("Enter a 32 bit signed integer value to be converted:\n"); printf("(0) Main Menu\n"); scanf("%d", &value); if (value != 0) { float a = *(float*)(&value); printf("The float value is %f\n\n", a); } else { printf("\n"); } } return; } int main(void) { int input = -1; while(1) { printf("Make A Selection:\n"); printf("(1) Float -> Int\n"); printf("(2) Int -> Float\n"); printf("(0) Exit Program\n\n"); scanf("%d", &input); printf("\n"); if (input == 1) { float_to_int(); } else if (input == 2) { int_to_float(); } else if (input == 0) { break; } } return 0; } Edited January 11, 2022 by Fortitude 3 Link to comment Share on other sites More sharing options...
Recommended Posts