cleanup based on SArpnts suggestions
All checks were successful
/ build (push) Successful in 44s

This commit is contained in:
Nycki 2025-07-07 16:12:43 -07:00
parent 91dc80dc23
commit 86b373dc6a

View file

@ -15,11 +15,11 @@
<p>paste ZZT music code in this box, then click the button to #play!</p>
<!-- snip here -->
<meta name="viewport" content="width=device-width initial-scale=1.0">
<meta name=viewport content=width=device-width,initial-scale=1>
<textarea id=f></textarea><br>
<button onclick='
<button onclick="
/*qrplay v2a, nycki & SArpnt, 2025*/
f.A&&f.A.close();
f.A?.close(); // throws exception if already stopped, but I dont care :3
B=new GainNode(f.A=A=new AudioContext,{gain:0.1});
B.connect(A.destination);
r=.4; // speed in s/beat
@ -41,17 +41,17 @@ for(
z<3?
z?o+=g: // -+ change octave
(o=0,l=1/8): // @ reset
z&1?console.log(l=g): // change note length
z&1?l=g: // change note length
( // play note
a=new OscillatorNode(A,{
type:`square`,
detune:100*(g+o+(d==`#`)-(d==`!`)) // # sharp or ! flat
type:'square',
detune:100*(g+o+(d=='#')-(d=='!')) // # sharp or ! flat
}),
a.connect(B),a.start(t*r),t+=l,a.stop(t*r)
)
// 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\x27`.indexOf(c.toLowerCase())]
'>#play</button> <button onclick='f.A.close()'>#stop</button>
) 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</button> <button onclick=f.A.close()>#stop</button>
<!-- stop snipping here -->
<button onclick='
@ -59,13 +59,6 @@ for(
window.location.search = "?"+f.value.replaceAll(" ","%20").replaceAll("\n","%0a").replaceAll("#","%23");
'>#save</button>
<script>
f.value=(f.value
|| window.location.search.slice(1).replaceAll('%20', ' ').replaceAll('%0a','\n').replaceAll('%0A','\n').replaceAll('%23', '#')
|| s.value
);
</script>
<hr>
<table style="text-align: center;">
@ -93,5 +86,12 @@ f.value=(f.value
<p>for security reasons, your phone probably won't open these as links. you'll have to copy and paste the text into your browser's uri input.</p>
<script>
// set default value for input
f.value=(f.value
|| window.location.search.slice(1).replaceAll('%20', ' ').replaceAll('%0a','\n').replaceAll('%0A','\n').replaceAll('%23', '#')
|| s.value
);
</script>
</body>
</html>