Esempio n. 1
0
func playNotes(ins audio.Instrument) error {
	s := bufio.NewScanner(os.Stdin)
	for s.Scan() {
		for _, f := range strings.Fields(s.Text()) {
			n, err := note.FromString(f)
			if err != nil {
				fmt.Println("invalid note: ", f)
			}
			ins.SetFreq(n.Freq())
			time.Sleep(250 * time.Millisecond)
		}
	}
	return s.Err()
}
Esempio n. 2
0
File: dj.go Progetto: lamproae/audio
func (v *voice) play(name string) {
	go func() {
		for {
			for _, txt := range v.notes {
				n, err := note.FromString(txt)
				if err == nil {
					v.ins.SetFreq(n.Freq())
				} else {
					v.ins.SetFreq(0)
				}
				time.Sleep(500 * time.Millisecond)
			}
		}
	}()

	err := v.ins.Play()
	if err != nil {
		panic(err)
	}
	fmt.Println(name, "done")
}