Including any user in this:
You can process the samples per pixel as a zoom level, at higher levels (increased more) you probably want to query this for performance reasons.
Most likely, you will need a fixed width that fits the screen to draw and use virtual scrolling (so you don’t have a potential drawing area of several million pixels).
You can calculate the value for each pixel by iterating over the audio data with: skip (scroll position * samples per pixel) + (pixel * samples per pixel), samples per pixel. This allows you to use infinite zoom and scroll, as you only read and draw the minimum amount to fill the view. The scroll width is calculated with the length of the audio data / samples per pixel.
Audio samples are typically shown in one of two ways: peak sample range or rms. The average value is calculated by summing the squares of all values in the sampling range, dividing the sum by the length of the sample, the rms value, if the square of it (the rms value is slightly higher than the average and is a good measure of perceived loudness)
You can increase productivity in several ways, such as increasing sub-sampling (causing loss of detail), throttling the scroll, and canceling the cancellation of drawing requests if there are new visual scrolling before displaying the previous one.
source share