Skip to content

Instantly share code, notes, and snippets.

@faiface
Created July 23, 2017 12:37
Show Gist options
  • Save faiface/d18a88313b746702c386fa7bffbbcf44 to your computer and use it in GitHub Desktop.
Save faiface/d18a88313b746702c386fa7bffbbcf44 to your computer and use it in GitHub Desktop.
package main
import (
"os"
"time"
"github.com/faiface/beep"
"github.com/faiface/beep/speaker"
"github.com/faiface/beep/wav"
)
func main() {
speaker.Init(44100, time.Second/30)
f, _ := os.Open("mozart.wav")
s, format, _ := wav.Decode(f)
buf := beep.NewBuffer(format)
buf.Append(s)
s.Close()
speaker.Play(beep.Loop(-1, buf.Streamer(
5*time.Minute+37*time.Second+666*time.Millisecond,
5*time.Minute+41*time.Second+148*time.Millisecond,
)))
select {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment