- Author:
- Lara
- Twitter:
- @
- GitHub:
- Facebook:
- Google+:
- +
- Reddit:
- /r/
- Pouet:
- Website:
- Compo:
- canvas
- Demo link:
- https://js1k.com/2017-magic/demo/2814
- Shortlink:
- https://js1k.com/2814
- Blog post:
- please update here!
- Bytes:
- 930
- Chars:
- 906
- Submission
D=[...`ǖ&ǖ&ƎŞn&n&ĮVn&ĮVn&ÎȀ&>>>>!>!V!>!V!>!V!>!V!>!V!>!V!>!V!>!VƎŀ&>>>>>V>V>V>V>V>V>V>VƎŀ&>>>>2b2b2bn&2b2b2bn&>V>V>V!>!V&>&V!>!V#>#V>V!>!V>V>V!>!V&>&V!>!V#>#V>V!þ!þĮVn&ƎnƎnɎn&n&ÎȀ&`]
A=new AudioContext
S=A.createScriptProcessor(B=2048,I=T=t=n=0,1)
S.connect(A.destination)
R=A.sampleRate
M=Math
;(P=_=>{
if(I>D.length-4)return
n=n<1?D[I+1][C="codePointAt"](0):-B
t=T
setTimeout(P,d=(D[I+=2][C](0)-14)*1.6)})()
S.onaudioprocess=e=>{c.fillStyle="#343"
c.fillRect(0,0,W=a.width,H=a.height)
c.fillStyle="#fff"
for(i=0;i<18;c.font=((S=n==i+18)?"bold ":"")+"64px Arial",i++)c.fillText("🐣",W/2+(i%9-5)*64,H/1.5-S*32-i*14)
for(o=e.outputBuffer.getChannelData(i=0);i<B;i++,T++)for(o[i]=0,j=9;j-->1;)o[i]+=M.sin(86.4*T/R*M.pow(2,(n+42)/12)*j)/j/50*M.exp((t-T)/R/d*B)}
- Description
- With sincere apologies to Wolfgang Amadeus Mozart
- Base64 encoded
RD1bLi4uYBoax5YaJhzHlhwmHsaOHsWeFW4VJhVuFSYaxK4aVhpuGiYcxK4cVhxuHCYew44eyIAfJh8UHj4eGhw+HBoePh4aHz4fGiE+IVYhPiFWIT4hViE+IVYhPiFWIT4hViE+IVYhPiFWGsaOGsWAHCYcFBo+GhoZPhkaGj4aGhw+HBoePh5WHj4eVh4+HlYePh5WHj4eVh4+HlYePh5WHj4eVhfGjhfFgBkmGRQXPhcaFT4VGhc+FxoZPhkaGjIaYhoyGmIaMhpiFW4VJhwyHGIcMhxiHDIcYhVuFSYePh5WGj4aVh4+HlYhPiFWJj4mViE+IVYjPiNWHz4fViE+IVYaPhpWHj4eViE+IVYmPiZWIT4hViM+I1YfPh9WIcO+IcO+GsSuGlYabhomHMaOHG4fxo4fbhXJjhXCnhduFyYZbhkmGsOOGsiAHyZgXQ0KQT1uZXcgQXVkaW9Db250ZXh0DQpTPUEuY3JlYXRlU2NyaXB0UHJvY2Vzc29yKEI9MjA0OCxJPVQ9dD1uPTAsMSkNClMuY29ubmVjdChBLmRlc3RpbmF0aW9uKQ0KUj1BLnNhbXBsZVJhdGUNCk09TWF0aA0KOyhQPV89PnsNCmlmKEk+RC5sZW5ndGgtNClyZXR1cm4NCm49bjwxP0RbSSsxXVtDPSJjb2RlUG9pbnRBdCJdKDApOi1CDQp0PVQNCnNldFRpbWVvdXQoUCxkPShEW0krPTJdW0NdKDApLTE0KSoxLjYpfSkoKQ0KUy5vbmF1ZGlvcHJvY2Vzcz1lPT57Yy5maWxsU3R5bGU9IiMzNDMiDQpjLmZpbGxSZWN0KDAsMCxXPWEud2lkdGgsSD1hLmhlaWdodCkNCmMuZmlsbFN0eWxlPSIjZmZmIg0KZm9yKGk9MDtpPDE4O2MuZm9udD0oKFM9bj09aSsxOCk/ImJvbGQgIjoiIikrIjY0cHggQXJpYWwiLGkrKyljLmZpbGxUZXh0KCLwn5CjIixXLzIrKGklOS01KSo2NCxILzEuNS1TKjMyLWkqMTQpDQpmb3Iobz1lLm91dHB1dEJ1ZmZlci5nZXRDaGFubmVsRGF0YShpPTApO2k8QjtpKyssVCsrKWZvcihvW2ldPTAsaj05O2otLT4xOylvW2ldKz1NLnNpbig4Ni40KlQvUipNLnBvdygyLChuKzQyKS8xMikqaikvai81MCpNLmV4cCgodC1UKS9SL2QqQil9
- Original source
// data (delay|note|delay|note|delay|...)
// extracted from http://www.midiworld.com/midis/other/mozart/magflute.mid
// using http://flashmusicgames.com/midi/mid2txt.php
// converted through String.fromCodePoint(n)
D = [...`ǖ&ǖ&ƎŞn&n&ĮVn&ĮVn&ÎȀ&>>>>!>!V!>!V!>!V!>!V!>!V!>!V!>!V!>!VƎŀ&>>>>>V>V>V>V>V>V>V>VƎŀ&>>>>2b2b2bn&2b2b2bn&>V>V>V!>!V&>&V!>!V#>#V>V!>!V>V>V!>!V&>&V!>!V#>#V>V!þ!þĮVn&ƎnƎnɎn&n&ÎȀ&`]
A = new AudioContext
S = A.createScriptProcessor(B=2048,I=T=t=n=0,1)
R = A.sampleRate
M = Math
// note on/off handler
;(P=_=>
{
if (I > D.length-4) return
// note
n = n < 1 ? D[I+1][C="codePointAt"](0) : -B
// delay
d = (D[I+=2][C](0)-14)*1.6
// current time
t = T
setTimeout(P,d)
})()
// playback loop
S.onaudioprocess = e =>
{
// background
c.fillStyle="#343"
c.fillRect(0,0,W=a.width,H=a.height)
// emojis
c.fillStyle="#fff"
for(i=0;i<18;c.font=((S=n==i+18)?"bold ":"")+"64px Arial",i++)
c.fillText("🐣",W/2+(i%9-5)*64,H/1.5-S*32-i*14)
// sawtooth wave
for(o=e.outputBuffer.getChannelData(i=0);i<B;i++,T++)
for(o[i]=0,j=9;j-->1;)
o[i]+=M.sin(86.4*T/R*M.pow(2,(n+42)/12)*j)/j/50*M.exp((t-T)/R/d*B)
}
S.connect(A.destination)