Generation of Music Using Pure JS and HTML5
cssdeck.com
Generation of Music Using Pure JS and HTML5
1–10 of 17 posts
Re: Generation of Music Using Pure JS and HTML5
#2Re: Generation of Music Using Pure JS and HTML5
#3Re: Generation of Music Using Pure JS and HTML5
#4Re: Generation of Music Using Pure JS and HTML5
#5http://jlongster.com/s/touch.html#notes
Requires Web Audio API. I talked about it here: http://jlongster.com/2012/09/12/web-apps.html
Re: Generation of Music Using Pure JS and HTML5
#6 this.dataURI = 'data:audio/wav;base64,'+FastBase64.Encode(this.wav);
(edit... more accurately the whole RIFFWAVE function blows my mind)Really quite revolutionary (in terms of my understanding)... I already knew about making JPEGS etc, so this makes perfect sense but just seeing him build all the headers for a wav file in memory then "spit it out" to the page is stunning.
Kudos, Bravo, Standing slow clap, etc...
Thanks for sharing.
Re: Generation of Music Using Pure JS and HTML5
#7Re: Generation of Music Using Pure JS and HTML5
#8Re: Generation of Music Using Pure JS and HTML5
#9web audio api also does help.. for instance https://github.com/dashersw/pedalboard.js
Re: Generation of Music Using Pure JS and HTML5
#10This should make it easier to make a pure js NES emulator. We have sprites/canvas/webgl, and this level of audio fits perfectly.
Now, in the mean time, I do have an idea of how this might be implemented on top of Riffwave.js, but it's iffy. The problem is that while the HTML5 audio element does have some events that tell you about playback status, we cannot possibly rely on JS events (or the placement of new audio tags) to give us the temporal granularity needed for audio timing. If you mistime the beginning of one block from the end of the previous block by half a millisecond, you'll hear an audible pop.
So one possible solution would be to crossfade blocks, using an overlap period on the same order as your timing uncertainty. In the cleverest implementation, the timing uncertainty would be continually measured and the overlap size would be adapted to be as low as possible.
But that's not a perfect solution. It would ameliorate the problem, but it would also introduce its own artifacts. For example, if you have a 440 Hz sine wave playing, and one block is offset by the next by 1.13 ms, then at the midpoint between two blocks (where each block is at 50% volume), the waves will interfere completely, resulting in a point of silence. The artifact would be soft, but it would still be a problem.