TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

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

21 pointsby asabalmost 6 years ago

5 comments

asabalmost 6 years ago
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
sbr464almost 6 years ago
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 未加载
xchipalmost 6 years ago
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 未加载
bradknowlesalmost 6 years ago
Doesn’t work on iOS, and provides no useful information on the page as to what it is supposed to be doing.
评论 #20367756 未加载
评论 #20370883 未加载
quickthrower2almost 6 years ago
Neat. I like how whistling produces a narrow band. Could make a flappy bird game from whistling!
评论 #20379924 未加载