Javascript is 18 years old! Let's celebrate with a nice little tune.
<body onload="for(r=q='data:audio/wav;base64,UklGRiQAAABXQVZFZm10IBAAAAABAAEA5h0AAOYdAAABAAgA',f=t=0;t++<6e5;q+=f&9)f+='G G UZZUUZUZ5 5 5 5 P P PL G GC5 5(/(@5 '.charCodeAt(t/1441%64)/500;new Audio(r+btoa(q)).play()">JS is jarig \o/
Our friends from Dead Horse JS, submitted this homage to JavaScript and Rob is Jarig in the 256 bytes intro competition at Function 2013 in Budapest, Hungary on September 14th, 2013.
A serious joke ?
This little production is quite interesting technically. It borrows the WAVE PCM setup from the 140b Music SoftSynth and HYPERSONIC MANDELBULB.
Melody Time
The catchy melody originally spans accross 3 patterns of 64 measures, including a "repeat" pattern at a different octave.
All the notes but one, are played on an even measure, and clearly there is no way to store 192 measures into 256 bytes. Exit odd note. Down to 96 measures. Still too much for 256 bytes. Exit repeat pattern. The 2 distinct patterns made it into a 64 bytes long string, and the smae oscillator is reused throughout the whole music.
Instead of using the character codes as MIDI note and compute the exact frequency as:
var note = melody.charCodeAt(t/tempo);
var freq = 440*Math.pow(2,note/12);
osc += freq;
This would have been sweet because it turned the melody into this string:
var melody = "V V YZZYYZYZQ Q Q Q X X XW V VUQ QLOLTQ ";
// LOL!
But this approach leaves no room for visuals or even a title. Looking at the frequency of the notes used, shows that the was a relatively small margin of error by skipping the MIDI encoding and using the raw character codes as increment for the oscillator. This change saved a good 15 bytes!
var melody = "G G UZZUUZUZ5 5 5 5 P P PL G GC5 5(/(@5 ";
var note = melody.charCodeAt(t/tempo);
var freq = note/500;
osc += freq;
Karma
Of course Javascript is jarig is available on Pouet.net.
Other recent experiments
There are many experiments and projects like JAVASCRIPT IS JARIG to discover other here.
- FRONTFEST MOSCOW It was an honour to be invited to Fronfest Moscow 2017 with the little family to give my first workshop; implementing a Twin-stick shooter using ES6 and Canvas, and to continue my CODE🎙ART series of talks + live coding aiming to inspire new web developer artists. on November 18th, 2017
- VOLTRA VOLTRA: Grinding the Universe, a gritty JavaScript demo, winner of the 1024 bytes demo competition at the Assembly 2017. on August 6th, 2017
- BREATHING EARTH Another take on Nadieh Bremer mesmerizing Breathing Earth visualisation, running at 60fps on a 2D Canvas without libraries or frameworks. on June 26th, 2017
- 10 PRINT THEREMIN AT WEB REBELS A lighting talk about labyrinth generation and theremin instrument using the Web Audio API in 219 bytes presented at Web Rebels 2016. on June 2nd, 2016
- JS1K 2015 INVITATION JS1k 2015, the yearly 1kb JavaScript contest, is around the corner and kuvos asked a couple of optimizer extraordinaires to open the show. Hopefully this little invitation will tingle the spider sense of talented developers and code golfers in time for them to submit high quality entries to JS1k 2015. on January 28th, 2015
- WOLFENSTEINY An homage to Wolfenstein 3D in 251 bytes of HTML5 on October 15th, 2013
- TEA STORM 256 bytes JavaScript signed distance field raymarcher using 2D Canvas. TEA STORM won at Function 2013 on September 14th, 2013
- OOMA The winning bootsector of Outline 2005, featuring two images zooming with experimental music in a valid 480bytes Atari bootsector. on March 30th, 2005
Let's talk
Don't be shy; get in touch by mail, twitter, github, linkedin or pouet if you have any questions, feedback, speaking, workshop or performance opportunity.