If D = total duration and f = wave frequency, then 2 * f * D must be some integer k.
If k is even, the sound will end on a full cycle.
If k is odd, the sound will end on a half-cycle.
Note that a A4 tone like in your example is an easy case. With some other frequency, some rounding can be needed, and be aware that even a tiny discontinuity (the zero-crossing not being "exact") can be audible, particularly if you listen to your sound as a loop.
If k is even, the sound will end on a full cycle.
If k is odd, the sound will end on a half-cycle.
Note that a A4 tone like in your example is an easy case. With some other frequency, some rounding can be needed, and be aware that even a tiny discontinuity (the zero-crossing not being "exact") can be audible, particularly if you listen to your sound as a loop.
Statistics: Posted by pragma — Sun Feb 11, 2024 9:06 am