public WaveAudio Generate(double timeScale, int timeShift) { if (wLast != null && timeScale == this.timeScaleLast && timeShift == this.timeShiftLast && !bNeedUpdate) { return(wLast); } WaveAudio w = wInput.Clone(); for (int ch = 0; ch < w.getNumChannels(); ch++) { for (int i = 0; i < w.data[ch].Length; i++) { w.data[ch][i] = w.data[ch][i] + w.data[ch][((int)(i * timeScale) + timeShift) % w.data[ch].Length]; } } this.timeScaleLast = timeScale; this.timeShiftLast = timeShift; this.wLast = w; this.bNeedUpdate = false; return(w); }