package sine import ( "io" "log" "time" "git.icedream.tech/icedream/uplink/app/channels" humanize "github.com/dustin/go-humanize" "github.com/viert/lame" ) type pluginInstance struct { } func (instance *pluginInstance) SetChannelManager(channelManager *channels.ChannelManager) { c, err := channelManager.Open("sine") if err != nil { log.Println("ERROR: sine channel could not be opened:", err) log.Println("Skipping sine channel creation") return } wr := lame.NewWriter(c.InputStream) wr.Encoder.SetBitrate(192) wr.Encoder.SetQuality(1) wr.Encoder.SetInSamplerate(44100) wr.Encoder.SetNumChannels(2) wr.Encoder.InitParams() go func() { log.Println("Sine stream goroutine started") sine := new(SineStream) sine.Samplerate = 44100 sine.Frequency = 990 sine.Beep = true sine.Timestamp = time.Now() log.Println("Will now broadcast sine stream") n, err := io.Copy(wr, sine) if err != nil { log.Fatal("Sine stream copy failed:", err) } log.Println("Sine stream finished, written", humanize.Bytes(uint64(n)), "bytes") }() }