Sunday, November 3, 2013

Lesson 34 - Wheel of fortune

Am I running out of descriptive titles for posts?

Today we continued on our professional audio API project.

The goal is to create functions for playing the familiar "taa" and "ti" notes (quarter-note, eight-note) with different pitches. This requires us to write functions with parameters, which isn't actually entirely new to us. So, we want a function that can be used to play an eight-note of any pitch. For example to play C:

ti c

The "c" here actually refers to the frequency of the C note (261.63 Hz) and is a parameter of the function "ti".

We wrote the "ti" function like

let ti n = play n 100

This translates to "to play an eight note of frequency n, you should plan the n note for 100 milliseconds". I explained the idea of a function parameter to her so that when you call the function, the parameter n will be replaced by the note you give to the function. And used a couple of examples.

Then we tried the function like

ti e

And it worked like a charm. Then she wrote the similar function "taa" mosly by herself. It worked too. I'm glad she used a different arbitrary name for the function parameter, to illustrate that the computer doesn't really care about the names; they are merely for us humans to care about.

Then she saved the file.

save "nakki"

Arbitrary names seems to be the way to go. We'll continue our program next time.

Why Wheel of Fortune? It's just the movement she makes with her hand while looking up the letters on the keyboard. Circling around the keyboard like an eagle looking for prey. Not that she misses often.