parent
819fda5985
commit
80a8c741df
1 changed files with 10 additions and 11 deletions
|
@ -28,25 +28,26 @@
|
|||
<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();
|
||||
s=`@`+f.value.toLowerCase();
|
||||
f.A?.close();
|
||||
A=f.A=new AudioContext;
|
||||
// time per-channel
|
||||
T=[];
|
||||
// tempo in beats per minute
|
||||
u=137;
|
||||
// volume. 50 is max, 45 is half, 40 is half again...
|
||||
// volume. 40 is default, 35 is half, 30 is half again.
|
||||
v=40;
|
||||
for(
|
||||
c=t=o=k=Z=0,l=3;D=s[c+1],E=D+s[c+2],C=s[c++];
|
||||
c=t=k=Z=0;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+=C+12|0:
|
||||
// triplets and dots
|
||||
z<6?l*=3/d:
|
||||
// dots and triplets
|
||||
z<5?l*=3/2:
|
||||
z<6?l/=3:
|
||||
// note or rest (percussion not implemented)
|
||||
z<23?(
|
||||
z-=6,
|
||||
|
@ -54,24 +55,22 @@ for(
|
|||
type:`square`,
|
||||
detune:100*(z*2-(z>3)-(D==`!`)+(D==`#`)+o-9)
|
||||
}),
|
||||
G=new GainNode(A,{gain:z<7&&.5**(11-v/5)}),
|
||||
G=new GainNode(A,{gain:z<7&&.5**(12-v/5)}),
|
||||
O.connect(G),
|
||||
G.connect(A.destination),
|
||||
O.start(t),
|
||||
O.stop(t+=2.5*l/u)
|
||||
O.stop(t+=7.5*l/u)
|
||||
):
|
||||
// reset octave and duration
|
||||
z<24?(o=0,l=3):
|
||||
z<24?(o=0,l=1):
|
||||
// set note length
|
||||
z<31?l=3<<(z-25):
|
||||
z<31?l=2**(z-25):
|
||||
// change channel
|
||||
z<32?(T[Z]=t,t=T[Z=E]|0,c+=2):
|
||||
// change tempo
|
||||
z<33?u=E+s[c+=2,c++]:
|
||||
// change volume
|
||||
(v=E,c+=2)
|
||||
// TODO combine all these slice operations into one branch
|
||||
// d is additional data that varies with the operation.
|
||||
)z=`\n;-+.3cdefgab012456789x@jtsiqhwzuv`.indexOf(C)
|
||||
'>#play</button> <button onclick=f.A.close()>#stop</button>
|
||||
<!-- stop snipping here -->
|
||||
|
|
Loading…
Add table
Reference in a new issue