WAV file player in pure Javascript

Web Audio API is one of the cutting edge technology Javascript has offered. (It isn’t even supported in IE11! But both Chrome and Firefox now support it without prefix). It allows direct low-level manipulation of audio data (to sample level).

While .wav file format is supported by all browsers (Support here is defined by ability to be decoded via AudioContext.decodeAudioData, which is normally the same as those supported in <audio> tag), many other format is not, such as MP3/AAC/Ogg due to various patent problems. Because audio codecs, as opposed to video codec, require very low power to decode, it has been done in pure Javascript before (jsMAD, etc). I actually aim to write some audio decoder in pure Javascript too, so the .wav file playing is the first stepping stone. (audiocogs/etc is Not Invented Here™)

tl;dr here’s the code: https://gist.github.com/innocenat/5c5a48365930b691c863 Read on for detail.

Introducing InnoWiki

Well, this is not actually planned, but it is simple enough that I can hacked things together in a couple of day (and yes, the code is very short, but very hackish)

Let meet InnoWiki: http://innowiki.innocen.at/ [GitHub]

Some side project: Brainfuck-JIT

I actually have wondered how JIT (Just-In-Time compiling) works for quite a long time, because it is basic knowledge that code segment in memory is write-protected, and you cannot move CPU instruction pointer to stack frame or heap for to security reason. But to do JIT you need to generate new machine code in memory and instantly execute it. How?

I stumbled upon this article titled “The Joy of Simple JITs”, which get me started. Apparently, you can do mmap (POSIX) or VirtualAlloc (Win32) to allocate virtual file in memory. And you can write to this section. And you can execute it. Looking great?

What I Plan to Do

It is great to have some plan, right? Over next few years, I plan to challenge my skills by various independent projects, which I will list here in no particular order. Some of these projects are very hard, yes, and I am not even sure if can complete them all (some may very well over my skill), but all of them will be a very good challenge.