Formulas 1.6. Formulas for creation

With some commands in the New menu, you can supply a formula that Praat will apply to all elements of the new object.

Creating a Sound from a formula

Choose Create Sound from formula... and type the following into the Formula field:

1/2 * sin (2 * pi * 377 * x)

When you click OK, a new Sound object will appear in the list. After you click View & Edit and zoom in a couple of times, you will see that the sound is a sine wave with a frequency of 377 hertz (cycles per second). This worked because the x in the formula represents the time, i.e. the formula was applied to every sample separately, with a different value of x for each sample.

Creating a Matrix from a formula

Choose Create simple Matrix... and type the following into the Formula field:

8

When you click OK, a new Matrix object will appear in the list. When you click Info, you will see that it is a matrix with 10 rows and 10 columns, and that all the 100 cells contain the value 8 (you can see this because both the minimum and the maximum are reported as being 8).

A more interesting example is the formula

row * col

For the resulting Matrix, choose Paint cells... and click OK. The Picture window will show a 10×10 matrix whose elements are the product of the row and column numbers, i.e., they have values between 1 and 100. Beside row and col, you can use x for the distance along the horizontal axis and y for the distance along the vertical axis; see the following page for examples.

Links to this page


© ppgb, January 28, 2011