TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Show HN: A spectrogram app in less than 100 lines of HTML and JavaScript

21 点作者 asab将近 6 年前

5 条评论

asab将近 6 年前
Hi HN, creator here. Lately I&#x27;ve been enjoying learning about the Web Audio API and wanted to apply it. I wanted a quick debugging tool to inspect the sounds I was synthesizing and ended up creating this. It&#x27;s vanilla JS, so just view source to check it out.<p>Things I&#x27;ve ended up enjoying with it:<p>- Hum, whistle, and sing my favorite tunes and compare the images<p>- Take it on a nature walk and look at bird calls<p>- Try to make sounds to draw a specific picture or shape<p>How it works:<p>On load, the app requests microphone access, and connects that audio stream to a WebAudio AnalyzerNode. The AnalyzerNode offers a fast fourier transform that is called repeatedly using requestAnimationFrame. For each frame, the entire contents of the canvas are shifted left by 1 virtual pixel, and the current fourier frequency bins are plotted in the rightmost column.<p>Limitations:<p>- There are 1024 frequency bins, compared to roughly 20,000 hertz hearing range, so the resolution is pretty good but not perfect as each dot represents a range of ~20 hertz.<p>- Unfortunately doesn&#x27;t work in iOS Firefox or Chrome; Apple won&#x27;t offer microphone access via getUserMedia to 3rd party browsers.<p>- It has a PWA manifest; Android users should be able to add to homescreen. iOS users still can&#x27;t since getUserMedia is restricted in iOS PWAs
sbr464将近 6 年前
Nice work, I like the simplicity &amp; loc count.<p>Here&#x27;s another example I found that I always liked (w&#x2F;source link) but definitely more complex.<p><a href="https:&#x2F;&#x2F;musiclab.chromeexperiments.com&#x2F;Spectrogram&#x2F;" rel="nofollow">https:&#x2F;&#x2F;musiclab.chromeexperiments.com&#x2F;Spectrogram&#x2F;</a><p><a href="https:&#x2F;&#x2F;github.com&#x2F;googlecreativelab&#x2F;chrome-music-lab&#x2F;tree&#x2F;master&#x2F;spectrogram" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;googlecreativelab&#x2F;chrome-music-lab&#x2F;tree&#x2F;m...</a>
评论 #20379899 未加载
xchip将近 6 年前
I see yours and I raise mine :P<p><a href="https:&#x2F;&#x2F;aguaviva.github.io&#x2F;GuitarTuner&#x2F;GuitarTuner.html" rel="nofollow">https:&#x2F;&#x2F;aguaviva.github.io&#x2F;GuitarTuner&#x2F;GuitarTuner.html</a><p>Each bar is correspond to each key in a piano. The red vertical lines are the notes of a guitar played open string.<p>You can use this to tune your instruments and to understand its harmonics too.
评论 #20379796 未加载
bradknowles将近 6 年前
Doesn’t work on iOS, and provides no useful information on the page as to what it is supposed to be doing.
评论 #20367756 未加载
评论 #20370883 未加载
quickthrower2将近 6 年前
Neat. I like how whistling produces a narrow band. Could make a flappy bird game from whistling!
评论 #20379924 未加载