| 1 | #ifndef _Ltas_h_ |
| 2 | #define _Ltas_h_ |
| 3 | /* Ltas.h |
| 4 | * |
| 5 | * Copyright (C) 1992-2012,2015-2019,2022,2023 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 2 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 "Spectrum.h" |
| 22 | #include "Sound.h" |
| 23 | #include "PointProcess.h" |
| 24 | #include "Collection.h" |
| 25 | |
| 26 | Thing_define (Ltas, Vector) { |
| 27 | void v1_info () |
| 28 | override; |
| 29 | int v_domainQuantity () const |
| 30 | override { return MelderQuantity_FREQUENCY_HERTZ; } |
| 31 | double v_convertStandardToSpecialUnit (double value, integer level, int unit) const |
| 32 | override; |
| 33 | double v_convertSpecialToStandardUnit (double value, integer level, int unit) const |
| 34 | override; |
| 35 | }; |
| 36 | |
| 37 | /* |
| 38 | Attributes: |
| 39 | xmin // Minimum frequency (Hz). |
| 40 | xmax > xmin // Maximum frequency (Hz). |
| 41 | nx >= 1 // Number of bands. |
| 42 | dx > 0.0 // Band width (Hz). |
| 43 | x1 // Centre of first band (Hz). |
| 44 | ymin, ymax, dy, y1 = 1.0 |
| 45 | ny = 1 |
| 46 | z [1] [1..nx] // The intensity per band, in dB/Hz. |
| 47 | */ |
| 48 | |
| 49 | autoLtas Ltas_create (integer nx, double dx); |
| 50 | /* |
| 51 | Function: |
| 52 | create an Ltas. |
| 53 | Preconditions: |
| 54 | nx >= 1; |
| 55 | dx > 0.0; |
| 56 | Postconditions: |
| 57 | my xmin == 0.0; my ymin == 1; |
| 58 | my xmax == nx * dx; my ymax == 1; |
| 59 | my nx == nx; my ny == 1; |
| 60 | my dx == dx; my dy == 1; |
| 61 | my x1 == 0.5 * dx; my y1 == 1; |
| 62 | my z [1] [1..nx] == 1e-4; // straight tube, area 1 cm2. |
| 63 | */ |
| 64 | |
| 65 | void Ltas_draw (Ltas me, Graphics g, double fmin, double fmax, |
| 66 | double minimum, double maximum, bool garnish, conststring32 method); |
| 67 | |
| 68 | autoMatrix Ltas_to_Matrix (Ltas me); |
| 69 | autoLtas Matrix_to_Ltas (Matrix me); |
| 70 | |
| 71 | Collection_define (LtasBag, CollectionOf, Ltas) { |
| 72 | }; |
| 73 | |
| 74 | autoLtas Ltases_merge (LtasBag ltases); |
| 75 | autoLtas Ltases_average (LtasBag ltases); |
| 76 | |
| 77 | autoLtas Ltas_computeTrendLine (Ltas me, double fmin, double fmax); |
| 78 | autoLtas Ltas_subtractTrendLine (Ltas me, double fmin, double fmax); |
| 79 | |
| 80 | /* Direct computations. */ |
| 81 | |
| 82 | autoLtas Spectrum_to_Ltas (Spectrum me, double bandwidth); |
| 83 | autoLtas Spectrum_to_Ltas_1to1 (Spectrum me); |
| 84 | autoLtas PointProcess_Sound_to_Ltas (PointProcess pulses, Sound sound, |
| 85 | double maximumFrequency, double bandWidth, |
| 86 | double shortestPeriod, double longestPeriod, double maximumPeriodFactor); |
| 87 | autoLtas PointProcess_Sound_to_Ltas_harmonics (PointProcess pulses, Sound sound, |
| 88 | integer maximumHarmonic, |
| 89 | double shortestPeriod, double longestPeriod, double maximumPeriodFactor); |
| 90 | |
| 91 | /* Shortcuts. */ |
| 92 | |
| 93 | autoLtas Sound_to_Ltas (Sound me, double bandwidth); |
| 94 | autoLtas Sound_to_Ltas_pitchCorrected (Sound sound, double pitchFloor, double pitchCeiling, |
| 95 | double maximumFrequency, double bandWidth, |
| 96 | double shortestPeriod, double longestPeriod, double maximumPeriodFactor); |
| 97 | |
| 98 | double Ltas_getSlope (Ltas me, double f1min, double f1max, double f2min, double f2max, int averagingUnits); |
| 99 | double Ltas_getLocalPeakHeight (Ltas me, double environmentMin, double environmentMax, double peakMin, double peakMax, int averagingUnits); |
| 100 | |
| 101 | /* End of file Ltas.h */ |
| 102 | #endif |