Scripting 8.3. The sendpraat directive

Besides being a subroutine (Scripting 8.1. The sendpraat subroutine) and a program (Scripting 8.2. The sendpraat program), sendpraat can also be called from within a Praat script.

Example 1: killing a program

Suppose we are in the Praat-shell program Als, which is a browser for dictionaries, and we want to kill the Praat-shell program Praat, which is a program for phonetics research:

beginSendpraat: "Praat"
    Quit
endSendpraat

Example 2: playing a sound

Suppose we are in the Praat-shell program Als, which is a browser for dictionaries, and has no idea of what a sound is. From this program, we can play a sound file by sending a message to the Praat-shell program Praat, which does know about sounds:

fileName$ = chooseReadFile$: "Play a sound file"
beginSendpraat: "Praat", "fileName$"
    Read from file: fileName$
    Play
    Remove
endSendpraat

After beginSendpraat, you first mention the name of the receiving program (here "Praat"), then the names of the variables you want the receiving program to know about.

To have the receiving program return information to you, specify the variables that are to be handed back:

fileName$ = chooseReadFile$: "Measure a sound file"
beginSendpraat: "Praat", "fileName$"
    Read from file: fileName$
    duration = Get total duration
    Remove
endSendpraat: "duration"
writeInfoLine: "That sound file lasts ", duration, " seconds."

Links to this page


© ppgb, January 12, 2014