| 1 | #ifndef _melder_h_ |
| 2 | #define _melder_h_ |
| 3 | /* melder.h |
| 4 | * |
| 5 | * Copyright (C) 1992-2025 Paul Boersma |
| 6 | * |
| 7 | * This code is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 3 of the License, or (at |
| 10 | * your option) any later version. |
| 11 | * |
| 12 | * This code is distributed in the hope that it will be useful, but |
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 15 | * See the GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this work. If not, see <http://www.gnu.org/licenses/>. |
| 19 | */ |
| 20 | |
| 21 | #include <stdio.h> |
| 22 | #include <stdlib.h> |
| 23 | #include <string.h> |
| 24 | #include <stdarg.h> |
| 25 | #include <stddef.h> |
| 26 | #include <wchar.h> |
| 27 | #ifdef __MINGW32__ |
| 28 | #include <sys/types.h> // for off_t |
| 29 | #endif |
| 30 | //#include <stdbool.h> |
| 31 | #include <functional> // std::move, std::forward |
| 32 | #include <memory> // unique_ptr |
| 33 | #include <new> // placement new |
| 34 | #include <algorithm> // std::min |
| 35 | #include <limits> // std::numeric_limits<double>::max(), std::numeric_limits<double>::lowest() |
| 36 | #include <mutex> |
| 37 | #include <atomic> // std::atomic<integer> |
| 38 | |
| 39 | /* |
| 40 | Law of Demeter for class functions defined outside class definition. |
| 41 | */ |
| 42 | #define our this -> |
| 43 | /* The single most useful macro in Praat: */ |
| 44 | #define my me -> |
| 45 | #define thy thee -> |
| 46 | #define your you -> |
| 47 | #define his him -> |
| 48 | #define her she -> |
| 49 | #define their they -> |
| 50 | #define iam(klas) klas me = (klas) void_me |
| 51 | #define optional_my optional_me -> |
| 52 | #define optional_thy optional_thee -> |
| 53 | #define optional_your optional_you -> |
| 54 | #define optional_his optional_him -> |
| 55 | #define optional_her optional_she -> |
| 56 | #define optional_their optional_they -> |
| 57 | |
| 58 | #define stringize(s) stringize_helper(s) |
| 59 | #define stringize_helper(s) #s |
| 60 | |
| 61 | #include "melder_assert.h" // Melder_assert |
| 62 | #include "melder_int.h" // <stdint.h>, int64, integer_to_uinteger_a (requires Melder_assert) |
| 63 | #include "melder_pointer.h" // NULL |
| 64 | #include "melder_real.h" // longdouble, MelderPoint, MelderRealRange |
| 65 | #include "NUMmath.h" // <math.h>, NUMpi, undefined |
| 66 | #include "complex.h" // <complex>, dcomplex |
| 67 | |
| 68 | #include "melder_alloc.h" // Melder_malloc (requires int64), Melder_free, MelderArray |
| 69 | #include "melder_string32.h" // char32, conststring32, autostring32 (requires Melder_malloc, our), Melder_dup |
| 70 | #include "melder_kar.h" // Melder_hasInk (requires char32), Melder_toLowerCase |
| 71 | #include "melder_str32.h" // Melder_length, str32cpy, str32cmp_caseInsensitive (requires Melder_toLowerCase) |
| 72 | |
| 73 | #include "enums.h" |
| 74 | #include "melder_enums.h" |
| 75 | |
| 76 | #include "melder_tensor.h" // VEC, autoMAT, Melder_VEC |
| 77 | #include "melder_colour.h" // MelderColour (requires VEC) |
| 78 | #include "melder_ftoa.h" // Melder_double, Melder_padLeft (require dcomplex, conststring32, MelderColour) |
| 79 | #include "melder_console.h" // MelderConsole (requires conststring32) |
| 80 | #include "melder_atof.h" |
| 81 | #include "melder_files.h" // Melder_fopen, MelderFile, MelderFolder |
| 82 | #include "melder_strvec.h" // STRVEC, autoSTRVEC (requires MelderArray) |
| 83 | #include "melder_sort.h" // sort_VEC_inout (requires VEC), sort_STRVEC_inout (requires STRVEC) |
| 84 | |
| 85 | #include "MelderArg.h" // MelderArg (requires Melder_double, MelderFile, Melder_VEC) |
| 86 | #include "MelderString.h" // MelderString_append (requires MelderArg) |
| 87 | #include "MelderThread.h" // Melder_thisThread_getUniqueID |
| 88 | #include "melder_textencoding.h" // Melder_length_utf8, Melder_32to8 (requires MelderString) |
| 89 | #include "melder_debug.h" // trace (requires MelderFile, MelderArg, MelderString), Melder_debug |
| 90 | #include "MelderFile.h" // MelderFile_open (requires MelderFile), MelderFile_write (requires MelderArg) |
| 91 | #include "MelderCat.h" // Melder_cat (requires MelderArg) |
| 92 | #include "melder_sprint.h" // Melder_sprint (requires MelderArg) |
| 93 | #include "melder_search.h" |
| 94 | #include "melder_casual.h" |
| 95 | #include "melder_info.h" |
| 96 | #include "melder_error.h" // Melder_throw (requires MelderArg), Melder_crash |
| 97 | #include "melder_require.h" |
| 98 | #include "melder_warning.h" |
| 99 | #include "melder_progress.h" |
| 100 | #include "melder_play.h" // Melder_record, Melder_play, Melder_beep |
| 101 | #include "melder_help.h" |
| 102 | #include "melder_ftoi.h" |
| 103 | #include "melder_time.h" // stopwatch, sleep, clock |
| 104 | #include "melder_audio.h" |
| 105 | #include "melder_audiofiles.h" |
| 106 | |
| 107 | /* The following trick uses Melder_debug only because it is the only plain variable known to exist at the moment. */ |
| 108 | #define Melder_offsetof(klas,member) (int) ((char *) & ((klas) & Melder_debug) -> member - (char *) & Melder_debug) |
| 109 | |
| 110 | /********** SYSTEM VERSION **********/ |
| 111 | |
| 112 | /* |
| 113 | For MacOS, this is set in Melder_init. |
| 114 | */ |
| 115 | inline integer Melder_systemVersion; |
| 116 | |
| 117 | /********** ENFORCE INTERACTIVE BEHAVIOUR **********/ |
| 118 | |
| 119 | /* Procedures to enforce interactive behaviour of the Melder_XXXXXX routines. */ |
| 120 | |
| 121 | /* |
| 122 | Set in praat_init. |
| 123 | True if run from the batch or from an interactive command-line interface. |
| 124 | */ |
| 125 | inline bool Melder_batch; |
| 126 | |
| 127 | /* |
| 128 | True if running a script. |
| 129 | */ |
| 130 | inline bool Melder_backgrounding; |
| 131 | |
| 132 | void Melder_init (); // inits NUmrandom, alloc, message, Melder_systemVersion |
| 133 | |
| 134 | #include "melder_quantity.h" |
| 135 | |
| 136 | #include "MelderReadText.h" |
| 137 | #include "melder_tensorio.h" // requires MelderReadText |
| 138 | #include "melder_sysenv.h" |
| 139 | #include "melder_app.h" |
| 140 | #include "melder_trust.h" |
| 141 | #include "abcio_enums.h" |
| 142 | #include "abcio.h" // requires MelderReadText |
| 143 | |
| 144 | #include "melder_templates.h" // Melder_ENABLE_IF_ISA, MelderCallback, MelderCompareHook |
| 145 | |
| 146 | #include "NUMspecfunc.h" |
| 147 | #include "NUMear.h" |
| 148 | #include "NUMinterpol.h" |
| 149 | #include "NUMmetrics.h" |
| 150 | #include "NUMrandom.h" |
| 151 | #include "NUMfilter.h" |
| 152 | #include "NUMlinprog.h" |
| 153 | |
| 154 | #include "regularExp.h" |
| 155 | #include "PAIRWISE_SUM.h" |
| 156 | |
| 157 | #include "NUM.h" |
| 158 | #include "STR.h" |
| 159 | #include "VEC.h" |
| 160 | #include "MAT.h" |
| 161 | #include "STRVEC.h" |
| 162 | |
| 163 | /* End of file melder.h */ |
| 164 | #endif |