diff --git a/static/qrplay/v2a.html b/static/qrplay/v2a.html index 44b3ad1..748b7f2 100644 --- a/static/qrplay/v2a.html +++ b/static/qrplay/v2a.html @@ -26,35 +26,28 @@ r=.4; // speed in s/beat l=1; // note length in beats T=[]; // elapsed beats per channel v=f.value; // input text -s=A.sampleRate; -W=A.createBuffer(1,2*s,s); -for(i=0;i++<2*s;W.getChannelData(0)[i]=Math.random()*3-1); -w=A.createBufferSource(); -w.buffer=W; -w.loop=true; -w.connect(B); +// white noise for percussion +W=A.createBuffer(1,s=A.sampleRate,s); +for(i=0;i++<2*s;W.getChannelData(0)[i]=Math.random()*2-1); +p=n=>(n.connect(B),n.start(t*r),t+=l,n.stop(t*r)); // todo: can this be inlined? for( i=o=k=t=Z=0; // loop over input, look ahead one character for sharp/flat // see bottom of loop for z and g initializers c=v[i++],d=v[i],c; - + z<0?0: // unknown character, ignore !z?(o=0,l=1/8): // @ reset z<3?o+=g: // -+ change octave z>28?k=z-29:// start or end of comment. POVUKR multi-character codes not implemented. k?0: // middle of comment z>27?(T[Z]=t,Z=+v.slice(i,i+=2),t=T[Z]||0): // change channel - z>18?(w.start(t*r),t+=l,w.stop(t*r)): + // play white noise for 012456789. 3 is omitted on purpose, used for triplets. + z>18?p((w=A.createBufferSource(),w.buffer=W,w.loop=1,w)): z>17?t+=l: // rest. 012456789 percussion not implemented. z&1?l=g: // change note length - ( // play note - a=new OscillatorNode(A,{ - type:'square', - detune:100*(g+o+(d=='#')-(d=='!')) // # sharp or ! flat - }), - a.connect(B),a.start(t*r),t+=l,a.stop(t*r) - ) + // play music note ABCDEFG, suffix # for sharp or ! for flat + p(new OscillatorNode(A,{type:'square',detune:100*(g+o+(d=='#')-(d=='!'))})) // type of g varies depending on the operation ) g=[,-12,12,4,-9,2,-7,1,-5,.5,-4,.25,-2,1/8,0,l/3,2,l*1.5][z=`@-+wchdqeifsgta3b.x012456789z\npovukr'`.indexOf(c.toLowerCase())] ">#play diff --git a/static/qrplay/v2a.min.html b/static/qrplay/v2a.min.html new file mode 100644 index 0000000..8434342 --- /dev/null +++ b/static/qrplay/v2a.min.html @@ -0,0 +1 @@ +
\ No newline at end of file