Source code: | runs.cpp |
runs-simple.cpp |
The runs program plays a single voice which follows the location of baton 1. The size of each step that the voice takes is controlled by the y-position of baton2. When the voice reaches the pitch location of baton 1, it will oscillate above and below that point untill baton 1 moves again.
There are four dimensions of control, two for each baton:
The general algorithm for the runs program is:
if it is time for a new note: calculate the duration of the next note from baton 2 x-position. calculate the loudness of the current note from baton 1 y-position. calculate the interval step of the current note form baton 2 y-position. calculate the target pitch from the baton 1 x-position. if the playing pitch is undefined, set it to the target pitch otherwise, add or subtract the interval calculated above to get the pitch closer to the target pitch. play the pitch with the calculated loudness.