| 1 |
/* Sampled_def.h |
| 2 |
* |
| 3 |
* Copyright (C) 1992-2005,2011,2014-2018,2020,2023,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 |
|
| 20 |
#define ooSTRUCT Sampled |
| 21 |
oo_DEFINE_CLASS (Sampled, Function) |
| 22 |
|
| 23 |
oo_INTEGER (nx) |
| 24 |
oo_DOUBLE (dx) |
| 25 |
oo_DOUBLE (x1) |
| 26 |
|
| 27 |
#if oo_READING |
| 28 |
Melder_require (xmax >= xmin, |
| 29 |
U"xmax should be at least as great as xmin."); |
| 30 |
Melder_require (nx >= 1, |
| 31 |
U"nx should be at least 1."); |
| 32 |
Melder_require (dx > 0.0, |
| 33 |
U"dx should be positive."); |
| 34 |
#endif |
| 35 |
|
| 36 |
#if oo_DECLARING |
| 37 |
bool v_hasGetNx () const |
| 38 |
override { return true; } |
| 39 |
double v_getNx () const |
| 40 |
override { return nx; } |
| 41 |
bool v_hasGetDx () const |
| 42 |
override { return true; } |
| 43 |
double v_getDx () const |
| 44 |
override { return dx; } |
| 45 |
bool v_hasGetX () const |
| 46 |
override { return true; } |
| 47 |
double v_getX (const integer ix) const |
| 48 |
override { return x1 + (ix - 1) * dx; } |
| 49 |
void v_shiftX (double xfrom, double xto) |
| 50 |
override; |
| 51 |
void v_scaleX (double xminfrom, double xmaxfrom, double xminto, double xmaxto) |
| 52 |
override; |
| 53 |
|
| 54 |
virtual double v_getValueAtSample (integer /* isamp */, integer /* ilevel */, int /* unit */) const |
| 55 |
{ return undefined; } |
| 56 |
virtual conststring32 v_getIndexText () const |
| 57 |
{ return U"index"; } |
| 58 |
virtual conststring32 v_getNxText () const |
| 59 |
{ return U"nx"; } |
| 60 |
virtual void checkIndex (const integer index) { |
| 61 |
Melder_require (index >= 1, |
| 62 |
U"The ", our v_getIndexText (), U" should be at least 1, but is ", index, U" instead."); |
| 63 |
Melder_require (index <= our nx, |
| 64 |
U"The ", our v_getIndexText (), U" should be at most ", our v_getNxText (), |
| 65 |
U" (", our nx, U"), but is ", index, U" instead." |
| 66 |
); |
| 67 |
} |
| 68 |
#endif // oo_DECLARING |
| 69 |
|
| 70 |
oo_END_CLASS (Sampled) |
| 71 |
#undef ooSTRUCT |
| 72 |
|
| 73 |
|
| 74 |
/* End of file Sampled_def.h */ |