This commit is contained in:
parent
968ec59529
commit
05d69fdefd
8 changed files with 111 additions and 51 deletions
|
@ -1,50 +0,0 @@
|
|||
<meta name="viewport" content="width=device-width">
|
||||
<textarea id="f">
|
||||
@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><br>
|
||||
<button onclick="
|
||||
const A=new AudioContext();
|
||||
// tempo
|
||||
r=.4;
|
||||
e='exponentialRampToValueAtTime';
|
||||
// play note with pitch and duration
|
||||
p=(h,t,u)=>{
|
||||
a=A.createOscillator();
|
||||
const b=A.createGain();
|
||||
a.connect(b);
|
||||
b.connect(A.destination);
|
||||
a.frequency.value=h;
|
||||
a.start(t*r);
|
||||
b.gain[e](1,t*r+.1);
|
||||
b.gain[e](0.001,u*r);
|
||||
};
|
||||
// read text from input
|
||||
v=window.location.search.slice(1)||f.value;f.value=v;
|
||||
for(i=t=o=m=0,l=1;c=v[i++],d=v[i];){
|
||||
// https://chriskallen.com/zzt/zztoop.php#sound
|
||||
// look-ahead for accidentals
|
||||
m=d=='#'?1:d=='!'?-1:0;
|
||||
s=n=>()=>p(440*Math.pow(2,(n+m+o)/12),t,t+=l);
|
||||
q=n=>()=>l=n;
|
||||
x=()=>t+=l;
|
||||
g=[
|
||||
// c major scale
|
||||
s(-9),s(-7),s(-5),s(-4),s(-2),s(0),s(2),
|
||||
// octaves
|
||||
()=>o-=12,()=>o+=12,
|
||||
// change duration
|
||||
q(4),q(2),q(1),q(.5),q(.25),q(.125),q(l/3),q(l*1.5),
|
||||
// reset
|
||||
()=>(o=0,l=.125),
|
||||
// rest, sound effects not implemented
|
||||
x,x,x,x,x,x,x,x,x,x,
|
||||
]['cdefgab-+whqist3.@x012456789'.indexOf(c.toLowerCase())];
|
||||
g&&g();
|
||||
}
|
||||
">#play</button>
|
|
@ -1 +0,0 @@
|
|||
<meta name="viewport" content="width=device-width"><textarea id="f"></textarea><br><button onclick="A=new AudioContext();r=.4;p=(h,t,u)=>{a=A.createOscillator();a.connect(A.destination);a.frequency.value=h;a.start(t*r);a.stop(u*r);};v=window.location.search.slice(1)||f.value;f.value=v;for(i=t=o=m=0,l=1;c=v[i++],d=v[i];){m=d=='#'?1:d=='!'?-1:0;s=n=>()=>p(440*Math.pow(2,(n+m+o)/12),t,t+=l);q=n=>()=>l=n;x=()=>t+=l;g=[s(-9),s(-7),s(-5),s(-4),s(-2),s(0),s(2),()=>o-=12,()=>o+=12,q(4),q(2),q(1),q(.5),q(.25),q(.125),q(l/3),q(l*1.5),()=>(o=0,l=.125),x,x,x,x,x,x,x,x,x,x,]['cdefgab-+whqist3.@x012456789'.indexOf(c.toLowerCase())];g&&g();}">#play</button>
|
27
static/qrplay/golf.html
Normal file
27
static/qrplay/golf.html
Normal file
|
@ -0,0 +1,27 @@
|
|||
<!-- https://bark.lgbt/@SArpnt@fe.disroot.org/114810256295973439 -->
|
||||
<textarea onblur='
|
||||
v=this.value;
|
||||
A=new AudioContext;
|
||||
for(
|
||||
i=t=o=0,l=1;
|
||||
c=v[i++],d=v[i],c;
|
||||
|
||||
z<0?0: // no match
|
||||
z>17?t+=l: // rest
|
||||
z<4? // @-+
|
||||
z?o+=g: // change octave
|
||||
(o=0,l=1/8): // @
|
||||
z&1?l=g: // change speed
|
||||
( // note
|
||||
a=new OscillatorNode(A,{
|
||||
type:`square`,
|
||||
detune:100*(g+o+(d==`#`)-(d==`!`)) // # sharp or ! flat
|
||||
}),
|
||||
a.connect(A.destination),
|
||||
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.x012456789`.indexOf(c.toLowerCase())]
|
||||
'>
|
83
static/qrplay/index.html
Normal file
83
static/qrplay/index.html
Normal file
|
@ -0,0 +1,83 @@
|
|||
<!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 SArpnt 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">
|
||||
<textarea id=f></textarea><br>
|
||||
<button onclick='
|
||||
v=f.value;
|
||||
A=new AudioContext;
|
||||
for(
|
||||
i=t=o=0,l=1;
|
||||
c=v[i++],d=v[i],c;
|
||||
|
||||
z<0?0: // no match
|
||||
z>17?t+=l: // rest
|
||||
z<4? // @-+
|
||||
z?o+=g: // change octave
|
||||
(o=0,l=1/8): // @
|
||||
z&1?l=g: // change speed
|
||||
( // note
|
||||
a=new OscillatorNode(A,{
|
||||
type:`square`,
|
||||
detune:100*(g+o+(d==`#`)-(d==`!`)) // # sharp or ! flat
|
||||
}),
|
||||
a.connect(A.destination),
|
||||
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.x012456789`.indexOf(c.toLowerCase())]
|
||||
'>#play</button>
|
||||
<!-- stop snipping here -->
|
||||
|
||||
<script>f.value=f.value||window.location.search.slice(1)||`@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`</script>
|
||||
|
||||
<hr>
|
||||
|
||||
<table style="text-align: center;">
|
||||
<tr><td>qrplay</td><td>Solfeggetio in C Minor</td></tr>
|
||||
<tr>
|
||||
<td>
|
||||
<img src="qrplay.png">
|
||||
</td>
|
||||
<td>
|
||||
<img src="qrplay-solfeggettio.png">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><textarea>data:text/html;base64,PG1ldGEgbmFtZT0idmlld3BvcnQiIGNvbnRlbnQ9IndpZHRoPWRldmljZS13aWR0aCI+PHRleHRhcmVhIGlkPWY+PC90ZXh0YXJlYT48YnI+PGJ1dHRvbiBvbmNsaWNrPSd2PWYudmFsdWU7QT1uZXcgQXVkaW9Db250ZXh0O2ZvcihpPXQ9bz0wLGw9MTtjPXZbaSsrXSxkPXZbaV0sYzt6PDA/MDp6PjE3P3QrPWw6ejw0P3o/bys9Zzoobz0wLGw9MS84KTp6JjE/bD1nOihhPW5ldyBPc2NpbGxhdG9yTm9kZShBLHt0eXBlOmBzcXVhcmVgLGRldHVuZToxMDAqKGcrbysoZD09YCNgKS0oZD09YCFgKSl9KSxhLmNvbm5lY3QoQS5kZXN0aW5hdGlvbiksYS5zdGFydCh0Ki40KSx0Kz1sLGEuc3RvcCh0Ki40KSkpZz1bLC0xMiwxMiw0LC05LDIsLTcsMSwtNSwuNSwtNCwuMjUsLTIsMS84LDAsbC8zLDIsbCoxLjVdW3o9YEAtK3djaGRxZWlmc2d0YTNiLngwMTI0NTY3ODlgLmluZGV4T2YoYy50b0xvd2VyQ2FzZSgpKV0nPiNwbGF5PC9idXR0b24+</textarea></td>
|
||||
<td><textarea>@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>
|
1
static/qrplay/min.html
Normal file
1
static/qrplay/min.html
Normal file
|
@ -0,0 +1 @@
|
|||
data:text/html;base64,PG1ldGEgbmFtZT0idmlld3BvcnQiIGNvbnRlbnQ9IndpZHRoPWRldmljZS13aWR0aCI+PHRleHRhcmVhIGlkPWY+PC90ZXh0YXJlYT48YnI+PGJ1dHRvbiBvbmNsaWNrPSd2PWYudmFsdWU7QT1uZXcgQXVkaW9Db250ZXh0O2ZvcihpPXQ9bz0wLGw9MTtjPXZbaSsrXSxkPXZbaV0sYzt6PDA/MDp6PjE3P3QrPWw6ejw0P3o/bys9Zzoobz0wLGw9MS84KTp6JjE/bD1nOihhPW5ldyBPc2NpbGxhdG9yTm9kZShBLHt0eXBlOmBzcXVhcmVgLGRldHVuZToxMDAqKGcrbysoZD09YCNgKS0oZD09YCFgKSl9KSxhLmNvbm5lY3QoQS5kZXN0aW5hdGlvbiksYS5zdGFydCh0Ki40KSx0Kz1sLGEuc3RvcCh0Ki40KSkpZz1bLC0xMiwxMiw0LC05LDIsLTcsMSwtNSwuNSwtNCwuMjUsLTIsMS84LDAsbC8zLDIsbCoxLjVdW3o9YEAtK3djaGRxZWlmc2d0YTNiLngwMTI0NTY3ODlgLmluZGV4T2YoYy50b0xvd2VyQ2FzZSgpKV0nPiNwbGF5PC9idXR0b24+
|
BIN
static/qrplay/qrplay-solfeggettio.png
Normal file
BIN
static/qrplay/qrplay-solfeggettio.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 600 B |
BIN
static/qrplay/qrplay.png
Normal file
BIN
static/qrplay/qrplay.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
Loading…
Add table
Reference in a new issue