Improve source code documentation
Assume clock() always returns a valid result
Use full sample value range
Round integer division result to nearest
Refactor wave generation

- The new implementation requires no division to track sign
   changes.
Allow unsigned sample types (e. g. U8)