Hacker News new | ask | show | jobs
by mrmufungo 2545 days ago
This was initially a project I had started to get better acquainted with the Web Audio API. I had done some preliminary work with the Media Source Extensions API and piping output via to the Web Audio API, but I wanted to see how well the scheduling capabilities were. Throughout the effort, I learned quite a bit about signal processing and FFT.

The current process is rather simple: I utilize M3U8 for storing segment information, and manually parse the file when a play request is received. I grab the first few (Opus-encoded) segments, pass them through an OfflineContext to maintain a specific sample rate, and store the resulting buffer in a wrapper object. Each object is stored in an array, and is responsible for re-creating the AudioNode when stopping or starting.

The hardest part about this (for me at least) was fetching and scheduling accurately while the player is running. I group segments requests together, and schedule after each group has finished downloading. It's not perfect, as I occasionally get pops between each segment: Chrome seems to be less noticeable than Firefox in this regard. I schedule based on the buffer duration, but there seems to be subtle differences between browsers.

In any case, I've had quite a bit of fun working on this project.

2 comments

Looks great, also thanks for giving technical specifics!

Could you elaborate a bit more on what the site does, perhaps in an ELI5 way (explain it like I'm 5 years old)? It's not entirely obvious at a glance, i.e is it like SoundCloud?/How does it differ?/Can it be used to create music?

Sure. The site is billed as a delivery service, thus you're able to upload music (that you have the rights to) and monetize it. You could, of course, opt to give away your content for free; there's no requirement to login or perform an action to download a free tack. The site does allow remixes and mixes, but they have their own rules.

In terms of interaction, it's similar to SoundCloud. I've been using SoundCloud for years - just right after they transitioned to their V2 site. I've also used Bandcamp for selling my own music, and always felt their approach was transparent and fair when it came to monetization. When I started this project, a little bit of both went into the design and structure.

Love this! I'm giving it a try, and I already have a feature request: can you increase the limit on display name and username?
Noted!