|
Analogously to the formulas that you can use for creating new objects (see the previous page), you can use formulas for modifying existing objects. You do this with the command Formula... that you can find in the Modify menu when you select an object.
Record a sound with your microphone and talk very lowly. If you don't know how to record a sound in Praat, consult the Intro. Once the Sound object is in the list, click Play. The result will sound very soft. Then choose Formula... from the Modify menu and type
self * 3
Click OK, then click Play again. The sound is much louder now. You have multiplied the amplitude of every sample in the sound with a factor of 3.
If you don’t use self
in your formula, the formula does not refer to the existing contents of the Sound. Hence, the formula
1/2 * sin (2 * pi * 377 * x)
will simply replace your recorded speech with a 377-Hz sine wave.
Many objects can be thought of as matrices: they consist of a number of rows and columns with data in every cell:
The formula is performed on every column of every row. The formula
self^2
will square all matrix elements.
The formula first works on the first row, and in that row from the first column on; this can work recursively. The formula
self + self [row, col - 1]
integrates each row.
You can refer to the current position in a Matrix (or Sound, etc.) by index or by x and y values:
row
col
x
y
You can refer to values in the current Matrix (or Sound, etc.) by index.
self
self
[column-expression
]
column-expression
is rounded to the nearest integer. If the index is out of range (less than 1 or greater than nx), the expression evaluates as 0.Example. An integrator is
self [col - 1] + self * dx
self
[row-expression
, column-expression
]
You can refer to values in the current Matrix (or Spectrogram, etc.) by x and y position:
self
(x-expression
, y-expression
)
You can refer to values in the current Sound (or Intensity etc.) by x position:
self
(x-expression
)
© ppgb 20170916