128 lines
No EOL
2.7 KiB
HTML
128 lines
No EOL
2.7 KiB
HTML
<!--
|
|
modified version of SArpnt's player (see /golf3.html)
|
|
compatible with QR alphanumeric mode or with ZZM files
|
|
|
|
reference
|
|
A: Audio context
|
|
C: Command Character
|
|
D: character after C, or other Data
|
|
F: main Function, also object that holds samples
|
|
G: Gain node
|
|
H: textarea Html element
|
|
I: Index into M
|
|
J: lookahead (for sharps and flats)
|
|
L: note Length
|
|
M: Music text
|
|
N: semitone Note offset (for octave changes)
|
|
O: Oscillator node
|
|
P: current time step
|
|
Q: numeric command id
|
|
S: find Sample
|
|
T: note Time
|
|
U: bpm
|
|
W: realtime When the song starts
|
|
-->
|
|
|
|
|
|
<!-- snip -->
|
|
<META NAME=VIEWPORT CONTENT=initial-scale=1>
|
|
<CENTER>
|
|
<P><A HREF=http://nycki.net/qrplay>qrplay v3e</A><br>by nycki and SArpnt</P>
|
|
<TEXTAREA ID=H STYLE=WIDTH:MIN(40EM,99%);HEIGHT:9LH>: $TITLE WiL Best :: Atrocity
|
|
: $SONG TITLE 1 The Forest Chase
|
|
s-a+ebaeagea+c-bgae+c-g
|
|
s-da+degf#dagedf#dcef#
|
|
s-a+ebaeagea+c-bgae+c-g
|
|
s-da+degf#dagedf#dega
|
|
s--g+g+bagdbf#bgdf#gab+c
|
|
scg+ce-g+e-g+cd-g+cc-g+cd-g
|
|
s-f+cf+c-afcfgcfacefe
|
|
s-eb+efg#ab+cd#efg#ab+fe
|
|
; $SONG ENDS
|
|
s-a+ebaeagea+c-bgae+c-g
|
|
s-da+degf#dagedf#dcef#
|
|
s-a+ebaeagea+c-bgae+c-g
|
|
s-da+degf#dagedf#dega
|
|
s--g+g+bagdbf#bgdf#gab+c
|
|
scg+ce-g+e-g+cd-g+cc-g+cd-g
|
|
s-f+cf+c-afcfgcfacefe
|
|
s-eb+efg#ab+cd#efg#ab+fe
|
|
</TEXTAREA><P>
|
|
<BUTTON onclick="
|
|
H.A?.close();
|
|
H.A=A=new AudioContext;
|
|
W=Date.now();
|
|
U=137;
|
|
F=(
|
|
M='',
|
|
T=0,
|
|
L,
|
|
N,
|
|
I=0,
|
|
K=0,
|
|
S=D=>D?S(D+(M[++I]==C)-(M[I]=='/')):I
|
|
)=>{for(;
|
|
C=M[I++];
|
|
D=M[I],
|
|
J=E=>E.indexOf(D)>=0,
|
|
P=L/U*15/8,
|
|
// start of comment
|
|
Q>24?K=1:
|
|
// reset
|
|
Q>23?(L=N=4,K=0):
|
|
// backspace
|
|
Q>22?T-=P:
|
|
// check comment mode
|
|
K?0:
|
|
// change octave
|
|
Q>20?N-=C+12:
|
|
Q>7?
|
|
// DECREMENT Q, and then...
|
|
(Q-=9)?
|
|
// triplet or dotted rhythm, C is 3 or .
|
|
Q>9?L/=+C||2/3:
|
|
Q>7?
|
|
// extended command. read two digits, then...
|
|
(D=D+M[++I,I++]|0)?
|
|
// set bpm (U)
|
|
Q>8?U=D+M[I++]:
|
|
// set volume (V)
|
|
G=new GainNode(A,{gain:2**(D/5-11)}):
|
|
0:
|
|
// else, set length to...
|
|
L=
|
|
// fixed length (JTSIQHW)
|
|
~Q?1<<Q:
|
|
// reset L=N=4
|
|
(K=0,N=4):
|
|
// save sample ($x.../)
|
|
F[D]=M.slice(++I,S(1)):
|
|
~Q?(
|
|
// play note or rest
|
|
O=new OscillatorNode(A,{
|
|
type: 'square',
|
|
// !: are flat, #* are sharp
|
|
detune:100*(Q*2-(Q>3)-J('!:')+J('#*')-N-7)
|
|
}),
|
|
Q&&O.connect(G),
|
|
G.connect(A.destination),
|
|
O.start(T),
|
|
O.stop(T+=P)
|
|
):
|
|
// any unused non-whitespace letter or number
|
|
C>'@'||1+C>1?(E=>setTimeout(
|
|
// play a sample async
|
|
_=>F(...E),
|
|
// don't async too far ahead or you'll lag us out
|
|
1e3*E[1]-Date.now()+W-5e3,
|
|
))([F[C],T+=P,L,N]):
|
|
// do nothing
|
|
0
|
|
)Q='XCDEFGABR$JTSIQHWVU3.-+P\n;/'.indexOf(C)},
|
|
F('RV35'+H.value.toUpperCase())
|
|
">#play</BUTTON> <BUTTON onclick=H.A.close()>#stop
|
|
|
|
<!-- snip -->
|
|
</BUTTON></P>
|
|
<img src="qrplay-v3d-nupas-theme.png">
|
|
</center> |