Example #1
0
File: dj.go Project: lamproae/audio
func main() {
	audio.Initialize()
	defer audio.Terminate()

	s := bufio.NewScanner(os.Stdin)
	for s.Scan() {
		fs := strings.Fields(s.Text())
		if len(fs) == 0 {
			continue
		}

		name, args := fs[0], fs[1:]
		switch name[0] {
		case '/':
			if err := action(name, args); err != nil {
				fmt.Println(err)
			}
		default:
			if len(args) == 0 {
				fmt.Println("melodies need at least one note")
			}
			melody(name, args)
		}
	}
	if err := s.Err(); err != nil {
		panic(err)
	}

}
Example #2
0
func main() {
	audio.Initialize()
	defer audio.Terminate()

	s := audio.NewSine(0, sampleRate)

	go func() {
		defer s.Stop()

		err := playNotes(s)
		if err != nil {
			panic(err)
		}
	}()

	err := s.Play()
	if err != nil {
		panic(err)
	}

	fmt.Println("good bye!")
}