Sine wave test.
Fixed an off-by-one error in buffer writing.