Demo window 1. My first Demo window script

The Demo window is Praat’s least visible window: you can create it only through a script. Try the following script after selecting a Sound object:

    demo Draw: 0, 3, -1, 1, “yes”, “curve”

You see the Demo window turn up on the screen, with the Sound painted into it. It works because the Draw... command is available in the Objects window when you select a Sound. Then try:

    demo Draw line: 0, -1, 3, 1

You see a line drawn from (0 seconds, -1 Pa) to (3 seconds, +1 Pascal) in the waveform. It works because the Draw line... command is available in the Picture window. Then try:

    demo Erase all
    demo Red
    demo Axes: 0, 100, 0, 100
    demo Text: 50, “centre”, 50, “half”, “Hello”

You see a text appear in red, in the centre of the window. This works because you are using commands from the Picture window, including the Axes... command, which sets the world coordinates to something else than before (before, the world coordinates were determined by the Sound).

Now suppose you want the Sound to appear in the top half of the window, and some texts in the bottom left and bottom right corners of the window. You can use Select outer viewport... and Select inner viewport..., if you know that the size of the Demo window is “100” horizontally and “100” vertically (rather than 12×12, as the Picture window), and that the point (0, 0) lies in the bottom left (rather than the top left, as in the Picture window):

    demo Erase all
    demo Black
    demo Times
    demo 24
    demo Select outer viewport: 0, 100, 50, 100
    demo Draw: 0, 0, 0, 0, “yes”, “curve”
    demo Select inner viewport: 0, 100, 0, 100
    demo Axes: 0, 10, 0, 10
    demo Text: 0, “left”, 0, “bottom”, “Left bottom corner”
    demo Text: 10, “right”, 0, “bottom”, “Right bottom corner”

As the title page of a presentation, you could do:

    demo Erase all
    demo Select inner viewport: 0, 100, 0, 100
    demo Axes: 0, 100, 0, 100
    demo Paint rectangle: “purple”, 0, 100, 0, 100
    demo Pink
    demo Text: 50, “centre”, 50, “half”, “This is my title”

Links to this page


© Paul Boersma 2009–2023