Exemple #1
0
func onStart() {
	rc, err := asset.Open("boing.wav")
	if err != nil {
		log.Fatal(err)
	}
	player, err = audio.NewPlayer(rc, 0, 0)
	if err != nil {
		log.Fatal(err)
	}
}
Exemple #2
0
func loadSE() {
	rc, err := asset.Open("gooon.wav")
	if err != nil {
		log.Fatal(err)
	}
	player, err = audio.NewPlayer(rc, 0, 0)
	if err != nil {
		log.Fatal(err)
	}

	player.SetVolume(1)
	//log.Println("SE open")
}
Exemple #3
0
func onStart() {
	gl.Enable(gl.BLEND)
	gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)

	rc, err := asset.Open("hello.wav")
	if err != nil {
		log.Fatal(err)
	}
	player, err = audio.NewPlayer(rc, 0, 0)
	if err != nil {
		log.Fatal(err)
	}
}
Exemple #4
0
func PlaySound(name string) {
	println("Playing Sound: " + name)
	rc, err := asset.Open("sound/" + name + ".wav")
	if err != nil {
		panic(err)
	}
	soundsPlayer, err = audio.NewPlayer(rc, 0, 0)
	if err != nil {
		panic(err)
	}
	soundsPlayer.Play()
	// player.Close()
}
Exemple #5
0
func onStart(glctx gl.Context) {
	images = glutil.NewImages(glctx)
	eng = glsprite.Engine(images)
	loadScene()

	rc, err := asset.Open("boing.wav")
	if err != nil {
		log.Fatal(err)
	}
	player, err = audio.NewPlayer(rc, 0, 0)
	if err != nil {
		log.Fatal(err)
	}
}
Exemple #6
0
func InitPlayers(u *uistate.UIState) {
	for i, _ := range u.Audio.Players {
		rc, err := asset.Open(u.Audio.Sounds[i])
		if err != nil {
			fmt.Println("FIRST ERR")
			log.Fatal(err)
		}
		u.Audio.Players[i], err = audio.NewPlayer(rc, 0, 0)
		if err != nil {
			fmt.Println("SECOND ERR")
			log.Fatal(err)
		}
	}
}
Exemple #7
0
func (p *Player) File(filename string) (*Player, error) {

	if p.player != nil {
		p.player.Close()
	}

	file, err := os.Open(filename)
	if err != nil {
		return p, err
	}

	p.file = file

	player, err := audio.NewPlayer(file, 0, 0)
	if err != nil {
		log.Fatal(err)
	}
	p.player = player

	return p, nil
}
Exemple #8
0
func main() {
	mpg123.Initialize()
	mp3, err := mpg123.Open("example.mp3")
	if err != nil {
		panic(err)
	}

	rate, channels, encoding, format := mp3.Format()
	fmt.Printf("Rate: %i Channels: %i Encoding: %i Format: %s\n", rate, channels, encoding, format)

	p, err := audio.NewPlayer(fakers, audio.Format(format), rate)
	if err != nil {
		panic(err)
	}

	p.Play()
	for p.State() == audio.Playing {
		time.Sleep(time.Second)
	}
	mpg123.Exit()
}
func main() {
	mpg123.Initialize()
	gopath := os.Getenv("GOPATH")
	mp3, err := mpg123.Open(gopath + "/src/github.com/Golang-Commons/mediaCommons/mpg123bind/examples/example.mp3")
	if err != nil {
		panic(err)
	}

	rate, channels, encoding, format := mp3.Format()
	fmt.Printf("Rate: %i Channels: %i Encoding: %i Format: %s\n", rate, channels, encoding, format)

	p, err := audio.NewPlayer(mp3, audio.Format(format), rate)
	if err != nil {
		panic(err)
	}

	p.Play()
	for p.State() == audio.Playing {
		time.Sleep(time.Second)
	}
	mpg123.Exit()
}
Exemple #10
0
func main() {
	tick := time.Tick(time.Duration(16) * time.Millisecond)
	C.Init()
	lastSwap := C.SwapCount()
	noise := ReadSeekCloser{bytes.NewReader(MustAsset("sound/noise.wav"))}
	player, err := audio.NewPlayer(noise, audio.Mono16, 44100)
	if err != nil {
		log.Fatal(err)
	}
	player.SetVolume(1.0)
	for _ = range tick {
		swap := C.SwapCount()
		if swap != lastSwap {
			fmt.Println("swap count:", swap)
			state := player.State()
			if state == audio.Playing || state == audio.Paused {
				player.Stop()
			}
			player.Seek(0)
			player.Play()
			lastSwap = swap
		}
	}
}