| 1 |
#ifndef _SampledXY_h_ |
| 2 |
#define _SampledXY_h_ |
| 3 |
/* SampledXY.h |
| 4 |
* |
| 5 |
* Copyright (C) 1992-2011,2013-2017,2023,2024 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 "Sampled.h" |
| 22 |
|
| 23 |
#include "SampledXY_def.h" |
| 24 |
|
| 25 |
void SampledXY_init (mutableSampledXY me, double xmin, double xmax, integer nx, double dx, double x1, |
| 26 |
double ymin, double ymax, integer ny, double dy, double y1); |
| 27 |
|
| 28 |
template <typename T> static inline double SampledXY_indexToY (constSampledXY me, T index) { return my y1 + (index - (T) 1) * my dy; } |
| 29 |
static inline double SampledXY_yToIndex (constSampledXY me, double y) { return (y - my y1) / my dy + 1.0; } |
| 30 |
static inline integer SampledXY_yToLowIndex (constSampledXY me, double y) { return Melder_ifloor ((y - my y1) / my dy + 1.0); } |
| 31 |
static inline integer SampledXY_yToHighIndex (constSampledXY me, double y) { return Melder_iceiling ((y - my y1) / my dy + 1.0); } |
| 32 |
static inline integer SampledXY_yToNearestIndex (constSampledXY me, double y) { return Melder_iround ((y - my y1) / my dy + 1.0); } |
| 33 |
|
| 34 |
integer SampledXY_getWindowSamplesY ( |
| 35 |
const constSampledXY me, |
| 36 |
const double ymin, |
| 37 |
const double ymax, |
| 38 |
integer *const iymin, |
| 39 |
integer *const iymax |
| 40 |
); |
| 41 |
|
| 42 |
void SampledXY_unidirectionalAutowindowY ( |
| 43 |
const constSampledXY me, |
| 44 |
double *const ymin, |
| 45 |
double *const ymax |
| 46 |
); |
| 47 |
void SampledXY_bidirectionalAutowindowY ( |
| 48 |
const constSampledXY me, |
| 49 |
double *const y1, |
| 50 |
double *const y2 |
| 51 |
); |
| 52 |
|
| 53 |
/* End of file SampledXY.h */ |
| 54 |
#endif |