Hometrainer 2.0 - Application
After wrestling through the Java Sound libraries, I finally succeeded in writing a small hometrainer application. If you are cycling while watching a movie (something I do often), then this application will pause the video if you are riding too slow. Also, the current speed is constantly displayed.
The application constantly monitors the line-input, waiting for a pulse from the hometrainers’ flywheel. When the sinus reaches a (pre-defined) threshold, it gets registered, and I can calculate the speed I’m cycling at. For extra precision, I calculate with audio-samples instead of using the computer-time. This is because of the time it takes to fill the buffer. So far, I’ve been able to measure the speed fairly accurate.
A small disadvantage is that the computer on the hometrainer calculates the speed exponentially. This was apparently done to make the impression that the user’s riding very fast. For the sake of honesty, I wrote my own program in a way so that it works linear.