more tricks; remove the d
All checks were successful
/ build (push) Successful in 32s

This commit is contained in:
Nycki 2025-07-09 22:45:15 -07:00
parent 657cc8f47c
commit 819fda5985
2 changed files with 12 additions and 13 deletions

View file

@ -38,22 +38,23 @@ u=137;
// volume. 50 is max, 45 is half, 40 is half again...
v=40;
for(
c=t=o=k=Z=0,l=3;E=s[c+2],D=s[c+1],C=s[c++];
c=t=o=k=Z=0,l=3;D=s[c+1],E=D+s[c+2],C=s[c++];
// no match
z<0?0:
// comments
z<2?k=z:k?0:
// - + octave
z<4?o+=12*--d:
z<4?o+=C+12|0:
// triplets and dots
z<6?l*=3/d:
// note or rest (percussion not implemented)
z<23?(
z-=6,
O=new OscillatorNode(A,{
type:`square`,
detune:100*(d?`0x`+d-(D==`!`)+(D==`#`)+o-9:-9e9)
detune:100*(z*2-(z>3)-(D==`!`)+(D==`#`)+o-9)
}),
G=new GainNode(A,{gain:.5**(11-v/5)}),
G=new GainNode(A,{gain:z<7&&.5**(11-v/5)}),
O.connect(G),
G.connect(A.destination),
O.start(t),
@ -64,17 +65,17 @@ for(
// set note length
z<31?l=3<<(z-25):
// change channel
z<32?(T[Z]=t,t=T[Z=D+E]|0,c+=2):
z<32?(T[Z]=t,t=T[Z=E]|0,c+=2):
// change tempo
z<33?u=s.slice(c,c+=3):
z<33?u=E+s[c+=2,c++]:
// change volume
(v=D+E,c+=2)
(v=E,c+=2)
// TODO combine all these slice operations into one branch
// d is additional data that varies with the operation.
)d=`--0229024579b`[z=`\n;-+.3cdefgab012456789x@jtsiqhwzuv`.indexOf(C)]
'>#play</button> <button onclick=f.A.close()>#stop</button></center>
)z=`\n;-+.3cdefgab012456789x@jtsiqhwzuv`.indexOf(C)
'>#play</button> <button onclick=f.A.close()>#stop</button>
<!-- stop snipping here -->
</center>
<hr>
<table style="text-align: center;">

View file

@ -1,3 +1 @@
<meta name=viewport content=initial-scale=1><center><p><a href=http://nycki.net/qrplay>qrplay v2c</a></p><textarea id=f style=width:min(40em,99%);height:9lh></textarea><p><button onclick='s=f.value.toLowerCase();f.A?.close();A=f.A=new AudioContext;T=[];u=137;v=40;for(c=t=o=k=Z=0,l=3;C=s[c++];z<0?0:z<2?k=z:k?0:z<4?o+=12*--d:z<6?l*=3/d:z<23?(O=new OscillatorNode(A,{type:`square`,detune:100*(d?`0x`+d-(s[c]==`!`)+(s[c]==`#`)+o-9:-9e9)}),G=new GainNode(A,{gain:.5**(14-v/5)}),O.connect(G),G.connect(A.destination),O.start(t),O.stop(t+=2.5*l/u)):z<24?(o=0,l=3):z<31?l=3<<(z-25):z<32?(T[Z]=t,t=T[Z=s[c++]+s[c++]|0]|0):z<33?u=s.slice(c,c+=3):v=s[c++]+s[c++])d=`--0229024579b`[z=`\n;-+.3cdefgab012456789x@jtsiqhwzuv`.indexOf(C)]'>#play</button> <button onclick=f.A.close()>#stop</button>
783
<meta name=viewport content=initial-scale=1><center><p><a href=http://nycki.net/qrplay>qrplay v2c</a></p><textarea id=f style=width:min(40em,99%);height:9lh></textarea><p><button onclick='s=f.value.toLowerCase();f.A?.close();A=f.A=new AudioContext;T=[];u=137;v=40;for(c=t=o=k=Z=0,l=3;D=s[c+1],E=D+s[c+2],C=s[c++];z<0?0:z<2?k=z:k?0:z<4?o+=C+12|0:z<6?l*=3/d:z<23?(z-=6,O=new OscillatorNode(A,{type:`square`,detune:100*(z*2-(z>3)-(D==`!`)+(D==`#`)+o-9)}),G=new GainNode(A,{gain:z<7&&.5**(11-v/5)}),O.connect(G),G.connect(A.destination),O.start(t),O.stop(t+=2.5*l/u)):z<24?(o=0,l=3):z<31?l=3<<(z-25):z<32?(T[Z]=t,t=T[Z=E]|0,c+=2):z<33?u=E+s[c+=2,c++]:(v=E,c+=2))z=`\n;-+.3cdefgab012456789x@jtsiqhwzuv`.indexOf(C)'>#play</button> <button onclick=f.A.close()>#stop</button>