From 1ec70b5c1d4334b286ddc13947fe4e7ddd56fdf6 Mon Sep 17 00:00:00 2001 From: nycki Date: Thu, 10 Jul 2025 01:59:51 -0700 Subject: [PATCH] percussion! --- static/qrplay/v2c.html | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/static/qrplay/v2c.html b/static/qrplay/v2c.html index 4e2efb9..f56ce02 100644 --- a/static/qrplay/v2c.html +++ b/static/qrplay/v2c.html @@ -37,6 +37,8 @@ T=[]; u=137; // volume. 40 is default, 35 is half, 30 is half again. v=40; +// percussion can be approximated as 1024th notes. +P=x=>(s=`z99l-5${x}o${o+4} l${Math.log2(l)} z${Z} x`+s.slice(c),c=0,T[99]=t); for( c=t=k=Z=0;D=s[c+1],E=D+s[c+2],C=s[c++]; // no match @@ -44,16 +46,21 @@ for( // comments z<2?k=z:k?0: // - + octave - z<4?o+=C+12|0: + z<4?o+=C+1|0: // dots and triplets z<5?l*=3/2: z<6?l/=3: - // note or rest (percussion not implemented) + // percussion + C==`0`?P(`o07g`): + C==`1`?P(`o05b+c#deff#gg#aa#b+cc#d`): + C==`2`?P(`o06g++ddb--g++ddb--g++ddb--g++ddb`): + C==`6`?P(`o05a++c#-aae+e--a++c#-aae+e--a++c#`): + // note or rest z<23?( z-=6, O=new OscillatorNode(A,{ type:`square`, - detune:100*(z*2-(z>3)-(D==`!`)+(D==`#`)+o-9) + detune:100*(z*2-(z>2)-(D==`!`)+(D==`#`)+12*o-9) }), G=new GainNode(A,{gain:z<7&&.5**(12-v/5)}), O.connect(G), @@ -66,12 +73,16 @@ for( // set note length z<31?l=2**(z-25): // change channel - z<32?(T[Z]=t,t=T[Z=E]|0,c+=2): + z<32?(T[Z]=t,t=T[Z=E|0]||0,c+=2): // change tempo z<33?u=E+s[c+=2,c++]: // change volume - (v=E,c+=2) -)z=`\n;-+.3cdefgab012456789x@jtsiqhwzuv`.indexOf(C) + z<34?(v=E,c+=2): + // set octave + z<35?(o=E-4,c+=2): + // set length + (l=2**E,c+=2) +)z=`\n;-+.3cdefgab012456789x@jtsiqhwzuvol`.indexOf(C) '>#play