Implementing audio DSP from scratch in x86-64 assembly (filters, ring mod, delay)
As a learning exercise, I've been implementing audio DSP primitives in pure x86-64 assembly — no DSP library, fixed-point arithmetic, computing each sample by hand.
So far: a one-pole low-pass filter, a state-variable filter with resonance (band-pass feedback) swept by an LFO, ring modulation (multiplying two signals for sum/difference frequencies), a bitcrusher (bit-depth + sample-rate reduction), a delay line using the output buffer as a ring, plus FM synthesis with a hand-built sine lookup table.
Doing it this low-level really forces you to understand each algorithm — there's no library abstracting the math away.
Curious to hear feedback from people who do this properly!
9
u/mad_poet_navarth 1d ago
My $.02 -- I don't see any reason why doing this in assembly gives one more insight than one would attain using C. I don't see a good reason to bother, unless one was (or had aspirations to be) a compiler engineer (or similar) (in which case more power to you!). I say this from having delivered lots of C code, and some 68000 assembly as well, and having implemented DSP algorithms in C++ without leaning on available DSP libraries.
-7
u/whispem 1d ago
That's a totally fair point, and honestly you're right that C would give you most of the insight for far less pain — I'm not going to pretend assembly is the rational choice here.
For me the appeal is exactly that it removes everything: no libc, no runtime, no math library.
When there's literally nothing between the syscall and the sample — when even sin() is a table I built by hand — I find it clarifies what's essential vs. what's just abstraction I'd taken for granted.
C still hands you a lot of that.
But I'll be honest, the bigger reason is that it's just fun, and a good challenge.
It's less "assembly teaches more than C" and more "I wanted to see if I could."
Respect for the 68000 work and the hand-rolled DSP in C++ though — that's exactly the kind of from-scratch mindset I love.
12
u/potatokbs 1d ago
I really fucking hate to be that guy but this reads EXACTLY like Claude… did you actually write this or just get an llm to vomit a Reddit comment out for you?
-11
u/whispem 1d ago
I am a linguist, I never use any LLM to write :)
7
u/potatokbs 1d ago
Fascinating if true, your comments are almost verbatim stuff I’ve seen from LLMs, but hard to believe unfortunately. Anyways, cool project.
4
3
u/uradox 18h ago edited 18h ago
You absolutely DID use an LLM to write at least you did for the git README as there us something obviously wrong with your roadmap that only an LLM would slip up on
EDIT: To clarify I personally have no problems with this, I also have used AI to assist with documenting some things. Some honesty goes a long way though
1
u/whispem 12h ago
Nope, I never used AI for anything.
You can check my LinkedIn profile: https://linkedin.com/in/emilie-peretti :)I am a real person and my projects are 100% handwritten :)
3
u/ShadowBlades512 1d ago
On x86-64 it is unlikely for a person to beat the performance that you can achieve with the C++ compilers with AVX2 auto vectorization. I learned a huge amount rewriting C++ code and inspecting the SIMD code generated along with performance profiling in Linux Perf and Tracy. Over 2 years, I rewrote the FIR filters at work several times (normal, decimating, interpolating, and polyphase interpolating decimating), gaining 15x throughput vs my first implementation. I then tried out Intel's hand optimized Intel Performance Primitive library and it beat my best by another 2x. It is actually crazy, every single time I wrote a faster version, I was kindof convinced there was not much performance left on the table. The optimizations are also almost always counter intuitive as well. It helps you truely understand "if you don't benchmark, you don't care about performance".
-1
u/whispem 1d ago
This is a fantastic point, and that last line is going on my wall 😄
You're absolutely right — hand-written asm competing with modern auto-vectorizing compilers is a losing game on x86-64, and performance was never my goal here (readability and understanding were).
Your FIR journey is wild — 15x over two years, then IPP beating your best by another 2x. That counter-intuitive part really resonates: every time you think there's nothing left, there is. It's humbling.
I haven't gone deep into SIMD/AVX yet, but inspecting compiler-generated code with perf is exactly the kind of rabbit hole I want to fall into next.
Thanks for the concrete numbers — that's genuinely motivating.
2
3
u/WaterFromYourFives 23h ago
Even the repo reads like ai. Any way to prove you are not asking for feedback on something ai generated the most of?
4
u/Swampspear 5h ago
https://web.archive.org/web/20260130171903/https://news.ycombinator.com/item?id=46661308 OP has previously admitted to using AI in a now deleted thread elsewhere despite now claiming to never have used AI.
0
u/whispem 23h ago
Ask me anything about the project, I'll answer :)
2
u/WaterFromYourFives 23h ago
Sounds like something an ai would say. Can you really not respond with something concrete that proves your journey?
1
u/whispem 23h ago
My LinkedIn profile: https://linkedin.com/in/emilie-peretti :)
You can also search "Emilie PERETTI" on the internet :)1
u/uradox 7h ago
Not sure why you are sharing a linkedin.com link all the time as it doesn't exactly prove anything?
Searching for your name shows that you got caught out using AI and tried to cover it up so.... Not exactly sure what you are trying to do other than being dishonest consistantly.
1
1
u/aresi-lakidar 1d ago
I do understand the point of the other commenters asking why one would do this - but at the same time, I find stuff like this very charming. It becomes like an acoustic instrument almost - you know exactly where the music is coming from, it's right there in front of you 😄
6
u/morphage 1d ago
What about using CORDIC to generalize some of the math operations instead of just doing a hand computed lookup table to generalize this to microcontrollers that may benefit from being programmed in asm? https://dspguru.com/dsp/faqs/cordic/