Lines Matching defs:s

62 function ToAudio(){return{add:function(first,voice_tb,cfmt){var toaud=this,C=abc2svg.C,p_time=0,abc_time=0,play_fac=C.BLEN/4*120/60,i,n,dt,d,v,c,s=first,rst=s,rst_fac,rsk,b_tim,b_typ,instr=[],chn=[]
63 function build_parts(first){var i,j,c,n,v,s=first,p=s.parts,st=[],r=""
83 s.parts=r
84 s.p_s=[]
85 while(1){if(!s.ts_next){s.part=first
87 s=s.ts_next
88 if(s.type==C.PART){s.part=first
89 v=s.text[0]
91 first.p_s[i]=s}}}}
108 function do_block(s){var v=s.v,c=chn[v]
109 switch(s.subtype){case"midichn":chn[v]=s.chn
111 case"midictl":switch(s.ctrl){case 0:instr[c]=(instr[c]&0x3fff)|(s.val<<14)
113 case 32:instr[c]=(instr[c]&0x1fc07f)|(s.val<<7)
117 s.chn=c
119 case"midiprog":instr[c]=(instr[c]&~0x7f)|s.instr
120 s.chn=c
122 function gen_grace(s){var g,i,n,t,d,s2,next=s.next
123 if(s.sappo){d=C.BLEN/16}else if((!next||next.type!=C.NOTE)&&s.prev&&s.prev.type==C.NOTE){d=s.prev.dur/2}else{d=next.dur/12
131 for(g=s.extra;g;g=g.next)
135 for(g=s.extra;g;g=g.next){g.ptim=t
137 g.chn=chn[s.v]
140 function set_tempo(s){var i,d=0,n=s.tempo_notes.length
142 d+=s.tempo_notes[i]
143 return d*s.tempo/60}
144 function set_variant(rsk,n,s){var d
145 n=n.match(/[1-8]-[2-9]|[1-9,.]|[^\s]+$/g)
151 rsk[i]=s
153 rsk[Number(d)]=s
155 rsk.push(s)}}
161 if(s.parts)
162 build_parts(s)
165 while(s){if(s.noplay){s=s.ts_next
167 dt=s.time-abc_time
169 abc_time=s.time}
170 s.ptim=p_time
171 switch(s.type){case C.BAR:if(s.time!=b_tim){b_tim=s.time
173 if(s.text&&rsk&&s.text[0]!='1'){if(b_typ&1)
176 set_variant(rsk,s.text,s)
179 if(s.bar_type[0]==':'){if(b_typ&2)
182 s.rep_p=rst
184 s.rep_v=rsk}
185 if(s.text){if(s.text[0]=='1'){if(b_typ&1)
188 s.rep_s=rsk=[rst]
191 set_variant(rsk,s.text,s)
192 rst_fac=play_fac}}else if(s.rbstop){if(s.bar_type.slice(-1)==':'){if(b_typ&4)
197 rst=s
200 case C.BLOCK:do_block(s)
202 case C.GRACE:if(s.time==0&&abc_time==0){dt=0
203 if(s.sappo)
205 else if(!s.next||s.next.type!=C.NOTE)
208 gen_grace(s)
210 case C.REST:case C.NOTE:d=s.dur
211 if(s.next&&s.next.type==C.GRACE){dt=0
212 if(s.next.sappo)
214 else if(!s.next.next||s.next.next.type!=C.NOTE)
216 s.next.time-=dt
219 s.pdur=d
220 v=s.v
222 s.chn=c
223 s.instr=instr[c]
225 case C.PART:rst=s
228 case C.TEMPO:if(s.tempo)
229 play_fac=set_tempo(s)
231 s=s.ts_next}
236 abc2svg.play_next=function(po){function do_tie(s,midi,d){var i,note,C=abc2svg.C,v=s.v,end_time=s.time+s.dur
237 while(1){s=s.ts_next
238 if(!s)
240 switch(s.type){case C.BAR:if(s.rep_p){if(!po.repn){s=s.rep_p
241 end_time=s.time}}
242 if(s.rep_s){if(!s.rep_s[po.repv+1])
244 s=s.rep_s[po.repv+1]
245 end_time=s.time}
246 while(s.ts_next&&!s.ts_next.dur)
247 s=s.ts_next}
248 if(s.time>end_time)
250 if(s.type==C.NOTE&&s.v==v)
252 i=s.notes.length
253 while(--i>=0){note=s.notes[i]
255 d+=s.pdur/po.conf.speed
256 return note.tie_ty?do_tie(s,midi,d):d}}
258 function set_ctrl(po,s2,t){var i,p_v=s2.p_v,tim=s2.time,s={subtype:"midictl",p_v:p_v,v:p_v.v,chn:p_v.chn}
259 for(i in p_v.midictl){s.ctrl=Number(i)
260 s.val=p_v.midictl[i]
261 po.midi_ctrl(po,s,t)}
262 for(s=p_v.sym;s&&s.time<=tim;s=s.next){if(s.subtype=="midictl")
263 po.midi_ctrl(po,s,t)}
265 function play_cont(po){var d,i,st,m,note,g,s2,t,maxt,C=abc2svg.C,s=po.s_cur
269 while(s.noplay){s=s.ts_next
270 if(!s||s==po.s_end){if(po.onend)
273 t=po.stim+s.ptim/po.conf.speed
278 t=po.stim+s.ptim/po.conf.speed}
281 while(1){if(!po.p_v[s.v])
282 set_ctrl(po,s,t)
283 switch(s.type){case C.BAR:if(s.rep_p){po.repv++
284 if(!po.repn&&(!s.rep_v||po.repv<s.rep_v.length)){po.stim+=(s.ptim-s.rep_p.ptim)/po.conf.speed
285 s=s.rep_p
286 while(s.ts_next&&!s.ts_next.dur)
287 s=s.ts_next
288 t=po.stim+s.ptim/po.conf.speed
292 if(s.rep_s){s2=s.rep_s[po.repv]
293 if(s2){po.stim+=(s.ptim-s2.ptim)/po.conf.speed
294 s=s2
295 t=po.stim+s.ptim/po.conf.speed
296 po.repn=false}else{s=po.s_end
298 if(s.bar_type.slice(-1)==':')
300 while(s.ts_next&&!s.ts_next.seqst)
301 s=s.ts_next
302 if(!s.part)
304 case C.PART:if(s.part&&po.i_p!=undefined){s2=s.part.p_s[++po.i_p]
305 if(s2){po.stim+=(s.ptim-s2.ptim)/po.conf.speed
306 s=s2
307 t=po.stim+s.ptim/po.conf.speed}else{s=po.s_end}}
309 case C.BLOCK:if(s.subtype=="midictl")
310 po.midi_ctrl(po,s,t)
312 case C.GRACE:for(g=s.extra;g;g=g.next){d=g.pdur/po.conf.speed
314 po.note_run(po,g,note.midi,t+g.ptim-s.ptim,d)}}
316 case C.NOTE:d=s.pdur/po.conf.speed
317 for(m=0;m<=s.nhd;m++){note=s.notes[m]
320 po.note_run(po,s,note.midi,t,note.tie_ty?do_tie(s,note.midi,d):d)}
321 case C.REST:d=s.pdur/po.conf.speed
322 if(po.onnote&&s.istart){i=s.istart
327 while(1){if(s==po.s_end||!s.ts_next){if(po.onend)
329 po.s_cur=s
331 s=s.ts_next
332 if(!s.noplay)
334 t=po.stim+s.ptim/po.conf.speed
337 po.s_cur=s
340 function get_part(po){var s,i,s_p
341 for(s=po.s_cur;s;s=s.ts_prev){if(s.parts){po.i_p=-1
343 s_p=s.part
346 for(i=0;i<s_p.p_s.length;i++){if(s_p.p_s[i]==s){po.i_p=i
364 function b64dcod(s){var i,t,dl,a,l=s.length,j=0
366 if(s[l-1]=='='){if(s[l-2]=='=')
371 for(i=0;i<l;i+=4){t=(b64d[s[i]]<<18)+
372 (b64d[s[i+1]]<<12)+
373 (b64d[s[i+2]]<<6)+
374 b64d[s[i+3]]
378 if(l!=s.length){t=(b64d[s[i]]<<18)+
379 (b64d[s[i+1]]<<12)+
380 (b64d[s[i+2]]<<6)+
381 b64d[s[i+3]]
386 function sample_cp(b,s){var i,n,a=b.getChannelData(0)
387 for(i=0;i<s.length;i++)
388 a[i]=s[i]/196608}
423 function load_res(s){var i
424 while(s){i=s.instr
427 s=s.ts_next}}
429 function midi_ctrl(po,s,t){if(s.ctrl==7)
430 s.p_v.vol=s.val/127}
431 function note_run(po,s,key,t,d){var g,st,instr=s.instr,k=key|0
432 parm=po.params[instr][k],o=po.ac.createBufferSource(),v=s.p_v.vol==undefined?1:s.p_v.vol
522 function note_run(po,s,k,t,d){var j,a=(k*100)%100,i=s.instr,c=s.chn
527 if(s.p_v.midictl){for(j in s.p_v.midictl)
528 po.op.send(new Uint8Array([0xb0+c,j,s.p_v.midictl[j]]))}}
534 function midi_ctrl(po,s,t){po.op.send(new Uint8Array([0xb0+s.chn,s.ctrl,s.val]),t*1000)}