I can write something myself by finding zero-crossings of the first derivative or something, but it seems like