Lines Matching refs:po

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
240 switch(s.type){case C.BAR:if(s.rep_p){if(!po.repn){s=s.rep_p
242 if(s.rep_s){if(!s.rep_s[po.repv+1])
244 s=s.rep_s[po.repv+1]
255 d+=s.pdur/po.conf.speed
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}
261 po.midi_ctrl(po,s,t)}
263 po.midi_ctrl(po,s,t)}
264 po.p_v[s2.v]=true}
265 function play_cont(po){var d,i,st,m,note,g,s2,t,maxt,C=abc2svg.C,s=po.s_cur
266 if(po.stop){if(po.onend)
267 po.onend(po.repv)
270 if(!s||s==po.s_end){if(po.onend)
271 po.onend(po.repv)
273 t=po.stim+s.ptim/po.conf.speed
274 if(po.conf.new_speed){d=po.get_time(po)
275 po.stim=d-(d-po.stim)*po.conf.speed/po.conf.new_speed
276 po.conf.speed=po.conf.new_speed
277 po.conf.new_speed=0
278 t=po.stim+s.ptim/po.conf.speed}
279 maxt=t+po.tgen
280 po.timouts=[]
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
288 t=po.stim+s.ptim/po.conf.speed
289 po.repn=true
291 po.repn=false}
292 if(s.rep_s){s2=s.rep_s[po.repv]
293 if(s2){po.stim+=(s.ptim-s2.ptim)/po.conf.speed
295 t=po.stim+s.ptim/po.conf.speed
296 po.repn=false}else{s=po.s_end
299 po.repv=1
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
307 t=po.stim+s.ptim/po.conf.speed}else{s=po.s_end}}
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
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
323 st=(t-po.get_time(po))*1000
324 po.timouts.push(setTimeout(po.onnote,st,i,true))
325 setTimeout(po.onnote,st+d*1000,i,false)}
327 while(1){if(s==po.s_end||!s.ts_next){if(po.onend)
328 setTimeout(po.onend,(t-po.get_time(po)+d)*1000,po.repv)
329 po.s_cur=s
334 t=po.stim+s.ptim/po.conf.speed
337 po.s_cur=s
338 po.timouts.push(setTimeout(play_cont,(t-po.get_time(po))*1000
339 -300,po))}
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
346 for(i=0;i<s_p.p_s.length;i++){if(s_p.p_s[i]==s){po.i_p=i
348 get_part(po)
349 po.stim=po.get_time(po)+.3
350 -po.s_cur.ptim*po.conf.speed
351 po.p_v=[]
352 if(!po.repv)
353 po.repv=1
354 play_cont(po)}
358 function Audio5(i_conf){var po,conf=i_conf,empty=function(){},errmsg,ac,gain,instr=[],params=[],rates=[],w_instr=0
428 function get_time(po){return po.ac.currentTime}
429 function midi_ctrl(po,s,t){if(s.ctrl==7)
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
442 o.playbackRate.value=po.rates[instr][k]
443 g=po.ac.createGain()
449 g.connect(po.gain)
452 function play_start(){if(po.stop){po.onend(repv)
455 abc2svg.play_next(po)}
473 po={conf:conf,onend:conf.onend||empty,onnote:conf.onnote||empty,s_end:i_end,s_cur:i_start,repv:i_lvl||0,tgen:2,get_time:get_time,midi_ctrl:midi_ctrl,note_run:note_run,ac:ac,gain:gain,params:params,rates:rates}
477 play_start()},stop:function(){po.stop=true
478 po.timouts.forEach(function(id){clearTimeout(id)})
479 abc2svg.play_next(po)
520 return null;return chunk};sf2.Riff.Parser.prototype.getNumberOfChunks=function(){return this.chunkList.length};return sf2}));function Midi5(i_conf){var po,conf=i_conf,empty=function(){},rf,op
521 function get_time(po){return window.performance.now()/1000}
522 function note_run(po,s,k,t,d){var j,a=(k*100)%100,i=s.instr,c=s.chn
526 if(i!=po.c_i[c]){if(po.c_i[c]==undefined){po.op.send(new Uint8Array([0xb0+c,121,0]))
528 po.op.send(new Uint8Array([0xb0+c,j,s.p_v.midictl[j]]))}}
529 po.c_i[c]=i
530 po.op.send(new Uint8Array([0xc0+c,i&0x7f]))}
531 if(a&&Midi5.ma.sysexEnabled){po.op.send(new Uint8Array([0xf0,0x7f,0x7f,0x08,0x02,i&0x7f,0x01,k,k,a/.78125,0,0xf7]),t)}
532 po.op.send(new Uint8Array([0x90+c,k,127]),t)
533 po.op.send(new Uint8Array([0x80+c,k,0]),t+d-20)}
534 function midi_ctrl(po,s,t){po.op.send(new Uint8Array([0xb0+s.chn,s.ctrl,s.val]),t*1000)}
554 break}}},play:function(i_start,i_end,i_lvl){po={conf:conf,onend:conf.onend||empty,onnote:conf.onnote||empty,s_end:i_end,s_cur:i_start,repv:i_lvl||0,tgen:2,get_time:get_time,midi_ctrl:midi_ctrl,note_run:note_run,op:op,c_i:[]}
556 abc2svg.play_next(po)},stop:function(){po.stop=true
557 po.timouts.forEach(function(id){clearTimeout(id)})
558 abc2svg.play_next(po)