Compare commits

...

2 commits

Author SHA1 Message Date
bfd199e414 comments
All checks were successful
/ build (push) Successful in 33s
2025-07-12 12:11:15 -07:00
07e22cd90f real-time feedback loop 2025-07-12 11:53:23 -07:00

View file

@ -27,12 +27,12 @@
<BUTTON onclick="
F.A?.close();
F.A=A=new AudioContext;
// kill some time for the audio context to start
S='@qx@'+F.value.toLowerCase();
D=Date.now();
S='@'+F.value.toLowerCase();
// stack
B=[];
// stack variables
K=O=T=Z=L=0;
K=L=O=T=Z=0;
U=137;
V=40;
// samples
@ -44,7 +44,7 @@ M=_=>{
// next index into S
s=1;
// opcode
z='\n;+-@.3cdefgabxjtsiqhwmuv{}012456789'.indexOf(a);
z='\n;+-@.3cdefgabxjtsiqhwmuv{}z012456789'.indexOf(a);
// do nothing
z<0?0:
@ -63,7 +63,7 @@ M=_=>{
type:'square',
detune:100*(z*2-(z>2)-(b=='!')+(b=='#')+12*O-9)
}),
g=new GainNode(A,{gain:z<7&&.5**(14-V/5)}),
g=new GainNode(A,{gain:z<7&&.5**(13-V/5)}),
o.connect(g),
g.connect(A.destination),
o.start(T),
@ -78,8 +78,9 @@ M=_=>{
// change volume
z<25?(V=b+c,s+=2):
// play simultaneously
z<26?B[Z++]={L,O,T,U,V}:
z<27?{L,O,T,U,V}=B[--Z]:
z<26?B[Z++]=[L,O,T,U,V]:z<27?[L,O,T,U,V]=B[--Z]:
// play on channel
z<28?B[B[Z]=[L,O,T,U,V],s=3,Z=b+c]=[L,O,T,U,V]=[1,0,0,U,V]:
// store sample
b=='['?(
m=0,
@ -94,7 +95,7 @@ M=_=>{
// play sample
S=C[a]+S.slice(s--);
// loop
(S=S.slice(s))&&setTimeout(M,50)
// loop (but don't get too far ahead)
A.state!='closed'&&(S=S.slice(s))&&setTimeout(M,1e3*T-Date.now()+D-5e3);
};M()
">#play</BUTTON> <BUTTON ONCLICK=F.A.close()>#stop