我低估了浏览器中音频波形处理的难度。

2作者: syncara27 天前
几个月前,我曾以为在浏览器中显示音频波形会是一个周末项目。 我错了。 第一个原型在处理短音频片段时运行良好,但当我尝试加载长达数小时的录音时,一切都崩溃了。 内存占用爆炸式增长。 用户界面变得无响应。 缩放操作痛苦不堪。 即使是生成波形峰值也比预期的要慢。 最让我惊讶的是,真正的挑战并非音频解码。而是高效地渲染和管理大量的时序数据。 我最终尝试了 Web Workers、IndexedDB 缓存、虚拟化渲染和渐进式加载策略,仅仅是为了保持浏览器的响应速度。 对于那些构建过基于浏览器的音频工具的人来说: 您遇到的最困难的性能瓶颈是什么? 是解码、渲染、内存管理,还是完全是其他什么问题?
查看原文
A few months ago I thought displaying an audio waveform in the browser would be a weekend project.<p>I was wrong.<p>The first prototype worked fine with short audio clips, but everything fell apart when I tried loading recordings that were several hours long.<p>Memory usage exploded.<p>The UI became unresponsive.<p>Zooming was painful.<p>Even generating waveform peaks took longer than expected.<p>What surprised me most is that the actual challenge wasn&#x27;t decoding audio. It was rendering and managing huge amounts of timeline data efficiently.<p>I ended up experimenting with Web Workers, IndexedDB caching, virtualized rendering and progressive loading strategies just to keep the browser responsive.<p>For those who have built browser-based audio tools:<p>What was the hardest performance bottleneck you encountered?<p>Was it decoding, rendering, memory management, or something else entirely?