From 347ee76cf023db13dd069f1c1ddd7a8b9ff463dd Mon Sep 17 00:00:00 2001 From: nycki Date: Mon, 7 Jul 2025 16:46:56 -0700 Subject: [PATCH] percussion --- static/qrplay/v2a.html | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/static/qrplay/v2a.html b/static/qrplay/v2a.html index 4e86edb..44b3ad1 100644 --- a/static/qrplay/v2a.html +++ b/static/qrplay/v2a.html @@ -26,6 +26,13 @@ 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); for( i=o=k=t=Z=0; // loop over input, look ahead one character for sharp/flat @@ -33,14 +40,13 @@ for( c=v[i++],d=v[i],c; z<0?0: // unknown character, ignore - z>29?k=1: // start of comment. P, O, V, U, K, R, not implemented. - z>28?k=0: // end of comment + !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>17?t+=l: // rest - z<3? - z?o+=g: // -+ change octave - (o=0,l=1/8): // @ reset + z>18?(w.start(t*r),t+=l,w.stop(t*r)): + z>17?t+=l: // rest. 012456789 percussion not implemented. z&1?l=g: // change note length ( // play note a=new OscillatorNode(A,{