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>
|
<p><a href=http://nycki.net/qrplay>qrplay v2c</a></p>
|
||||||
<textarea id=f style=width:min(40em,99%);height:9lh></textarea><p>
|
<textarea id=f style=width:min(40em,99%);height:9lh></textarea><p>
|
||||||
<button onclick='
|
<button onclick='
|
||||||
s=f.value.toLowerCase();
|
s=`@`+f.value.toLowerCase();
|
||||||
f.A?.close();
|
f.A?.close();
|
||||||
A=f.A=new AudioContext;
|
A=f.A=new AudioContext;
|
||||||
// time per-channel
|
// time per-channel
|
||||||
T=[];
|
T=[];
|
||||||
// tempo in beats per minute
|
// tempo in beats per minute
|
||||||
u=137;
|
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;
|
v=40;
|
||||||
for(
|
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
|
// no match
|
||||||
z<0?0:
|
z<0?0:
|
||||||
// comments
|
// comments
|
||||||
z<2?k=z:k?0:
|
z<2?k=z:k?0:
|
||||||
// - + octave
|
// - + octave
|
||||||
z<4?o+=C+12|0:
|
z<4?o+=C+12|0:
|
||||||
// triplets and dots
|
// dots and triplets
|
||||||
z<6?l*=3/d:
|
z<5?l*=3/2:
|
||||||
|
z<6?l/=3:
|
||||||
// note or rest (percussion not implemented)
|
// note or rest (percussion not implemented)
|
||||||
z<23?(
|
z<23?(
|
||||||
z-=6,
|
z-=6,
|
||||||
|
@ -54,24 +55,22 @@ for(
|
||||||
type:`square`,
|
type:`square`,
|
||||||
detune:100*(z*2-(z>3)-(D==`!`)+(D==`#`)+o-9)
|
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),
|
O.connect(G),
|
||||||
G.connect(A.destination),
|
G.connect(A.destination),
|
||||||
O.start(t),
|
O.start(t),
|
||||||
O.stop(t+=2.5*l/u)
|
O.stop(t+=7.5*l/u)
|
||||||
):
|
):
|
||||||
// reset octave and duration
|
// reset octave and duration
|
||||||
z<24?(o=0,l=3):
|
z<24?(o=0,l=1):
|
||||||
// set note length
|
// set note length
|
||||||
z<31?l=3<<(z-25):
|
z<31?l=2**(z-25):
|
||||||
// change channel
|
// change channel
|
||||||
z<32?(T[Z]=t,t=T[Z=E]|0,c+=2):
|
z<32?(T[Z]=t,t=T[Z=E]|0,c+=2):
|
||||||
// change tempo
|
// change tempo
|
||||||
z<33?u=E+s[c+=2,c++]:
|
z<33?u=E+s[c+=2,c++]:
|
||||||
// change volume
|
// change volume
|
||||||
(v=E,c+=2)
|
(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)
|
)z=`\n;-+.3cdefgab012456789x@jtsiqhwzuv`.indexOf(C)
|
||||||
'>#play</button> <button onclick=f.A.close()>#stop</button>
|
'>#play</button> <button onclick=f.A.close()>#stop</button>
|
||||||
<!-- stop snipping here -->
|
<!-- stop snipping here -->
|
||||||
|
|
Loading…
Add table
Reference in a new issue