Add helper.piecewise to simplify generating inputs

Added this helper function, tests, and updated the controlled oscillator example.