101 lines
		
	
	
		
			No EOL
		
	
	
		
			3.8 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			101 lines
		
	
	
		
			No EOL
		
	
	
		
			3.8 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
| <!doctype html>
 | |
| <html lang="en">
 | |
| <head>
 | |
|     <title>qrplay</title>
 | |
| </head>
 | |
| <body>
 | |
| 
 | |
| <nav><a href="/">home</a></nav>
 | |
| 
 | |
| <h2>qrplay by nycki and SArpnt</h2>
 | |
| <p>a QR-code sized implementation of ZZT Play, which you may know from the <a href="https://chriskallen.com/zzt/hallofmusic.html">ZZT Hall of Music</a>.</p> 
 | |
| 
 | |
| <p>I designed this because I wanted a program I could print on a business card, and <a href="https://git.disroot.org/SArpnt">SArpnt</a> found some clever ways to shrink it even further. The version on this page is commented, the version in the QR code is minified.</p>
 | |
| 
 | |
| <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">
 | |
| <textarea id=f></textarea><br>
 | |
| <button onclick='
 | |
| /*qrplay v2, nycki & SArpnt, 2025*/
 | |
| f.A&&f.A.close();
 | |
| f.A=A=new AudioContext;
 | |
| v=f.value;
 | |
| T=[];Z=0; // channels
 | |
| B=new GainNode(A,{gain:0.1});
 | |
| B.connect(A.destination);
 | |
| for(
 | |
| 	i=o=k=t=0,l=1;
 | |
| 	c=v[i++],d=v[i],c;
 | |
| 
 | |
| 	z<0?0: // no match
 | |
| 	z>29?k=1: // start of comment. P, O, V, U, K, R, not implemented.
 | |
| 	z>28?k=0: // end of comment
 | |
| 	k?0: // 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): // @
 | |
| 	(console.log(z),z)&1?console.log(l=g): // change speed
 | |
| 	( // note
 | |
| 		a=new OscillatorNode(A,{
 | |
| 			type:`square`,
 | |
| 			detune:100*(g+o+(d==`#`)-(d==`!`)) // # sharp or ! flat
 | |
| 		}),
 | |
| 		a.connect(B),
 | |
| 		a.start(t*.4),
 | |
| 		t+=l,
 | |
| 		a.stop(t*.4)
 | |
| 	)
 | |
| )
 | |
| 	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>
 | |
| <!-- stop snipping here -->
 | |
| 
 | |
| <button onclick='
 | |
| window.location.search = "?"+f.value.replaceAll(" ","%20").replaceAll("\n","%0a").replaceAll("#","%23");
 | |
| '>#save</button>
 | |
| 
 | |
| <script>
 | |
| f.value=f.value||window.location.search.slice(1)||`'Solfeggettio in C Minor by JS Bach
 | |
| @i-e!ce!g+ce!dc-bgb+dgfe!de!
 | |
| @ice!g+ce!dcdc-bagfe!d
 | |
| @ie!ce!g+ce!dc-bgb+dgfe!d
 | |
| @i+e!ce!g+ce!dcdc-bagfe!d
 | |
| @i+e!c-ge!c++c-ge!a!--fa!+cfa!+ce!
 | |
| @i+d-b!fd-b!++b!fdg--e!gb!+dgb!+d
 | |
| @i+ge!dc-ge!dh.c`;
 | |
| f.value=f.value.replaceAll('%20', ' ').replaceAll('%0a','\n').replaceAll('%0A','\n').replaceAll('%23', '#');
 | |
| </script>
 | |
| 
 | |
| <hr>
 | |
| 
 | |
| <table style="text-align: center;">
 | |
|     <tr><td>qrplay</td><td>Solfeggetio in C Minor</td></tr>
 | |
|     <tr>
 | |
|         <td>
 | |
|             <img src="qrplay-v1.png">
 | |
|         </td>
 | |
|         <td>
 | |
|             <img src="qrplay-solfeggettio.png">
 | |
|         </td>
 | |
|     </tr>
 | |
|     <tr>
 | |
|         <td><textarea>data:text/html,<meta%20name="viewport"%20content="width=device-width%20initial-scale=1.0"><textarea%20id=f></textarea><br><button%20onclick='/*qrplay%20v1,%20nycki%20&%20SArpnt,%202025*/v=f.value;T=[];Z=0;f.A=A=f.A||new%20AudioContext;B=new%20GainNode(A,{gain:0.4});B.connect(A.destination);for(i=o=k=t=0,l=1;c=v[i++],d=v[i],c;z<0?0:z>29?k=1:z>28?k=0:k?0:z>27?(T[Z]=t,Z=+v.slice(i,i+=2),t=T[Z]||0):z>17?t+=l:z<3?z?o+=g:(o=0,l=1/8):(console.log(z),z)&1?console.log(l=g):(a=new%20OscillatorNode(A,{type:`square`,detune:100*(g+o+(d==`%23`)-(d==`!`))}),a.connect(B),a.start(t*.4),t+=l,a.stop(t*.4)))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())]'>%23play</button><button%20onclick='f.A.close();f.A=0'>%23stop</button></textarea></td>
 | |
|         <td><textarea>'Solfeggettio in C Minor by JS Bach
 | |
| @i-e!ce!g+ce!dc-bgb+dgfe!de!
 | |
| @ice!g+ce!dcdc-bagfe!d
 | |
| @ie!ce!g+ce!dc-bgb+dgfe!d
 | |
| @i+e!ce!g+ce!dcdc-bagfe!d
 | |
| @i+e!c-ge!c++c-ge!a!--fa!+cfa!+ce!
 | |
| @i+d-b!fd-b!++b!fdg--e!gb!+dgb!+d
 | |
| @i+ge!dc-ge!dh.c</textarea></td>
 | |
|     </tr>
 | |
| </table>
 | |
| 
 | |
| <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>
 | |
| 
 | |
| </body>
 | |
| </html> |