
Web Audio API: Musically-aware scheduling and Dynamic looping (2016) - feross
https://jakearchibald.com/2016/sounds-fun/
======
kaycebasques
FYI we've got a Web Audio API guide in the works for web.dev. We're still
working on it but here's the staged version: [https://deploy-preview-2757--
web-dev-staging.netlify.app/pro...](https://deploy-preview-2757--web-dev-
staging.netlify.app/profiling-web-audio-apps-in-chrome/)

(Figured I might as well put in a plug while Web Audio is on page 1)

~~~
nchase
Looks great! Thanks!

------
feross
The demo near the end with the Sonic “Chemical Plant” theme is definitely
worth checking out. I wasn’t aware that this was how games dynamically change
the background music in response to an event in the game.

~~~
kevingadd
It can be interesting to compare "game rip" versions of game soundtracks with
the official CD releases. An official release of a track from Remember Me
might be 2-3 minutes long, but the game rip is 10-20 minutes long, filled with
stems and loop segments that transition back and forth based on a few things
like the length of the player's current combo chain and their HP.

AFAIK, Splinter Cell: Chaos Theory is another example of this - there's an
official release of the soundtrack but the game rip versions of the tracks are
typically all 5-10x as long because they are extremely dynamic.

Aside from loop point adjustment, a common technique is to split a track into
layers and fade layers in/out dynamically depending on world state.

~~~
jaffathecake
Nintendo are particularly good at this, where each phase though a menu towards
starting a game will add layers to the music. Makes me wonder if they're still
using some form of sample-based music tracker.

------
jakelazaroff
Heads up, 2016 article. Did a double take when it said fetch wasn't
implemented in Safari yet.

~~~
randall
I was frightened for a minute.

------
aasasd
Decoding whole tracks in memory seems pretty wasteful (and then getting entire
waveforms on top, though this part can probably be limited). I guess it's okay
if you're looping a thirty-second track but not so much if it's twenty
minutes, like mentioned in another comment. Makes me wonder if compressed
audio can be used directly in such cases.

