percussion!
All checks were successful
/ build (push) Successful in 34s

This commit is contained in:
Nycki 2025-07-10 01:59:51 -07:00
parent 80a8c741df
commit 1ec70b5c1d

View file

@ -37,6 +37,8 @@ T=[];
u=137;
// volume. 40 is default, 35 is half, 30 is half again.
v=40;
// percussion can be approximated as 1024th notes.
P=x=>(s=`z99l-5${x}o${o+4} l${Math.log2(l)} z${Z} x`+s.slice(c),c=0,T[99]=t);
for(
c=t=k=Z=0;D=s[c+1],E=D+s[c+2],C=s[c++];
// no match
@ -44,16 +46,21 @@ for(
// comments
z<2?k=z:k?0:
// - + octave
z<4?o+=C+12|0:
z<4?o+=C+1|0:
// dots and triplets
z<5?l*=3/2:
z<6?l/=3:
// note or rest (percussion not implemented)
// percussion
C==`0`?P(`o07g`):
C==`1`?P(`o05b+c#deff#gg#aa#b+cc#d`):
C==`2`?P(`o06g++ddb--g++ddb--g++ddb--g++ddb`):
C==`6`?P(`o05a++c#-aae+e--a++c#-aae+e--a++c#`):
// note or rest
z<23?(
z-=6,
O=new OscillatorNode(A,{
type:`square`,
detune:100*(z*2-(z>3)-(D==`!`)+(D==`#`)+o-9)
detune:100*(z*2-(z>2)-(D==`!`)+(D==`#`)+12*o-9)
}),
G=new GainNode(A,{gain:z<7&&.5**(12-v/5)}),
O.connect(G),
@ -66,12 +73,16 @@ for(
// set note length
z<31?l=2**(z-25):
// change channel
z<32?(T[Z]=t,t=T[Z=E]|0,c+=2):
z<32?(T[Z]=t,t=T[Z=E|0]||0,c+=2):
// change tempo
z<33?u=E+s[c+=2,c++]:
// change volume
(v=E,c+=2)
)z=`\n;-+.3cdefgab012456789x@jtsiqhwzuv`.indexOf(C)
z<34?(v=E,c+=2):
// set octave
z<35?(o=E-4,c+=2):
// set length
(l=2**E,c+=2)
)z=`\n;-+.3cdefgab012456789x@jtsiqhwzuvol`.indexOf(C)
'>#play</button> <button onclick=f.A.close()>#stop</button>
<!-- stop snipping here -->
</center>