Two Sets of Grids Algorithm Assignment

Create a new version of algo.cpp called gridsets.cpp to develop the musical interest of your algorithm at work.

There are two objects to this assignment:

In class, we looked at a formula that would quantize the values from the sine algorithm such that it produces a regular (additive) rhythmic grouping.

nextNoteTime = t_time + 250 * (1 + ((int)(2 * (1 + sin(t_time/1000)))))) or, in other words, successive notes will be separated by a series in msec. that goes

250,500,750,1000,750,500,250,500, etc. -- [sixteenth, eighth, dotted sixteenth, quarter, dotted sixteenth, eighth, sixteenth, etc.]

The formula first offsets the output of sine by 1, so it varies from 0 - 2. Then, it scales it to a range 0 - 4. Since it's still a real number (floating point) the (int) statement causes it to be converted to an integer (rounding down) so we now get either of 4 values, 0,1,2,3, to which we add 1 and multiply by 250.

The same kind of formula can be applied to filter values used for the outgoing pitch or key number (and create a musical scale).

Finally, create another control variable called mode1 and determine a command to set it (from the computer keyboard, if you like) that will select between two different musical results. The selection can be effected by putting an if statement where values are calculated for key number and for nextNoteTime.

if (mode1) {impose a grid to do it this way} else {impose a grid to do it the other way};

Turn in the work in a new web folder for lab4.