Adaptive grid lines as seen in Waveform

I’m trying to achieve grid lines that change snap depending on zoom level of my component. I think the function for this is TimecodeDisplayFormat::getBestSnapType ? However, I’m having a hard time understanding how to calculate the onScreenTimePerPixel argument.

onScreenTimePerPixel is the width of your view in seconds / width of your view in pixels.