Scripting 6.3. Query commands

If you click the "Get mean..." command for a Pitch object, the Info window will contain a text like "150 Hz" as a result. In a script, you would rather have this result in a variable instead of in the Info window. The solution is simple:

mean = Get mean: 0, 0, "Hertz", "Parabolic"

The numeric variable "mean" now contains the number 150. When assigning to a numeric variable, the interpreter converts the part of the text before the first space into a number.

You can also assign to string variables:

mean$ = Get mean: 0, 0, "Hertz", "Parabolic"

The string variable "mean$" now contains the entire string "150 Hz".

This works for every command that would otherwise write into the Info window.

Links to this page


© ppgb, January 7, 2014