Beispiel #1
0
func (p *PatternView) animate() {
	var next <-chan time.Time
	var ctrl audio.PlayControl
	for {
		select {
		case <-p.play:
			if next != nil {
				next = nil
				ctrl.Stop()
				break
			}
			p.inst.Stop()
			ctrl = audio.PlayAsync(p.player)
			next = time.After(time.Second / fps)
		case <-next:
			next = time.After(time.Second / fps)
			Do(p, func() {
				p.cursorTime = p.player.GetTime()
				Repaint(p)
			})
		case <-ctrl.Done:
			next = nil
			Do(p, func() {
				SetKeyFocus(p.oldFocus)
			})
		case <-p.stop:
			return
		}
	}
}
Beispiel #2
0
func (s *ScoreView) animate() {
	var next <-chan time.Time
	var ctrl audio.PlayControl
	for {
		select {
		case <-s.play:
			if next != nil {
				next = nil
				ctrl.Stop()
				break
			}
			for _, inst := range audio.BandInstruments(s.band) {
				inst.Stop()
			}
			ctrl = audio.PlayAsync(s.player)
			next = time.After(time.Second / 60)
		case <-next:
			next = time.After(time.Second / 60)
			Do(s, func() {
				s.cursorTime = s.player.GetTime()
				Repaint(s)
			})
		case <-ctrl.Done:
			next = nil
			Do(s, func() {
				SetKeyFocus(s.oldFocus)
			})
		case <-s.close:
			return
		}
	}
}
Beispiel #3
0
func startAudio() {
	playControl = audio.PlayAsync(&tones)
}