The single quotes indicate that sound_file$ is the name of the variable, not the name of the Sound object. In this way, the function of single quotes is the opposite of the function of double quotes. The Praat manual (Help… Praat Intro) contains a lot of information about things you can do with variables. To see some of them, open the manual and search for “numeric” or “string”. Lines 36-40 show some simple arithmetic with numeric variables. When the script is run, the commands on lines 10-14 will cause a window to open and prompt the user for the name of the sound file, the two formant tracking parameters: form Measure formant values for segments in a textgrid FORMSįorms are a convenient way of giving information to the script. The first line indicates that this is a form, and specifies what text is to appear in the window. The next three lines indicate three variables that we will define and give values to, specifying the type of variable (“sentence” for strings, “positive” for positive numbers), the names of the variables, and their default values. Note that the string variable name doesn’t have $ at the end, but when we refer to it later (e.g., in line 20) we will use the $. The problem is that double-quotes have special significance for Praat: they enclose strings.An alternative to a form would be to specify the values directly in the script, and change them manually when we run it, like this (note the differences involving $ and quotes): sound_file$ = "myname" Also, we don’t use quotes for text strings, because Praat is expecting text. You should have seen that this generates an error (our syntax coloring also served as a warning). Note: What if I want double-quotes in my string? See the next section for some common string operations and some gotchas. Every time you type anything in a Praat script, or ask Praat to give you a value, you have to think about its data type (number or string). You should care because Praat cares: If the program is expecting a string and you give it a number or vice versa, you will get an error and your script won't work. This is all to say that instead of being so cranky and aggressive, imaginary interlocutor, you should thank the creators of Praat for simplifying it down to two for us, because they are doing a lot of work behind the scenes to hide all of this complexity. I don't want to go on a tirade about numbers of bits and 0's and 1's, so I leave it to the more curious to Google.įor example, the languages Praat is written in (C and C++) are both older than the Mac, and they have several further subdivisions of types of numbers (like an integer, real, long, or double), all of which take up different amounts of space. This focus on fine-grained control of memory still exists for anyone who's making a program that requires intensive computation and must be fast (like game programmers, for example). Some of the important computer languages that we use today predate that old Macintosh, and these older computer languages require that the programmer choose what data type a variable would be to allow him or her to maximize to an extreme the available computational space. At the time of writing, you can now attach a single file to an email that is up to 25Mb, which is 25000 kilobytes, about 200 times bigger than all of the computational space available to the first Mac!Ī string will take up more space in your memory than something like a number, so the computer needs to know how much space to set aside for a variable that will contain a string. A computer like the original Macintosh had only 128 kilobytes of memory (RAM)!!!!! That means that all computations the computer made had to take up less than this amount of space (like showing you all of the windows, processing clicks, making things appear on screen). The main reason is because they take up different amounts of computer memory. Why do I care? Why is there a difference between numbers and strings? Hold on, what's a string?Ī string is basically any character or combination of characters. This is how we indicate in Praat's language that instead of working with numeric data, we are working with "strings". Two important details here: The variable name now ends in a dollar sign, and the value we assigned it is surrounded in double quotes (must be double! The single quotes mean something else.). Let's remember how we assigned a number to a variable: However, sometimes we want to manipulate more than numbers. The previous section talked about the concept of variables, and used number variables as a starting point.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |