func (s *noiseForcedSines) Play(n struct{ Pitch, Amplitude []*audio.ControlPoint }) { releaseTime := 1.0 s.Add(&voice{ Pitch: audio.NewControl(n.Pitch), Amp: audio.NewControl(n.Amplitude), rand: rand.New(rand.NewSource(time.Now().UnixNano())), b: -math.Log(.001) / 2 / releaseTime, RMS: audio.NewRMS(.05), }) }
func (r *reverb) InitAudio(p audio.Params) { r.params = p r.streams = nil for i := 0; i < 30; i++ { s := &grainStream{t: 1} r.streams = append(r.streams, s) } r.buf = make([]float64, int(p.SampleRate)) r.rand = rand.New(rand.NewSource(time.Now().UnixNano())) r.dcFilter.InitAudio(p) r.fbRMS = audio.NewRMS(.5) r.fbRMS.InitAudio(p) r.outRMS = audio.NewRMS(.5) r.outRMS.InitAudio(p) r.limiter = audio.NewLimiter(.25, 1) audio.Init(r.limiter, p) r.Decay.InitAudio(p) r.Sustain.InitAudio(p) r.Dry.InitAudio(p) r.Wet.InitAudio(p) }