precompute D and E
All checks were successful
/ build (push) Successful in 39s

This commit is contained in:
Nycki 2025-07-09 22:19:51 -07:00
parent c2d3b02098
commit 657cc8f47c
2 changed files with 8 additions and 13 deletions

View file

@ -38,7 +38,7 @@ u=137;
// volume. 50 is max, 45 is half, 40 is half again...
v=40;
for(
c=t=o=k=Z=0,l=3;C=s[c++];
c=t=o=k=Z=0,l=3;E=s[c+2],D=s[c+1],C=s[c++];
// no match
z<0?0:
// comments
@ -51,9 +51,9 @@ for(
z<23?(
O=new OscillatorNode(A,{
type:`square`,
detune:100*(d?`0x`+d-(s[c]==`!`)+(s[c]==`#`)+o-9:-9e9)
detune:100*(d?`0x`+d-(D==`!`)+(D==`#`)+o-9:-9e9)
}),
G=new GainNode(A,{gain:.5**(14-v/5)}),
G=new GainNode(A,{gain:.5**(11-v/5)}),
O.connect(G),
G.connect(A.destination),
O.start(t),
@ -64,11 +64,11 @@ for(
// set note length
z<31?l=3<<(z-25):
// change channel
z<32?(T[Z]=t,t=T[Z=s[c++]+s[c++]|0]|0):
z<32?(T[Z]=t,t=T[Z=D+E]|0,c+=2):
// change tempo
z<33?u=s.slice(c,c+=3):
// change volume
v=s[c++]+s[c++]
(v=D+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)]

View file

@ -1,8 +1,3 @@
<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>;; @title nupa's theme
;; @authors nycki bsp
z00
@qcceg hcqeg dcdc d#h.d
@qcceg hcqeg dcd#d hc
z01
@-wc b! a a!
@-wc b! haqa!g -hc</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>
<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