| 1 | #ifndef _Spectrogram_h_ |
| 2 | #define _Spectrogram_h_ |
| 3 | /* Spectrogram.h |
| 4 | * |
| 5 | * Copyright (C) 1992-2007,2011,2012,2015-2019,2022,2023,2024,2026 David Weenink & Paul Boersma, 2026 yjzxkxdn (colour schemes) |
| 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 "Matrix.h" |
| 22 | #include "Graphics.h" |
| 23 | #include "Spectrogram_enums.h" |
| 24 | |
| 25 | Thing_define (Spectrogram, Matrix) { |
| 26 | void v1_info () |
| 27 | override; |
| 28 | int v_domainQuantity () const |
| 29 | override { return MelderQuantity_TIME_SECONDS; } |
| 30 | }; |
| 31 | |
| 32 | /* Attributes: |
| 33 | xmin // Start time (seconds). |
| 34 | xmax // End time (seconds). |
| 35 | nx // Number of time slices. |
| 36 | dx // The time between two subsequent time slices. |
| 37 | x1 // The centre of the first time slice. |
| 38 | ymin // Minimum frequency (Hz). |
| 39 | ymax // Maximum frequency (Hz). |
| 40 | dy // Frequency step (Hz). |
| 41 | y1 // Centre of first frequency band (Hz). |
| 42 | z [iy] [ix] // Power spectrum density. |
| 43 | */ |
| 44 | |
| 45 | autoSpectrogram Spectrogram_create (double tmin, double tmax, integer nt, double dt, double t1, |
| 46 | double fmin, double fmax, integer nf, double df, double f1); |
| 47 | /* |
| 48 | Function: |
| 49 | Create the spectrogram data structure. |
| 50 | Preconditions: |
| 51 | nt > 0; |
| 52 | nf > 0; |
| 53 | dt > 0.0; |
| 54 | df > 0.0; |
| 55 | Postconditions: |
| 56 | result -> xmin == tmin; result -> ymin == fmin; |
| 57 | result -> xmax == tmax; result -> ymax == fmax; |
| 58 | result -> nx == nt; result -> ny == nf; |
| 59 | result -> dx == dt; result -> dy == df; |
| 60 | result -> x1 == t1; result -> y1 == f1; |
| 61 | result -> z [1..nf] [1..nt] == 0.0; |
| 62 | */ |
| 63 | |
| 64 | void Spectrogram_paintInside (constSpectrogram me, Graphics g, |
| 65 | double tmin, double tmax, double fmin, double fmax, double maximum, bool autoscaling, |
| 66 | double dynamicRange, double preemphasis, double dynamicCompression, |
| 67 | kSpectrogram_colourMap colourMap, bool invertColours); |
| 68 | void Spectrogram_paint (constSpectrogram me, Graphics g, |
| 69 | double tmin, double tmax, double fmin, double fmax, double maximum, bool autoscaling, |
| 70 | double dynamicRange, double preemphasis, double dynamicCompression, |
| 71 | kSpectrogram_colourMap colourMap, bool invertColours, |
| 72 | bool garnish); |
| 73 | /* |
| 74 | Function: |
| 75 | Draw me to a Graphics. |
| 76 | If tmax <= tmin, draw all time samples. |
| 77 | If fmax <= fmin, draw all frequency bands. |
| 78 | Arguments: |
| 79 | dynamicRange (dB): the difference between the maximum intensity and the lowest visible intensity. |
| 80 | preemphasis (dB/octave): high-pass filtering. |
| 81 | dynamicCompression (0-1): |
| 82 | the amount by which weaker frames are enhanced in the direction of the strongest frame; |
| 83 | 0 = no compression, 1 = complete compression (all frames shown equally strong). |
| 84 | garnish: |
| 85 | a boolean that determines if a box, ticks, numbers, and text are written in the margins. |
| 86 | */ |
| 87 | |
| 88 | autoSpectrogram Matrix_to_Spectrogram (constMatrix me); |
| 89 | /* |
| 90 | Create a Spectrogram from a Matrix, |
| 91 | with deep copy of all its attributes, except class information and methods. |
| 92 | */ |
| 93 | |
| 94 | autoMatrix Spectrogram_to_Matrix (constSpectrogram me); |
| 95 | /* |
| 96 | Create a Matrix from a Spectrogram, |
| 97 | with deep copy of all its attributes, except class information and methods. |
| 98 | */ |
| 99 | |
| 100 | Collection_define (SpectrogramList, OrderedOf, Spectrogram) { |
| 101 | }; |
| 102 | |
| 103 | void SpectrogramList_paintInside (constSpectrogramList me, Graphics g, |
| 104 | double tmin, double tmax, double fmin, double fmax, double maximum, bool autoscaling, |
| 105 | double dynamicRange, double preemphasis, double dynamicCompression, |
| 106 | kSpectrogram_colourMap colourMap, bool invertColours); |
| 107 | void SpectrogramList_paint (constSpectrogramList me, Graphics g, |
| 108 | double tmin, double tmax, double fmin, double fmax, double maximum, bool autoscaling, |
| 109 | double dynamicRange, double preemphasis, double dynamicCompression, |
| 110 | kSpectrogram_colourMap colourMap, bool invertColours, |
| 111 | bool garnish); |
| 112 | |
| 113 | /* End of file Spectrogram.h */ |
| 114 | #endif |