- Author:
- p4p4
- Twitter:
- @
- GitHub:
- Facebook:
- Google+:
- +
- Reddit:
- /r/
- Pouet:
- Website:
- p4p4.p4.ohost.de
- Compo:
- classic
- Demo link:
- https://js1k.com/2010-first/demo/493
- Shortlink:
- https://js1k.com/493
- Blog post:
- please update here!
- Bytes:
- 964
- Chars:
- 964
- Submission
M=Math;n=String.fromCharCode;N=16;Z=255;O=20;U=62;B=100;S=44100;T=32;s=T*S;D="data";function r(b,e){return e==1?n(b&Z,b>>8&Z):n(b&Z,b>>8&Z,b>>N&Z,b>>24&Z)}k=1.0594;a=0.01;A=[9,11,2,9,11,12,28,9,18,12,1,14,9,12,N,9];z="";for(p=0;p<T;p++){for(t=0;t<S;t++){o=M.floor(0.5+0.5*M.sin(t*a)*65535);z+=n(o&Z,o>>8&Z)}a*=k}l=length;c="fmt "+r(N)+r(1,1)+r(1,1)+r(S)+r(2*S)+r(2,1)+r(N,1);d=D+r(s*2)+z;h="RIFF"+r(4+(8+c.l)+(8+d.l))+"WAVE";a=new Audio(D+":audio/wav;base64,"+escape(btoa(h+c+d)));V=document.getElementById("c"); c=V.getContext("2d");c.f=c.fillRect;H=V.height=160;W=V.width=510;function f(b,e,g){c.fillStyle="rgb("+b+","+e+","+g+")"}V.onmousedown=function(b){x=b.clientX-5;y=b.clientY-5;X=O;for(j=0;j<N;j++){if(x>X&&x<X+O)A[j]+=y>40&&y<U?1:y>U&&y<82?-1:0;X+=30}};t=0;setInterval(function(){f(B,B,B);c.f(0,0,W,H);t=++t%N;a.pause();a.currentTime=A[t];a.play();for(j=0;j<N;j++){o=O+A[j]*N;x=O+j*30;f((j==t)*H,o,o);c.f(x,40,O,O);c.f(x,U,O,O);c.fillText(A[j],x,B)}},H);
- Description
- 303/bassline.
click the rects to detune..
- Base64 encoded
TT1NYXRoO249U3RyaW5nLmZyb21DaGFyQ29kZTtOPTE2O1o9MjU1O089MjA7VT02MjtCPTEwMDtTPTQ0MTAwO1Q9MzI7cz1UKlM7RD0iZGF0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PU8rQVtqXSpOO3g9TytqKjMwO2YoKGo9PXQpKkgsbyxvKTtjLmYoeCw0MCxPLE8pO2MuZih4LFUsTyxPKTtjLmZpbGxUZXh0KEFbal0seCxCKX19LEgpOw==
- Original source
M=Math;
n=String.fromCharCode;
N=16;
Z=255;
O=20;
U=62;
B=100;
S=44100;
T=32;
s=T*S; // 32 1-second tones.
D="data";
//
// audio
//
function r(A,p)
{
return p==1?n(A&Z,A>>8&Z):n(A&Z,A>>8&Z,A>>N&Z,A>>24&Z)
}
k = 1.0594;//63094359; // 12th root of 2
a = 0.01; //0.006875*k*k*k; // a
A=[9,11,2,9,11,12,28,9,18,12,1,14,9,12,N,9]; // preset melody
z="";
for(p=0;p<T;p++)
{
for(t=0;t<S;t++)
o= M.floor( 0.5 + 0.5 * M.sin(t*a) * 0xffff ),
z+=n(o&Z,o>>8&Z);
a *= k;
}
l=length;
c="fmt "+r(N)+r(1,1)+r(1,1)+r(S)+r(2*S)+r(2,1)+r(N,1);
d= D +r(s*2)+z;
h="RIFF"+r(4+(8+c.l)+(8+d.l))+"WAVE";
a=new Audio( D + ":audio/wav;base64," + escape(btoa(h+c+d)) );
//
// graphix:
//
V = document.getElementById('c');
c = V.getContext('2d');
c.f = c.fillRect;
H=V.height=160;
W=V.width=510;
function f(r,g,b)
{
c.fillStyle = "rgb("+r+","+g+","+b+")"
}
V.onmousedown=function(m)
{
x=m.clientX-5;
y=m.clientY-5;
X=O;
for ( j=0; j<N; j++ ) // clicked?
{
if ( x>X && x<X+O )
A[j] += y>40&&y<U ? 1 : y>U&&y<82 ? -1 : 0;
X += 30;
}
}
//
// frame
//
t=0;
setInterval(function()
{
f(B,B,B);
c.f(0, 0, W,H);
t = (++t % N);
a.pause();
a.currentTime=A[t];
a.play();
for ( j=0; j<N; j++ )
{
o=O + A[j]*N;
x=O+j*30;
f((j==t)*H,o,o);
c.f( x, 40, O, O);
c.f( x, U, O, O);
c.fillText( A[j] , x, B )
}
},H);