func newEcho(delay time.Duration) *echo { h, err := portaudio.DefaultHostApi() chk(err) p := portaudio.LowLatencyParameters(h.DefaultInputDevice, h.DefaultOutputDevice) p.Input.Channels = 1 p.Output.Channels = 1 e := &echo{buffer: make([]float32, int(p.SampleRate*delay.Seconds()))} e.Stream, err = portaudio.OpenStream(p, e.processAudio) chk(err) return e }
func main() { portaudio.Initialize() defer portaudio.Terminate() h, err := portaudio.DefaultHostApi() chk(err) stream, err := portaudio.OpenStream(portaudio.HighLatencyParameters(nil, h.DefaultOutputDevice), func(out []int32) { for i := range out { out[i] = int32(rand.Uint32()) } }) chk(err) defer stream.Close() chk(stream.Start()) time.Sleep(time.Second) chk(stream.Stop()) }