parent
c2b4088a6c
commit
12e098255d
3 changed files with 119 additions and 102 deletions
117
static/qrplay/v3b.html
Normal file
117
static/qrplay/v3b.html
Normal file
|
@ -0,0 +1,117 @@
|
|||
<META NAME=VIEWPORT CONTENT=INITIAL=SCALE=1>
|
||||
<CENTER>
|
||||
<P><A HREF=http://nycki.net/qrplay>qrplay v3b</A></P>
|
||||
<TEXTAREA ID=F STYLE=WIDTH:MIN(40EM,99%);HEIGHT:9LH>; drum samples!
|
||||
i 0000 1111 2222 4444 5555 6666 7777 8888 9999
|
||||
|
||||
hx@
|
||||
|
||||
; you can overwrite samples
|
||||
0[-c+c]
|
||||
00000000
|
||||
|
||||
hx@
|
||||
|
||||
; state is NOT preserved when playing samples
|
||||
0[cdefgab+]
|
||||
0000
|
||||
|
||||
; state IS preserved during parallel play
|
||||
@q {-ggeec}
|
||||
cdefg
|
||||
|
||||
hx@
|
||||
|
||||
; infinite loop
|
||||
0[i9x9x6xxx0]
|
||||
0
|
||||
</TEXTAREA><P>
|
||||
<BUTTON onclick="
|
||||
F.A?.close();
|
||||
F.A=A=new AudioContext;
|
||||
// kill some time for the audio context to start?
|
||||
S='@xx'+F.value;
|
||||
// stack
|
||||
B=[];
|
||||
// stack variables
|
||||
K=O=T=Z=L=0;
|
||||
U=137;
|
||||
V=40;
|
||||
// samples
|
||||
C=[
|
||||
'+g',
|
||||
'-b+c#deff#g',
|
||||
'g++ddb--g++ddb',
|
||||
,
|
||||
'+ea-g--b++g++c#',
|
||||
'a#ga#g-a#+g-b+g',
|
||||
'-a++c#-aae+e--a',
|
||||
'-ffed#ddc#',
|
||||
'dddddd#e',
|
||||
'--ba#bb-a+a#-b'
|
||||
].map(c=>`{o06m${c}}x`);
|
||||
|
||||
// main loop
|
||||
M=_=>{
|
||||
[a,b,c,d]=S;
|
||||
// next index into S
|
||||
s=1;
|
||||
// opcode
|
||||
z='\n;+-@.3cdefgabx012456789jtsiqhwmuvo{}'.indexOf(a);
|
||||
|
||||
// no match
|
||||
z<0?0:
|
||||
// comment
|
||||
z<2?K=z:K?0:
|
||||
// octave
|
||||
z<4?O+=a+1|0:
|
||||
// reset octave and length
|
||||
z<5?(O=0,L=1):
|
||||
// dots and triplets
|
||||
z<6?L*=3/2:
|
||||
z<7?L/=3:
|
||||
// note or rest
|
||||
z<15?(
|
||||
z-=7,
|
||||
o=new OscillatorNode(A,{
|
||||
type:'square',
|
||||
detune:100*(z*2-(z>2)-(b=='!')+(b=='#')+12*O-9)
|
||||
}),
|
||||
g=new GainNode(A,{gain:z<7&&.5**(12-V/5)}),
|
||||
o.connect(g),
|
||||
g.connect(A.destination),
|
||||
o.start(T),
|
||||
o.stop(T+=7.5*L/U)
|
||||
):
|
||||
// store sample
|
||||
z<22&&b=='['?(
|
||||
m=0,
|
||||
d=B.findIndex.call(S,c=>
|
||||
c=='['?!++m:
|
||||
c==']'?!--m:
|
||||
0
|
||||
),
|
||||
C[a]=S.slice(s,d),
|
||||
s=d+1
|
||||
):
|
||||
// play sample
|
||||
z<24?S=C[a]+S.slice(s--):
|
||||
// set note length
|
||||
z<31?L=2**(z-25):
|
||||
// set note length (microtone)
|
||||
z<32?L=U/2**11:
|
||||
// change tempo in bpm
|
||||
z<33?(U=b+c+d,s+=3):
|
||||
// change volume
|
||||
z<34?(V=b+c,s+=2):
|
||||
// change octave
|
||||
z<35?(O=b+c-4,s+=2):
|
||||
// play simultaneously
|
||||
z<36?B[Z++]={L,O,T,U,V}:
|
||||
{L,O,T,U,V}=B[--Z];
|
||||
|
||||
// loop
|
||||
S=S.slice(s);
|
||||
S&&setTimeout(M)
|
||||
};M()
|
||||
">#play</BUTTON> <BUTTON ONCLICK=F.A.close()>#stop</BUTTON>
|
|
@ -1,102 +1 @@
|
|||
<META NAME=VIEWPORT CONTENT=INITIAL=SCALE=1>
|
||||
<CENTER>
|
||||
<P><A HREF=http://nycki.net/qrplay>qrplay v3b</A></P>
|
||||
<TEXTAREA ID=F STYLE=WIDTH:MIN(40EM,99%);HEIGHT:9LH>; drum samples!
|
||||
i 0000 1111 2222 4444 5555 6666 7777 8888 9999
|
||||
|
||||
hx@
|
||||
|
||||
; you can overwrite samples
|
||||
0[-c+c]
|
||||
00000000
|
||||
|
||||
hx@
|
||||
|
||||
; state is NOT preserved when playing samples
|
||||
0[cdefgab+]
|
||||
0000
|
||||
|
||||
; state IS preserved during parallel play
|
||||
@q {-ggeec}
|
||||
cdefg
|
||||
|
||||
hx@
|
||||
|
||||
; infinite loop
|
||||
0[i9x9x6xxx0]
|
||||
0
|
||||
</textarea><p>
|
||||
<button onclick="
|
||||
F.A?.close();
|
||||
F.A=A=new AudioContext;
|
||||
S='@'+F.value;
|
||||
// stack
|
||||
B=[];
|
||||
// stack variables
|
||||
K=O=T=Z=L=0;
|
||||
U=137;
|
||||
V=40;
|
||||
// samples
|
||||
C=[];
|
||||
|
||||
// main loop
|
||||
M=()=>{
|
||||
[a,b,c]=S;
|
||||
// next index into S
|
||||
s=1;
|
||||
// opcode
|
||||
z='\n;+-@.3cdefgabx012456789jtsiqhwmuvo{}'.indexOf(a);
|
||||
|
||||
// no match
|
||||
z<0?0:
|
||||
|
||||
// comment
|
||||
z<2?K=z:K?0:
|
||||
|
||||
// octave
|
||||
z<4?O+=a+1|0:
|
||||
|
||||
// reset octave and length
|
||||
z<5?(O=0,L=1):
|
||||
|
||||
// dots and triplets
|
||||
z<6?L*=3/2:
|
||||
z<7?L/=3:
|
||||
|
||||
// note or rest
|
||||
z<13?(
|
||||
z-=7,
|
||||
o=new OscillatorNode(A,{
|
||||
type:'square',
|
||||
detune:100*(z*2-(z>2)-(b=='!')+(b=='#')+12*O-9)
|
||||
}),
|
||||
g=new GainNode(A,{gain:z<7&&.5**(12-V/5)}),
|
||||
o.connect(g),
|
||||
g.connect(A.destination),
|
||||
o.start(T),
|
||||
o.stop(T+=7.5*L/U)
|
||||
):
|
||||
|
||||
// store sample
|
||||
z<22&&b=='['?(
|
||||
m=0,
|
||||
d=B.findIndex.call(S,c=>
|
||||
c=='['?!++m:
|
||||
c==']'?!--m:
|
||||
0
|
||||
),
|
||||
C[a]=S.slice(s,d),
|
||||
s=d+1
|
||||
):
|
||||
|
||||
// play sample
|
||||
z<22?S=C[a]+S.slice(s):
|
||||
|
||||
// do nothing
|
||||
0;
|
||||
|
||||
// loop
|
||||
S=S.slice(s);
|
||||
S&&setTimeout(M)
|
||||
};M()
|
||||
">#play</BUTTON>
|
||||
<META NAME=VIEWPORT CONTENT=INITIAL=SCALE=1><CENTER><P><A HREF=http://nycki.net/qrplay>qrplay v3b</A></P><TEXTAREA ID=F STYLE=WIDTH:MIN(40EM,99%);HEIGHT:9LH></TEXTAREA><P><BUTTON onclick="F.A?.close();F.A=A=new AudioContext;S='@xx'+F.value;B=[];K=O=T=Z=L=0;U=137;V=40;C=['+g','-b+c#deff#g','g++ddb--g++ddb',,'+ea-g--b++g++c#','a#ga#g-a#+g-b+g','-a++c#-aae+e--a','-ffed#ddc#','dddddd#e','--ba#bb-a+a#-b'].map(c=>`{o06m${c}}x`);M=_=>{[a,b,c,d]=S;s=1;z='\n;+-@.3cdefgabx012456789jtsiqhwmuvo{}'.indexOf(a);z<0?0:z<2?K=z:K?0:z<4?O+=a+1|0:z<5?(O=0,L=1):z<6?L*=3/2:z<7?L/=3:z<15?(z-=7,o=new OscillatorNode(A,{type:'square',detune:100*(z*2-(z>2)-(b=='!')+(b=='#')+12*O-9)}),g=new GainNode(A,{gain:z<7&&.5**(12-V/5)}),o.connect(g),g.connect(A.destination),o.start(T),o.stop(T+=7.5*L/U)):z<22&&b=='['?(m=0,d=B.findIndex.call(S,c=>c=='['?!++m:c==']'?!--m:0),C[a]=S.slice(s,d),s=d+1):z<24?S=C[a]+S.slice(s--):z<31?L=2**(z-25):z<32?L=U/2**11:z<33?(U=b+c+d,s+=3):z<34?(V=b+c,s+=2):z<35?(O=b+c-4,s+=2):z<36?B[Z++]={L,O,T,U,V}:{L,O,T,U,V}=B[--Z];S=S.slice(s);S&&setTimeout(M)};M()">#play</BUTTON> <BUTTON ONCLICK=F.A.close()>#stop</BUTTON>
|
1
static/qrplay/v3b.min.txt
Normal file
1
static/qrplay/v3b.min.txt
Normal file
|
@ -0,0 +1 @@
|
|||
data:text/html,<META%20NAME=VIEWPORT%20CONTENT=INITIAL=SCALE=1><CENTER><P><A%20HREF=http://nycki.net/qrplay>qrplay%20v3b</A></P><TEXTAREA%20ID=F%20STYLE=WIDTH:MIN(40EM,99%);HEIGHT:9LH></TEXTAREA><P><BUTTON%20onclick="F.A?.close();F.A=A=new%20AudioContext;S='@xx'+F.value;B=[];K=O=T=Z=L=0;U=137;V=40;C=['+g','-b+c%23deff%23g','g++ddb--g++ddb',,'+ea-g--b++g++c%23','a%23ga%23g-a%23+g-b+g','-a++c%23-aae+e--a','-ffed%23ddc%23','dddddd%23e','--ba%23bb-a+a%23-b'].map(c=>`{o06m${c}}x`);M=_=>{[a,b,c,d]=S;s=1;z='\n;+-@.3cdefgabx012456789jtsiqhwmuvo{}'.indexOf(a);z<0?0:z<2?K=z:K?0:z<4?O+=a+1|0:z<5?(O=0,L=1):z<6?L*=3/2:z<7?L/=3:z<15?(z-=7,o=new%20OscillatorNode(A,{type:'square',detune:100*(z*2-(z>2)-(b=='!')+(b=='%23')+12*O-9)}),g=new%20GainNode(A,{gain:z<7&&.5**(12-V/5)}),o.connect(g),g.connect(A.destination),o.start(T),o.stop(T+=7.5*L/U)):z<22&&b=='['?(m=0,d=B.findIndex.call(S,c=>c=='['?!++m:c==']'?!--m:0),C[a]=S.slice(s,d),s=d+1):z<24?S=C[a]+S.slice(s--):z<31?L=2**(z-25):z<32?L=U/2**11:z<33?(U=b+c+d,s+=3):z<34?(V=b+c,s+=2):z<35?(O=b+c-4,s+=2):z<36?B[Z++]={L,O,T,U,V}:{L,O,T,U,V}=B[--Z];S=S.slice(s);S&&setTimeout(M)};M()">%23play</BUTTON>%20<BUTTON%20ONCLICK=F.A.close()>%23stop</BUTTON>
|
Loading…
Add table
Reference in a new issue