Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The worse language I've ever seen come from the tool praat, which is a good audio analysis tool. It does a pretty good job until you use the script language. <em>sigh</em> bad memories.</p> <h1>Tiny praat script tutorial for beginners</h1> <p> <li><h2>Function call</h2> We've listed at least 3 different function calling syntax : <ul> <li><h3>The regular one</h3> <code>string = selected("Strings")</code> <p>Nothing special here, you assign to the variable string the result of the selected function. Not really scary... yet.</p> </li> <li><h3>The "I'm invoking some GUI command with parameters"</h3> <code>Create Strings as file list... liste 'path$'/'type$'</code><br /> <p>As you can see, the function name start at "Create" and finish with the "...". The command "Create Strings as file list" is the text displayed on a button or a menu (I'm to scared to check) on praat. This command take 2 parameters liste and an expression. I'm going to look deeper in the expression <code>'path$'/'type$'</code> </p> <p>Hmm. Yep. No spaces. If spaces were introduced, it would be separate arguments. As you can imagine, parenthesis don't work. At this point of the description I would like to point out the suffix of the variable names. I won't develop it in this paragraph, I'm just teasing.</p> </li> <li><h3>The "Oh, but I want to get the result of the GUI command in my variable"</h3> <code>noliftt = Get number of strings</code><br /> Yes we can see a pattern here, long and weird function name, it must be a GUI calling. But there's no '...' so no parameters. I don't want to see what the parser looks like. </li> </ul> </li> <li><h2>The incredible type system</h2> (AKA Haskell and OCaml, praat is coming to you) <ul> <li><h3>Simple natives types</h3> <code>windowname$ = left$(line$,length(line$)-4)</code> <p>So, what's going on there? It's now time to look at the convention and types of expression, so here we got : <ul> <li>left$ :: (String, Int) -> String</li> <li>lenght :: (String) -> Int</li> <li>windowname$ :: String</li> <li>line$ :: String</li> </ul> As you can see, variable name and function names are suffixed with their type or return type. If their suffix is a '$', then it return a string or is a string. If there is nothing it's a number. I can see the point of prefixing the type to a variable to ease implementation, but to suffix, no sorry, I can't</p> </li> <li><h3>Array type</h3> To show the array type, let me introduce a 'tiny' loop : <pre><code> for i from 1 to 4 &nbsp;&nbsp;&nbsp;&nbsp;Select... time time &nbsp;&nbsp;&nbsp;&nbsp;bandwidth'i'$ = Get bandwidth... i &nbsp;&nbsp;&nbsp;&nbsp;forhertz'i'$ = Get formant... i endfor </code></pre> <p> We got i which is a number and... (no it's not a function)<br/> <code>bandwidth'i'$</code><br/> What it does is create string variables : <code>bandwidth1$</code>, <code>bandwidth2$</code>, <code>bandwidth3$</code>, <code>bandwidth4$</code> and give them values. As you can expect, you can't create two dimensional array this way, you must do something like that : <code>band2D__'i'__'j'$</code> </p> <a href="http://img214.imageshack.us/img214/3008/scaredkittylolqa2.jpg">http://img214.imageshack.us/img214/3008/scaredkittylolqa2.jpg</a> </li> <li><h2>The special string invocation</h2> <code> outline$ = "'time'@F'i':'forhertznum'Hz,'bandnum'Hz, 'spec''newline$'" outline$ >> 'outfile$' </code> <p> Strings are weirdly (at least) handled in the language. the '' is used to call the value of a variable inside the global "" string. This is <em>weird</em>. It goes against all the convention built into many languages from bash to PHP passing by the powershell. And look, it even got redirection. Don't be fooled, it doesn't work like in your beloved shell. No you have to get the variable value with the '' </p> </li> <li><h2>Da Wonderderderfulful execution model</h2> <p>I'm going to put the final touch to this wonderderderfulful presentation by talking to you about the execution model. So as in every procedural languages you got instruction executed from top to bottom, there is the variables and the praat GUI. That is you code everything on the praat gui, you invoke commands written on menu/buttons.</p> <p>The main window of praat contain a list of items which can be : <ul> <li>files</li> <li>list of files (created by a function with a wonderderfulful long long name)</li> <li>Spectrogramm</li> <li>Strings (don't ask)</li> </ul> So if you want to perform operation on a given file, you must select the file in the list programmatically and then push the different buttons to take some actions. If you wanted to pass parameters to a GUI action, you have to follow the GUI layout of the form for your arguments, for example "<code>To Spectrogram... 0.005 5000 0.002 20 Gaussian </code>" is like that because it follows this layout:</p> <p><a href="http://img7.imageshack.us/img7/5534/tospectrogramm.png">http://img7.imageshack.us/img7/5534/tospectrogramm.png</a></p></li> </ul> <p>Needless to say, my nightmares are filled with praat scripts dancing around me and shouting "DEBUG MEEEE!!".</p></p> <p><sub> More information at the <a href="http://www.fon.hum.uva.nl/praat/">praat</a> site, under the well-named section "easy programmable scripting language"</sub></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload