Simple silence detection is performed by comparing sound fragments with a certain value (which is selected depending on the quality of the recording).
Sort of:
abs(track[position]) < 0.1
or
(track[position]) < 0.1) && (track[position]) > -0.1)
assuming the piece is [-1, 1] float.
This will work better if the sound normalizes.
source share