void UpdateVisualsLines() { int numberOfTexturePixelsNeededUpdate = ShiftTextureUV(); int waveFormIndexer = analyzer.waveFormResolution - analyzer.GetWaveFormBinsInLastUpdate(); // Calculate the indexes in the texture that needs to be updated: int textureBeginIndex = TextureBeginIndex(numberOfTexturePixelsNeededUpdate); // draw the waveform float newPointL = 0; float newPointR = 0; int numberOfTextureLinesDrawn = 0; int i = textureBeginIndex; while (numberOfTextureLinesDrawn < numberOfTexturePixelsNeededUpdate) { int savedIndexer = waveFormIndexer; float sumL = GetSumWaveForm(waveFormToTexture, false, ref waveFormIndexer); waveFormIndexer = savedIndexer; float sumR = GetSumWaveForm(waveFormToTexture, false, ref waveFormIndexer, Channels.right); int numPixelsL = (int)(halfHeight * sumL); int numPixelsR = (int)(halfHeight * sumR); // Reset the color to background color DrawLine(i, 0, height, true, backgroundColor); newPointL = halfHeight + numPixelsL; newPointR = halfHeight + numPixelsR; DrawLine(i - 1, prevPointL, newPointL, false, waveformColorL); DrawLine(i - 1, prevPointR, newPointR, false, waveformColorR); numberOfTextureLinesDrawn += 1; i = (i + 1) % width; prevPointL = newPointL; prevPointR = newPointR; } texture.Apply(); }