From f5622c60dd9e10365901f33f226da748b0fae944 Mon Sep 17 00:00:00 2001 From: barbeque-squared Date: Thu, 3 Nov 2022 15:41:46 +0100 Subject: [PATCH] make the rendering of the oscilloscope significantly less expensive. the more players, the bigger the impact --- src/base/UDraw.pas | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/base/UDraw.pas b/src/base/UDraw.pas index 6a1fa0bb6..729985f93 100644 --- a/src/base/UDraw.pas +++ b/src/base/UDraw.pas @@ -363,6 +363,9 @@ procedure SingDrawOscilloscope(X, Y, W, H: real; NrSound: integer); Sound: TCaptureBuffer; MaxX, MaxY: real; Col: TRGB; +const + // arbitrarily chosen, but this makes it draw only 4096/SampleIndexStep line segments + SampleIndexStep = 32; begin; Sound := AudioInputProcessor.Sound[NrSound]; @@ -382,13 +385,16 @@ procedure SingDrawOscilloscope(X, Y, W, H: real; NrSound: integer); MaxX := W-1; MaxY := (H-1) / 2; + SampleIndex := 0; + Sound.LockAnalysisBuffer(); glBegin(GL_LINE_STRIP); - for SampleIndex := 0 to High(Sound.AnalysisBuffer) do + while SampleIndex < High(Sound.AnalysisBuffer) do begin glVertex2f(X + MaxX * SampleIndex/High(Sound.AnalysisBuffer), Y + MaxY * (1 - Sound.AnalysisBuffer[SampleIndex]/-Low(Smallint))); + SampleIndex := SampleIndex + SampleIndexStep; end; glEnd;