| 1 |
/* Pitch_def.h |
| 2 |
* |
| 3 |
* Copyright (C) 1992-2006,2008,2011,2012,2015-2020,2022,2023 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 2 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 |
/* Attributes: |
| 20 |
xmin // Start time (seconds). |
| 21 |
xmax > xmin // End time (seconds). |
| 22 |
nx >= 1 // Number of time slices. |
| 23 |
dx > 0.0 // Time step (seconds). |
| 24 |
x1 // Centre of first time slice (seconds). |
| 25 |
ceiling // Candidates with a higher frequency are unvoiced. |
| 26 |
maxnCandidates >= 1 // Maximum number of candidates per time slice. |
| 27 |
frame[1..nx].nCandidates // Number of candidates in each time slice, including the unvoiced candidate. |
| 28 |
frame[1..nx].candidate[1..nCandidates].frequency |
| 29 |
// The frequency of each candidate (Hz), 0 means aperiodic or silent. |
| 30 |
// candidate[1].frequency is the frequency of the currently best candidate. |
| 31 |
frame[1..nx].candidate[1..nCandidates].strength |
| 32 |
// The strength of each candidate, a real number between 0 and 1: |
| 33 |
// 0 means not periodic at all, 1 means perfectly periodic; |
| 34 |
// if the frequency of the candidate is 0, its strength is a real number |
| 35 |
// that represents the maximum periodicity that |
| 36 |
// can still be considered to be due to noise (e.g., 0.4). |
| 37 |
// candidate[1].strength is the strength of the currently best candidate. |
| 38 |
frame[1..nx].intensity |
| 39 |
// The relative intensity of each frame, a real number between 0 and 1. |
| 40 |
*/ |
| 41 |
|
| 42 |
|
| 43 |
#define ooSTRUCT Pitch_Candidate |
| 44 |
oo_DEFINE_STRUCT (Pitch_Candidate) |
| 45 |
|
| 46 |
oo_DOUBLE (frequency) |
| 47 |
oo_DOUBLE (strength) |
| 48 |
|
| 49 |
oo_END_STRUCT (Pitch_Candidate) |
| 50 |
#undef ooSTRUCT |
| 51 |
|
| 52 |
|
| 53 |
#define ooSTRUCT Pitch_Frame |
| 54 |
oo_DEFINE_STRUCT (Pitch_Frame) |
| 55 |
|
| 56 |
#if oo_READING_BINARY |
| 57 |
oo_VERSION_UNTIL (0) |
| 58 |
oo_INT16 (nCandidates) |
| 59 |
oo_FLOAT (intensity) |
| 60 |
oo_VERSION_ELSE_UNTIL (1) |
| 61 |
oo_FLOAT (intensity) |
| 62 |
oo_INTEGER (nCandidates) |
| 63 |
oo_VERSION_ELSE |
| 64 |
oo_DOUBLE (intensity) |
| 65 |
oo_INTEGER (nCandidates) |
| 66 |
oo_VERSION_END |
| 67 |
#else |
| 68 |
oo_DOUBLE (intensity) |
| 69 |
oo_INTEGER (nCandidates) |
| 70 |
#endif |
| 71 |
|
| 72 |
oo_STRUCTVEC (Pitch_Candidate, candidates, nCandidates) |
| 73 |
|
| 74 |
oo_END_STRUCT (Pitch_Frame) |
| 75 |
#undef ooSTRUCT |
| 76 |
|
| 77 |
|
| 78 |
#define ooSTRUCT Pitch |
| 79 |
oo_DEFINE_CLASS (Pitch, Sampled) |
| 80 |
|
| 81 |
oo_DOUBLE (ceiling) |
| 82 |
oo_INT16 (maxnCandidates) |
| 83 |
oo_STRUCTVEC (Pitch_Frame, frames, nx) |
| 84 |
|
| 85 |
#if oo_DECLARING |
| 86 |
void v1_info () |
| 87 |
override; |
| 88 |
int v_domainQuantity () const |
| 89 |
override { return MelderQuantity_TIME_SECONDS; } |
| 90 |
int v_getMinimumUnit (integer level) const |
| 91 |
override; |
| 92 |
int v_getMaximumUnit (integer level) const |
| 93 |
override; |
| 94 |
conststring32 v_getUnitText (integer level, int unit, uint32 flags) const |
| 95 |
override; |
| 96 |
bool v_isUnitLogarithmic (integer level, int unit) const |
| 97 |
override; |
| 98 |
double v_convertStandardToSpecialUnit (double value, integer level, int unit) const |
| 99 |
override; |
| 100 |
double v_convertSpecialToStandardUnit (double value, integer level, int unit) const |
| 101 |
override; |
| 102 |
double v_getValueAtSample (integer sampleNumber, integer level, int unit) const |
| 103 |
override; |
| 104 |
conststring32 v_getIndexText () const |
| 105 |
override { return U"frame number"; } |
| 106 |
conststring32 v_getNxText () const |
| 107 |
override { return U"the number of frames"; } |
| 108 |
#endif |
| 109 |
|
| 110 |
oo_END_CLASS (Pitch) |
| 111 |
#undef ooSTRUCT |
| 112 |
|
| 113 |
|
| 114 |
/* End of file Pitch_def.h */ |