| 1 | /* manual_commands.cpp |
| 2 | * |
| 3 | * Copyright (C) 1992-2025 Paul Boersma |
| 4 | * |
| 5 | * This code is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 3 of the License, or (at |
| 8 | * your option) any later version. |
| 9 | * |
| 10 | * This code is distributed in the hope that it will be useful, but |
| 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 13 | * See the GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this work. If not, see <http://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | |
| 19 | #include "ManPagesM.h"cxx . . $ `<file>/sys/ManPagesM.h`/ |
| 20 | |
| 21 | void manual_commands_initcxx . . $ manual_commands_init(e57bd08652fa63a5). (ManPagescxx . . $ ManPages# me); |
| 22 | void manual_commands_initcxx . . $ manual_commands_init(e57bd08652fa63a5). (ManPagescxx . . $ ManPages# me) { |
| 23 | |
| 24 | MAN_PAGES_BEGINcxx . . $ `sys/ManPagesM.h:27:9`! R"~~~( |
| 25 | ################################################################################ |
| 26 | "fixed menu commands" (into 2023 “Fixed menu commands“) |
| 27 | © Paul Boersma 1997,2005,2012,2023 |
| 28 | |
| 29 | The commands in the fixed menus of the @@Objects window@ (Praat, New, Open, Help, Goodies, |
| 30 | Settings, and Technical) and the @@Picture window@ (File, Edit, Margins, World, Select, Pen, Font, Help). |
| 31 | |
| 32 | These commands are always clickable (if not hidden) and scriptable (if not added). |
| 33 | |
| 34 | ################################################################################ |
| 35 | "action commands" (into 2023 “Action commands”) |
| 36 | © Paul Boersma 1997,2002,2011,2023 |
| 37 | |
| 38 | The commands in the @@Dynamic menu@ of the @@Objects window@. |
| 39 | |
| 40 | These commands are available only if the right kinds of objects are selected. |
| 41 | They are shown in a list in the right half of the Objects window, |
| 42 | or in the @@Save menu@ if they start with ##Save as# or ##Append to#. |
| 43 | |
| 44 | ################################################################################ |
| 45 | "Add action command..." |
| 46 | © Paul Boersma 1997,2005,2006,2023 |
| 47 | |
| 48 | One of the hidden commands in the Praat menu of the @@Objects window@. |
| 49 | With this command, you add a button to the dynamic menu in the right half of the Objects window. |
| 50 | |
| 51 | Settings |
| 52 | ======== |
| 53 | See @@Add to dynamic menu...@. |
| 54 | |
| 55 | Usage |
| 56 | ===== |
| 57 | You can use this command in your @@initialization script@ or in @@plug-ins@, |
| 58 | just like @@Add menu command...@. |
| 59 | |
| 60 | Normally, however, if you want to add a command to the dynamic menu, |
| 61 | you would use the command @@Add to dynamic menu...@ of the @ScriptEditor instead, |
| 62 | which has the exact same list of parameters. |
| 63 | |
| 64 | ################################################################################ |
| 65 | "Add menu command..." |
| 66 | © Paul Boersma 1997,2005,2006,2023 |
| 67 | |
| 68 | One of the hidden commands in the Praat menu of the @@Objects window@. |
| 69 | With this command, you add a button to any of the fixed menus in the Objects window, |
| 70 | the Picture window, or any type of editor window. |
| 71 | |
| 72 | Settings |
| 73 | ======== |
| 74 | See @@Add to fixed menu...@ (for the Objects window or the Picture window) |
| 75 | or @@Add to menu...@ (for editor windows). |
| 76 | |
| 77 | Usage |
| 78 | ===== |
| 79 | You can use this command in your @@initialization script@ or in @@plug-ins@, |
| 80 | just like @@Add action command...@. |
| 81 | |
| 82 | Normally, however, if you want to add a command to a fixed menu, |
| 83 | you would use the command @@Add to fixed menu...@ of the @ScriptEditor instead, |
| 84 | which has the exact same list of parameters. |
| 85 | |
| 86 | ################################################################################ |
| 87 | "Add to dynamic menu..." |
| 88 | © Paul Boersma 1998,2006,2011,2014,2023 |
| 89 | |
| 90 | A command in the File menu of the @ScriptEditor. |
| 91 | |
| 92 | With this command, you add a button to the dynamic menu in the @@Objects window@. |
| 93 | This button will only be visible if the specified combination of objects is selected. |
| 94 | Clicking the button will invoke the specified @@Praat script@. |
| 95 | |
| 96 | Settings |
| 97 | ======== |
| 98 | ##Class 1 |
| 99 | : the name of the class of the object to be selected. |
| 100 | For instance, if a button should only appear if the user selects a Sound, this would be “Sound”. |
| 101 | |
| 102 | ##Number 1 |
| 103 | : the number of objects of %class1 that have to be selected. For most built-in commands, this number is unspecified (0); |
| 104 | e.g., the user can choose #Draw... or ##To Spectrum# regardless of whether she selected 1, 2, 3, or more Sound objects. |
| 105 | If the number of selected objects is different from %number1, the button will be visible but insensitive. |
| 106 | |
| 107 | ##Class 2 |
| 108 | : the name of the class of the second object to be selected, different from %class1. |
| 109 | Normally the empty string (“”). |
| 110 | |
| 111 | ##Number 2 |
| 112 | : the number of selected objects of %class2. |
| 113 | |
| 114 | ##Class 3 |
| 115 | : the name of the class of the third object to be selected, different from %class1 and %class2. |
| 116 | Normally the empty string (“”). |
| 117 | |
| 118 | ##Number 3 |
| 119 | : the number of selected objects of %class3. |
| 120 | |
| 121 | ##Command |
| 122 | : the title of the new command button (or label, or submenu title). |
| 123 | To get a separator line instead of a command text (only in a submenu), |
| 124 | you specify a unique string that starts with a hyphen (“-”); the @ButtonEditor may contain some examples of this. |
| 125 | If the command starts with ##Save as# or ##Append to#, it will be placed in the @@Save menu@. |
| 126 | |
| 127 | ##After command |
| 128 | : a button title in the dynamic menu or submenu where you want your new button. |
| 129 | If you specify the empty string (“”), your button will be put at the bottom. |
| 130 | You can specify a push button, a label (subheader), or a cascade button (submenu title) here. |
| 131 | |
| 132 | ##Depth |
| 133 | : 0 if you want your button in the main menu, 1 if you want it in a submenu. |
| 134 | |
| 135 | ##Script |
| 136 | : the full path name of the script to invoke. If you saved the script you are editing, |
| 137 | its name will already have been filled in here. |
| 138 | If you do not specify a script, you will get a separating label or cascading menu title instead, |
| 139 | depending on the %depth of the following command. |
| 140 | |
| 141 | Example |
| 142 | ======= |
| 143 | If one object of class Sound is selected, you want a new submenu called “Filters” |
| 144 | after the #Convolve button, containing your new commands “Autocorrelation” and “Band filter...”, |
| 145 | separated by a horizontal separator line: |
| 146 | {; |
| 147 | Add to dynamic menu: "Sound", 0, "", 0, "", 0, "Filters -", |
| 148 | ... "Convolve", 0, "" |
| 149 | Add to dynamic menu: "Sound", 1, "", 0, "", 0, "Autocorrelation", |
| 150 | ... "Filters -", 1, "/u/praats/demo/autocorrelation.praat" |
| 151 | Add to dynamic menu: "Sound", 0, "", 0, "", 0, "-- band filter --", |
| 152 | ... "Autocorrelation", 1, "" |
| 153 | Add to dynamic menu: "Sound", 1, "", 0, "", 0, "Band filter...", |
| 154 | ... "-- band filter --", 1, "/u/praats/demo/bandFilter.praat" |
| 155 | } |
| 156 | Note that “Filters -” will be a submenu title, %because it is followed by subcommands (%depth 1). |
| 157 | Note that %number1 is 1 only for the executable buttons; for the cascade button and the separator line, |
| 158 | this number is ignored. |
| 159 | |
| 160 | Usage convention |
| 161 | ================ |
| 162 | Please adhere to the convention that command that take arguments, such as “Band filter...” above, end in three dots. |
| 163 | |
| 164 | Using this command in a script |
| 165 | ============================== |
| 166 | To add a dynamic button from a script (perhaps your @@initialization script@ or a @@plug-ins|plug-in@), |
| 167 | use the hidden shell command @@Add action command...@ instead. |
| 168 | |
| 169 | ################################################################################ |
| 170 | "Add to fixed menu..." |
| 171 | © Paul Boersma 1997,2002,2005,2006,2012,2014,2023 |
| 172 | |
| 173 | A command in the File menu of the @ScriptEditor. |
| 174 | |
| 175 | With this command, you add a button to any fixed menu in the @@Objects window@ or in the @@Picture window@. |
| 176 | Clicking the added button will invoke the specified @@Praat script@. |
| 177 | |
| 178 | Settings |
| 179 | ======== |
| 180 | #Window |
| 181 | : the name of the window (“Objects” or “Picture”) that contains the menu that you want to change. |
| 182 | |
| 183 | #Menu |
| 184 | : the title of the menu that you want to change. If #Window is “Objects”, you can specify |
| 185 | the Praat, New, Open, Help, Goodies, Settings, or Technical menu (for the Save menu, |
| 186 | which depends on the objects selected, |
| 187 | you would use @@Add to dynamic menu...@ instead). If #Window is “Picture”, you can specify |
| 188 | the File, Edit, Margins, World, Select, Pen, Font, or Help menu. |
| 189 | |
| 190 | #Command |
| 191 | : the title of the new menu button. To get a separator line instead of a command text, |
| 192 | you specify a unique string that starts with a hyphen (“-”); the @ButtonEditor contains many examples of this. |
| 193 | |
| 194 | ##After command |
| 195 | : a button title in the menu or submenu after which you want your new button to be inserted. |
| 196 | If you specify the empty string (“”), your button will be put in the main menu. |
| 197 | |
| 198 | #Depth |
| 199 | : 0 if you want your button in the main menu, 1 if you want it in a submenu. |
| 200 | |
| 201 | #Script |
| 202 | : the full path name of the script to invoke. If you saved the script you are editing, |
| 203 | its name will already have been filled in here. If you do not specify a script, |
| 204 | you will get a cascading menu title instead. |
| 205 | |
| 206 | Example 1 |
| 207 | ========= |
| 208 | In the Matrix submenu of the @@New menu@, you want a separator line followed by the command #Peaks: |
| 209 | {; |
| 210 | Add to fixed menu: "Objects", "New", "-- peaks --", "Create simple Matrix...", 1, "" |
| 211 | Add to fixed menu: "Objects", "New", "Peaks", "-- peaks --", 1, "/u/praats/demo/peaks.praat" |
| 212 | } |
| 213 | Example 2 |
| 214 | ========= |
| 215 | In the @@New menu@, you want a submenu called “Demo”, with a subitem titled “Lorenz...”: |
| 216 | {; |
| 217 | Add to fixed menu: "Objects", "New", "Demo", "", 0, "" |
| 218 | Add to fixed menu: "Objects", "New", "Lorenz...", "Demo", 1, "/u/praats/demo/lorenz.praat" |
| 219 | } |
| 220 | Usage convention |
| 221 | ================ |
| 222 | Please adhere to the convention that commands that take arguments, such as “Lorenz...” above, end in three dots. |
| 223 | |
| 224 | Using this command in a script |
| 225 | ============================== |
| 226 | To add a fixed button from a script (perhaps your @@initialization script@ or a @@plug-ins|plug-in@), |
| 227 | use the hidden shell command @@Add menu command...@ instead. It has the exact same list of parameters. |
| 228 | |
| 229 | ################################################################################ |
| 230 | "Add to menu..." |
| 231 | © Paul Boersma 2023 |
| 232 | |
| 233 | A command in the File menu of a @ScriptEditor that was created in an editor (e.g. SoundEditor) window. |
| 234 | |
| 235 | With this command, you add a button to any fixed menu in an editor window. |
| 236 | Clicking the added button will invoke the specified @@Praat script@. |
| 237 | |
| 238 | Settings |
| 239 | ======== |
| 240 | #Window |
| 241 | : the name of the type of window (e.g. “TextGridEditor”) that contains the menu that you want to change. |
| 242 | |
| 243 | #Menu |
| 244 | : the title of the menu that you want to change. If #Window is “SoundEditor”, you can specify |
| 245 | the File, Edit, Time, Play, Sound, Analyses, Spectrogram, Pitch, Intensity, Formants, or Pulses menu. |
| 246 | |
| 247 | #Command |
| 248 | : the title of the new menu button. To get a separator line instead of a command text, |
| 249 | you specify a unique string that starts with a hyphen (“-”). |
| 250 | To get a command with a rectangle to its right (like e.g. ##Save sound to disk:# in the File menu |
| 251 | of the SoundEditor), have the command end in a colon (“:”). |
| 252 | To get a command with a rectangle to its right and a separator line above it, |
| 253 | you can use e.g. `- Save sound to disk:` as a shorthand. |
| 254 | |
| 255 | ##After command |
| 256 | : not used; always keep this empty (i.e. an empty string). |
| 257 | |
| 258 | #Depth |
| 259 | : 0 if you want your button left-aligned in the menu, 1 if you want it indented |
| 260 | (as e.g. the command ##Save selected sound as WAV file...# in the File menu of the SoundEditor). |
| 261 | |
| 262 | #Script |
| 263 | : the full path name of the script to invoke. If you saved the script you are editing, |
| 264 | its name will already have been filled in here. If you do not specify a script, |
| 265 | you will get a separator line instead. |
| 266 | |
| 267 | Usage convention |
| 268 | ================ |
| 269 | Please adhere to the convention that commands that take arguments, such as “Lorenz...” above, end in three dots. |
| 270 | |
| 271 | Using this command in a script |
| 272 | ============================== |
| 273 | To add a fixed button from a script (perhaps your @@initialization script@ or a @@plug-ins|plug-in@), |
| 274 | use the hidden shell command @@Add menu command...@ instead. It has the exact same list of parameters. |
| 275 | |
| 276 | ################################################################################ |
| 277 | "ButtonEditor" |
| 278 | © Paul Boersma 1998,2003,2005,2006,2023 |
| 279 | |
| 280 | An editor for viewing, hiding, showing, removing, and executing the commands |
| 281 | in the fixed menus, editor menus and dynamic menus of the Praat program. |
| 282 | To open the button editor, choose ##Buttons...# |
| 283 | from the Settings menu in the Praat menu of the @@Objects window@. |
| 284 | |
| 285 | What the button editor shows |
| 286 | ============================ |
| 287 | The button editor gives a list of: |
| 288 | 1. The five fixed buttons. |
| 289 | 2. The built-in and added @@fixed menu commands@, lexicographically sorted by window and menu name. |
| 290 | 3. The added editor menu commands, lexicographically sorted by editor and menu name. |
| 291 | 4. The built-in and added @@action commands@, sorted by the names of the selected objects. |
| 292 | |
| 293 | Visibility of built-in commands |
| 294 | =============================== |
| 295 | Most built-in commands are visible by default, but some are hidden by default (see @@hidden commands@). |
| 296 | The button editor shows these commands as “shown” or “hidden”, respectively. |
| 297 | You can change the visibility of a command by clicking on the blue “shown” or “hidden” text; |
| 298 | this text will then be replaced with “HIDDEN” or “SHOWN”, with capitals to signal their non-standard settings. |
| 299 | These changes will be remembered in the @@buttons file@ across sessions of your program. |
| 300 | To return to the standard settings, click the blue “HIDDEN” or “SHOWN” texts again. |
| 301 | |
| 302 | Some built-in commands cannot be hidden. They are marked as “unhidable”. |
| 303 | The most notable example is the ##Buttons...# button |
| 304 | (a failure to make the ##Commands...# command unhidable in Microsoft Word |
| 305 | causes some computer viruses to be very hard to remove...). |
| 306 | |
| 307 | Added commands |
| 308 | ============== |
| 309 | Commands that you have added to the fixed or dynamic menus (probably with @@Add to fixed menu...@ or |
| 310 | @@Add to dynamic menu...@ in the @ScriptEditor), |
| 311 | are marked as “ADDED”. They are remembered in the @@buttons file@. |
| 312 | You can change the availability of these commands by clicking on the blue “ADDED” text, which will then |
| 313 | be replaced with “REMOVED”. After this, the added command will no longer be remembered in the @@buttons file@. |
| 314 | To make the command available again, click the blue “REMOVED” text again, before leaving the program. |
| 315 | |
| 316 | Start-up commands |
| 317 | ================= |
| 318 | Commands that were added in an @@initialization script@ or @@plug-ins|plug-in@ (with @@Add menu command...@ or |
| 319 | @@Add action command...@) are marked as “START-UP”. |
| 320 | They are %not remembered in the @@buttons file@. |
| 321 | You can change the visibility of these commands by clicking on the blue “START-UP” text, which will then |
| 322 | be replaced with “HIDDEN”. This setting %will be remembered in the @@buttons file@. |
| 323 | To make the command visible again, click the blue “HIDDEN” text again. |
| 324 | |
| 325 | Executing commands |
| 326 | ================== |
| 327 | The button editor allows you to choose hidden commands without first making them visible in the fixed or dynamic menus. |
| 328 | |
| 329 | The editor shows all the executable commands in blue. These include: |
| 330 | 1. The fixed #Remove button, if one or more objects are selected in the @@List of Objects@. |
| 331 | 2. The other fixed buttons, if exactly one object is selected. |
| 332 | 3. All of the fixed menu commands, hidden or not, and “removed” or not. |
| 333 | 4. Those action commands that match the currently selected objects with respect to class and number. |
| 334 | |
| 335 | To execute any of these blue commands, just click on it. |
| 336 | |
| 337 | ################################################################################ |
| 338 | "buttons file" (into 2002 “Buttons file”) |
| 339 | © Paul Boersma 1997,2002,2007,2015,2020 |
| 340 | |
| 341 | The file into which changes in the availability and visibility of commands in the fixed |
| 342 | and dynamic menus are recorded. |
| 343 | |
| 344 | The buttons file is written to disk when you quit Praat, |
| 345 | and it is read again when you start Praat the next time. It is a simple @@Praat script@ that you can read |
| 346 | (but should not edit) with any text editor. |
| 347 | |
| 348 | Adding buttons |
| 349 | ============== |
| 350 | To add a command to a fixed or dynamic menu, you typically use the @ScriptEditor. |
| 351 | |
| 352 | Removing buttons |
| 353 | ================ |
| 354 | To remove an added command from a fixed or dynamic menu, you typically use the @ButtonEditor. |
| 355 | |
| 356 | Hiding and showing buttons |
| 357 | ================ |
| 358 | To hide a built-in command from a fixed or dynamic menu, or to make a hidden command visible, |
| 359 | you typically use the @ButtonEditor. |
| 360 | |
| 361 | Where is the buttons file? |
| 362 | ========================== |
| 363 | The buttons file is in your Praat @@preferences folder@. |
| 364 | |
| 365 | On Windows the file is called #`Buttons5.ini`, |
| 366 | for instance `C:\Users\Miep\Praat\Buttons5.ini`. |
| 367 | |
| 368 | On MacOS it is called #`Buttons5`, |
| 369 | for instance `/Users/miep/Library/Preferences/Praat Prefs/Buttons5`. |
| 370 | |
| 371 | On Linux it is called #`buttons5`, |
| 372 | for instance `/home/miep/.praat-dir/buttons5`. |
| 373 | |
| 374 | ################################################################################ |
| 375 | "preferences folder" |
| 376 | © Paul Boersma 2007,2010,2015(“preferences directory”),2020 |
| 377 | |
| 378 | The Praat preferences folder is the folder where Praat saves the @@preferences file@ and the @@buttons file@, |
| 379 | and where you can install @@plug-ins@ and save the preferences of your scripts (in your subfolder of the #apps subfolder). |
| 380 | If the preferences folder does not exist, it will automatically be created when you start Praat. |
| 381 | |
| 382 | Windows |
| 383 | ======= |
| 384 | If you are user #Miep, your Praat preferences folder will be `C:\Users\Miep\Praat` in Praat 6.xx, |
| 385 | and `C:\Users\Miep\AppData\Roaming\Praat` in Praat 7.xx. |
| 386 | |
| 387 | To see what’s in there, open a File Explorer window, switch on `View` \-> `Show` \-> `Hidden items`, |
| 388 | and navigate to `Local Disk` \-> `Users` \-> %`your name` \-> `AppData` \-> `Roaming` \-> `Praat`. |
| 389 | |
| 390 | Macintosh |
| 391 | ========= |
| 392 | If you are user #miep, your Praat preferences folder will be `/Users/miep/Library/Preferences/Praat Prefs` in Praat 6.xx, |
| 393 | and `/Users/miep/Library/Application Support/Praat` in Praat 7.xx. |
| 394 | |
| 395 | To see what’s in there, go to the Finder, choose Go \-> Library, and navigate to `Application Support` \-> `Praat`. |
| 396 | |
| 397 | Linux |
| 398 | ===== |
| 399 | If your home folder is #`/home/miep/`, your Praat preferences folder will be `/home/miep/.praat-dir` in Praat 6.xx, |
| 400 | and `/home/miep/.config/praat` in Praat 7.xx. |
| 401 | |
| 402 | To see what’s in there, open a Terminal window and type `ls -al ~/.config/praat`. |
| 403 | |
| 404 | (If the environment variable `XDG_CONFIG_HOME` is set, then the `praat` folder will be there instead.) |
| 405 | |
| 406 | If your app isn’t called Praat, but e.g. PraatForHospitals (Praat’s extra safe edition available from version 7 on), |
| 407 | then the preferences folder isn’t called `Praat` or `praat`, but `PraatForHospitals` or `praat_for_hospitals` instead. |
| 408 | |
| 409 | ################################################################################ |
| 410 | "preferences file" (into 2003 “Preferences file”) |
| 411 | © Paul Boersma 1997,2002,2003,2007,2020,2023 |
| 412 | |
| 413 | The file into which some of your preferences are saved across your sessions with Praat. |
| 414 | For instance, if you change the font used by the Picture window to Palatino and quit Praat, |
| 415 | the Picture-window font will still be Palatino when you start Praat again. |
| 416 | |
| 417 | The preferences file is written to disk when you quit Praat, |
| 418 | and it is read when you start Praat. It is a simple text file that you can read |
| 419 | (but should not edit) with any text editor. |
| 420 | |
| 421 | Where is the preferences file? |
| 422 | ============================== |
| 423 | The preferences file is in your Praat @@preferences folder@. |
| 424 | |
| 425 | On Windows it is called #`Preferences5.ini`, |
| 426 | for instance `C:\Users\Miep\Praat\Preferences5.ini`. |
| 427 | |
| 428 | On Macintosh it is called #`Prefs5`, |
| 429 | for instance `/Users/miep/Library/Preferences/Praat Prefs/Prefs5`. |
| 430 | |
| 431 | On Linux the file is called #`prefs5`, |
| 432 | for instance `/home/miep/.praat-dir/prefs5`. |
| 433 | |
| 434 | ################################################################################ |
| 435 | "initialization script" (through 2004 “Initialization script”) |
| 436 | © Paul Boersma 1997,2004,2006,2014,2015,2020,2023 |
| 437 | |
| 438 | Your initialization script is a normal @@Praat script@ that is run as soon as you start Praat. |
| 439 | |
| 440 | On Unix or macOS, you create an initialization script by creating a file named `praat-startUp` |
| 441 | in the folder `/usr/local`, |
| 442 | or putting a file `.praat-user-startUp` or `praat-user-startUp` in your home folder |
| 443 | (if you rename the Praat executable, these names have to change as well). |
| 444 | |
| 445 | If you have more than one of these files, they are run in the above order. |
| 446 | |
| 447 | On Windows, you create an initialization script by creating a file named |
| 448 | `praat-user-startUp` in your home folder, |
| 449 | which could be `C:\Users\Miep` if you are Miep. |
| 450 | |
| 451 | If you have both of these files, they are run in the above order. |
| 452 | |
| 453 | Example |
| 454 | ======= |
| 455 | If you like to be greeted by your husband when Praat starts up, |
| 456 | you could put the following lines in your initialization script: |
| 457 | {; |
| 458 | if windows |
| 459 | Read from file: "C:\Users\Miep\helloMiep.wav" |
| 460 | elsif macintosh |
| 461 | Read from file: "/Users/miep/helloMiep.wav" |
| 462 | else |
| 463 | Read from file: "/home/miep/helloMiep.wav" |
| 464 | endif |
| 465 | Play |
| 466 | Remove |
| 467 | } |
| 468 | What not to use an initialization script for |
| 469 | ============================================ |
| 470 | You could set preferences like the default font in your initialization script, |
| 471 | but these will be automatically remembered between invocations of Praat anyway (in your @@preferences file@), |
| 472 | so this would often be superfluous, or indeed confusing. |
| 473 | |
| 474 | For installing sets of menu commands at start-up you will probably prefer to use @@plug-ins@ |
| 475 | rather than a single start-up file. |
| 476 | |
| 477 | ################################################################################ |
| 478 | "plug-ins" (into 2006 “plugins”) |
| 479 | © Paul Boersma 2006,2007,2014,2015,2020,2023 |
| 480 | |
| 481 | Experienced Praat script writers can distribute their product as a plug-in to Praat. |
| 482 | |
| 483 | The Praat plug-in mechanism |
| 484 | =========================== |
| 485 | When Praat starts up, it will execute all Praat scripts called #`setup.praat` |
| 486 | that reside in folders whose name starts with #`plugin_` and that themselves reside in |
| 487 | your Praat @@preferences folder@. |
| 488 | |
| 489 | How to write a Praat plug-in |
| 490 | ============================ |
| 491 | Suppose that you have a set of Praat scripts specialized in the analysis and synthesis of vocalizations of guinea pigs, |
| 492 | and that these scripts are called `analyseQueak.praat` and `createQueak.praat` (“queak” is what guinea pigs tend to say). |
| 493 | With the @ScriptEditor, you have put the script `analyseQueak.praat` in the dynamic menu that |
| 494 | appears if the user selects a Sound object, and you have put the script `createQueak.praat` in the @@New menu@. |
| 495 | Only the latter script requires the user to supply some settings in a form, so the two menu commands |
| 496 | are ##Analyse queak# (without dots) and ##Create queak...# (with three dots), respectively. |
| 497 | Suppose now that you want to distribute those two commands to other guinea pig vocalization researchers. |
| 498 | |
| 499 | What you do is that you create a Praat script called `setup.praat` (in the same folder as the two other scripts), |
| 500 | that contains the following two lines: |
| 501 | {; |
| 502 | \@{Add action command:} "Sound", 1, "", 0, "", 0, "Analyse queak", "", 0, "analyseQueak.praat" |
| 503 | \@{Add menu command:} "Objects", "New", "Create queak...", "", 0, "createQueak.praat" |
| 504 | } |
| 505 | (If you ran this script, Praat would install those two commands in the correct menus, and remember them in the @@buttons file@; |
| 506 | but you are now going to install them in a different way.) |
| 507 | |
| 508 | You now put the three scripts in a new folder called %`plugin_Queak`, |
| 509 | and put this folder in your Praat preferences folder. If you are on Windows, |
| 510 | you will now have a folder called something like `C:\Users\Your Name\Praat\plugin_Queak`. |
| 511 | |
| 512 | If you now start up Praat, Praat will automatically execute the script |
| 513 | `C:\Users\Your Name\Praat\plugin_Queak\setup.praat` |
| 514 | and thereby install the two buttons. The two buttons will %not be remembered in the buttons file, |
| 515 | but they will be installed at every Praat start-up. De-installation involves removing (or renaming) the `plugin_Queak` folder. |
| 516 | |
| 517 | To distribute the Queak plug-in among your colleague guinea pig researchers, you can use any installer program to put |
| 518 | the `plugin_Queak` folder into the user’s Praat preferences folder; or you could ask those colleagues to move |
| 519 | the `plugin_Queak` folder there by hand. |
| 520 | |
| 521 | The structure of your plug-in folder |
| 522 | ==================================== |
| 523 | In the example `setup.praat` file above, the names of the scripts `analyseQueak.praat` and `createQueak.praat` |
| 524 | occur without any folder information. This works because Praat regards these file names as being relative to the folder |
| 525 | where `setup.praat` is located. If your plug-in is much larger than two scripts, you may want to put subdirectories into |
| 526 | the folder `plugin_Queak`. For instance, if you put `analyseQueak.praat` into the subfolder `analysis`, |
| 527 | your line in the `setup.praat` script would look as follows: |
| 528 | {; |
| 529 | \@{Add action command:} "Sound", 1, "", 0, "", 0, "Analyse queak", "", 0, "analysis/analyseQueak.praat" |
| 530 | } |
| 531 | The forward slash (“/”) in this example makes your plug-in platform-independent: it will work unchanged |
| 532 | on Windows, Macintosh, and Unix. |
| 533 | |
| 534 | Nothing prevents you from adding data files to your plug-in. For instance, your `plugin_Queak` folder |
| 535 | could contain a subfolder `sounds` full of guinea pig recordings, and you could make them available in the New or Open menu. |
| 536 | |
| 537 | Using a plug-in for site-wide customization |
| 538 | =========================================== |
| 539 | If your local guinea pig research group shares a number of Praat scripts, these can be made available to everybody |
| 540 | in the following way: |
| 541 | 1. Create a script that adds buttons to the fixed and dynamic menus, using the commands |
| 542 | @@Add menu command...@ and @@Add action command...@. This script could be a slightly edited copy of someone’s |
| 543 | @@buttons file@. |
| 544 | 2. Put this script where everybody can see it, |
| 545 | for instance in `U:\MaldenGuineaPigResearchButtons.praat`, where `U` is your shared computer. |
| 546 | 3. Create a file `setup.praat` that contains only the following line: |
| 547 | ` |
| 548 | runScript: "U:\MaldenGuineaPigResearchButtons.praat" |
| 549 | ` |
| 550 | 4. Put the `setup.praat` file in a new folder called `plugin_MaldenGuineaPigResearch`, |
| 551 | and distribute this folder among your local colleagues. |
| 552 | |
| 553 | This procedure allows all members of the group to automatically enjoy all the later changes in your |
| 554 | custom command set. |
| 555 | |
| 556 | ################################################################################ |
| 557 | "plugins" |
| 558 | © Paul Boersma 2006 |
| 559 | |
| 560 | See @@plug-ins@. |
| 561 | |
| 562 | ################################################################################ |
| 563 | "hidden commands" (into 2023 “Hidden commands”) |
| 564 | © Paul Boersma 1997,2003,2005,2006,2011 |
| 565 | |
| 566 | Some commands in Praat's fixed and dynamic menus are hidden by default. |
| 567 | You can still call hidden commands from scripts, run them by clicking on them in a @ButtonEditor, |
| 568 | or make them visible with the help of the @ButtonEditor. |
| 569 | |
| 570 | To hide commands that are visible by default, use the @ButtonEditor. |
| 571 | |
| 572 | What commands are hidden by default? |
| 573 | ==================================== |
| 574 | Commands that are expected to be of very limited use, are hidden by default. Examples are: |
| 575 | 1. The commands @@Add menu command...@, ##Hide menu command...#, ##Show menu command...#, |
| 576 | @@Add action command...@, ##Hide action command...#, and ##Show action command...# in the #Praat menu |
| 577 | of the @@Objects window@. These are used in the @@buttons file@ and could be used by an @@initialization script@ or a @@plug-ins|plug-in@ |
| 578 | as well; in an interactive session, however, the functionality of these commands is part of the |
| 579 | @ScriptEditor and the @ButtonEditor. |
| 580 | 2. The command ##Read from old Praat picture file...# in the #File menu of the @@Picture window@. |
| 581 | For reading a file format that was in use before May, 1995. |
| 582 | 3. In the Praat program, the action ##Sound: Save as Sesam file...#. Writes a file format in common use |
| 583 | in the Netherlands on Vax machines. In the Dutch phonetics departments, the plugs were pulled from the Vaxes in 1994. |
| 584 | 4. In the Praat program, the action ##Sound: To Cochleagram (edb)...#. Needed by one person in 1994. |
| 585 | An interesting, but undocumented procedure (De Boer's gammatone filter bank plus Meddis & Hewitt's |
| 586 | synapse model), which does not create a normally interpretable Cochleagram object. |
| 587 | |
| 588 | ################################################################################ |
| 589 | )~~~" MAN_PAGES_ENDcxx . . $ `sys/ManPagesM.h:28:9`! |
| 590 | |
| 591 | } |
| 592 | |
| 593 | /* End of file manual_commands.cpp */ |