I am not currently performing a similar task. This is not trivial. Because silence will not be a straight line of zeros. there will be some fluctuations.
If you are guaranteed a clear signal, it would be rather trivial to set a marker in the first sample with an absolute value greater than 0.001.
You can set the final marker without going back through the file. all you do is every pattern that exceeds this threshold, you set a final marker in that pattern.
If your entrance has the ability to contain glare and squitps, before it starts correctly, you will need a more sophisticated technique. Post a comment below and I will continue the answer.
source share