编程与软件工程blog.bjrn.se编辑精选
动手写一个 MP3 解码器
Let's Build an MP3 Decoder
2008 — 2018,它一次次回到首页
黑点是上首页(≥ 50 分)的那次投稿,空心点是没冲上去的投稿,点越大分数越高。
导读
这篇 2008 年的经典教程手把手带你用 Haskell 从零实现一个 MP3 解码器,讲解 MP3 格式的解码原理,包括 Huffman 解码、反量化、立体声处理等环节。文章时隔多年多次登上 Hacker News 首页,是学习音频压缩与函数式编程实践的知名参考资料。
为什么经久不衰:它把一个真实而复杂的工业标准拆解成可动手实现的项目,兼具教学深度和趣味性,至今仍是理解 MP3 原理和用 Haskell 做实际工程的最佳入门之一。
HN 评论精选
指出本文未深入讲解滤波器组和 MDCT 等难点,并推荐 JPEG 教程和 MPEG 压缩论文作为补充
同类型且同样用 Haskell 写的教程,我推荐《Exploring JPEG》。对于有压缩和信号处理基础的人来说,理解 MP3 的难点在于多相滤波器组和混合离散余弦变换,本文对这两点着墨不多,它们利用的混叠抵消性质相当微妙。其余部分与图像压缩有直接对应(如联合立体声类似 RGB 到亮度-色度空间的变换),不难掌握。这些较难的信号处理部分,推荐从 Pan 的 IEEE 论文《A Tutorial on MPEG/Audio Compression》入手。
psykotic查看英文原文
In the same genre and likewise in Haskell, I recommend Exploring JPEG: http://www.imperialviolet.org/binary/jpeg/ On the decoder side, for someone who has basic familiarity with compression and signal processing, the obstacles in understanding MP3 are polyphase filter banks and the mixed discrete cosine transform, which are not much explained in this article. They both take advantage of alias cancelation properties (in the frequency domain for the filter bank and in the temporal domain for the MDCT) that in my opinion are pretty subtle. The rest of the components in an MP3 decoder have close analogues in image compression (e.g. joint stereo is a decorrelation transform that is analogous to going from RGB to a luminance-chrominance color space), so they shouldn't be difficult to grasp. For those trickier signal processing parts, Pan's IEEE article A Tutorial on MPEG/Audio Compression is a great place to start: http://www.ee.columbia.edu/~dpwe/e6820/papers/Pan95-mpega.pdf
怀旧:早年自己实现 MP3 解码器的经历,凸显当年计算资源之有限
这让我回忆起往事。我最早写的“正经”程序之一就是用 Pascal 写的 MP3 解码器,在我的 P90 机器上解码一分钟音频要花约 30 分钟。当时我感觉自己是全世界之王。
noonespecial查看英文原文
Wow, that takes me back. One of the first "serious" programs I wrote was an mp3 decoder in pascal. It took about 30 minutes per minute of audio to do the decode on my p90. I felt like king of the whole world.
赞叹将声音数字化的过程本身很迷人
好文章!我觉得把声音这种可听、真实的东西数字化的整个过程实在太神奇了。
darxius查看英文原文
Great read! (although I admit I'm not completely done it) I think the whole process of taking something audible and "real" (like sound) and digitizing it is simply amazing.
专利过期后,有人提议做开源 MP3 编码器,但承认难度不小
既然专利已经过期,我们来做个 MP3 编码器吧!……我完全不知道该怎么做,哪怕是个玩具级的。
sp332查看英文原文
Now that the patents have expired, let's make an MP3 encoder! ... I have no idea how to do that. Even a toy one.
历次讨论
同类还值得读
开源应用架构
The Architecture of Open Source Applications
《开源软件架构》(AOSA)是一本在线免费书,邀请知名开源项目的作者亲自剖析其内部设计,涵盖 SQLAlchemy、LLVM、Audacity、Apache、Bash 等系统。
编程与软件工程上首页 9 次 · 2011–2024aosabook.org编辑精选编程语言简史:简短、不完整且多半错误
A Brief, Incomplete, and Mostly Wrong History of Programming Languages
一篇以戏谑、故意不准确的方式回顾编程语言史的博客文章,用夸张轶事和讽刺定义串起 Lisp、C、C++、Java、JavaScript、PHP 等语言。
编程与软件工程上首页 8 次 · 2009–2021james-iry.blogspot.comSQLite 是如何测试的
How SQLite is tested
SQLite 官方文档页,系统介绍 SQLite 的测试体系:多种测试方法(TCL 测试、模糊测试、回归测试、静态分析等)和海量测试用例,展示了这个小型开源项目如何靠极致测试获得…
编程与软件工程上首页 8 次 · 2009–2025sqlite.org编辑精选高级编程语言(2009)
Advanced programming languages (2009)
Matt Might 的经典文章,按用途推荐“高级编程语言”:如果追求就业就选主流语言,如果追求表达力、学术研究或创业,则推荐 Haskell、OCaml、Scala 等函数式语…
编程与软件工程上首页 8 次 · 2009–2022matt.might.net我的 Forth 与栈机器经历
Yosefk - My history with Forth & stack machines
作者以亲身经历回顾了使用 Forth 语言和栈式机器的历程:既赞叹其简洁优雅、代码量小、可自举的优点,也坦率指出栈操作在实际编程中的痛苦,以及 Forth 社区文化中的问题。
编程与软件工程上首页 8 次 · 2010–2024yosefk.com编辑精选