| 1 |
// Listing 5.1 Defining and testing a function that adds an octave to any MIDI note number |
| 2 |
|
| 3 |
// A Simple Function example |
| 4 |
// Declare our function here |
| 5 |
|
| 6 |
fun int addOctave( int note ) // (1) Function declaration |
| 7 |
{ |
| 8 |
int result; // (2) Result to return |
| 9 |
note + 12 => result; // (3) Calculates the value to return |
| 10 |
return result; // (4) Returns it |
| 11 |
} |
| 12 |
|
| 13 |
// Main addOctave Test Program, call and print out result |
| 14 |
|
| 15 |
addOctave(60) => int answer; // (5) Uses the function |
| 16 |
|
| 17 |
<<< answer >>>; // (6) Checks the result |