| 1 | #ifndef _Vector_h_ |
| 2 | #define _Vector_h_ |
| 3 | /* Vector.h |
| 4 | * |
| 5 | * Copyright (C) 1992-2005,2007,2011,2012,2015-2018,2020,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 | /* Vector inherits from Matrix */ |
| 22 | /* A Vector is a horizontal Matrix. */ |
| 23 | /* The rows are 'channels'. There will often be only one channel, but e.g. a stereo sound has two. */ |
| 24 | #include "Matrix.h" |
| 25 | |
| 26 | Thing_define (Vector, Matrix) { |
| 27 | bool v_hasGetVector () const |
| 28 | override { return true; } |
| 29 | double v_getVector (integer irow, integer icol) const |
| 30 | override; |
| 31 | bool v_hasGetFunction1 () const |
| 32 | override { return true; } |
| 33 | double v_getFunction1 (integer irow, double x) const |
| 34 | override; |
| 35 | bool v_hasGetMatrix () const |
| 36 | override { return false; } |
| 37 | bool v_hasGetFunction2 () const |
| 38 | override { return false; } |
| 39 | double v_getValueAtSample (integer isamp, integer ilevel, int unit) const |
| 40 | override; |
| 41 | |
| 42 | VEC channel (integer channelNumber) { return z.row (channelNumber); } |
| 43 | }; |
| 44 | |
| 45 | #include "Vector_enums.h" |
| 46 | integer kVector_valueInterpolation_to_interpolationDepth (kVector_valueInterpolation valueInterpolationType); |
| 47 | integer kVector_peakInterpolation_to_interpolationDepth (kVector_peakInterpolation peakInterpolationType); |
| 48 | |
| 49 | #define Vector_CHANNEL_AVERAGE 0 |
| 50 | #define Vector_CHANNEL_1 1 |
| 51 | #define Vector_CHANNEL_2 2 |
| 52 | double Vector_getValueAtX (constVector me, double x, integer channel, kVector_valueInterpolation valueInterpolationType); |
| 53 | |
| 54 | void Vector_getMinimumAndX (constVector me, double xmin, double xmax, integer channel, kVector_peakInterpolation peakInterpolationType, |
| 55 | double *return_minimum, double *return_xOfMinimum); |
| 56 | void Vector_getMinimumAndXAndChannel (constVector me, double xmin, double xmax, kVector_peakInterpolation peakInterpolationType, |
| 57 | double *return_minimum, double *return_xOfMinimum, integer *return_channelOfMinimum); |
| 58 | void Vector_getMaximumAndX (constVector me, double xmin, double xmax, integer channel, kVector_peakInterpolation peakInterpolationType, |
| 59 | double *return_maximum, double *return_xOfMaximum); |
| 60 | void Vector_getMaximumAndXAndChannel (constVector me, double xmin, double xmax, kVector_peakInterpolation peakInterpolationType, |
| 61 | double *return_maximum, double *return_xOfMaximum, integer *return_channelOfMaximum); |
| 62 | double Vector_getMinimum (constVector me, double xmin, double xmax, kVector_peakInterpolation peakInterpolationType); |
| 63 | double Vector_getMaximum (constVector me, double xmin, double xmax, kVector_peakInterpolation peakInterpolationType); |
| 64 | double Vector_getAbsoluteExtremum (constVector me, double xmin, double xmax, kVector_peakInterpolation peakInterpolationType); |
| 65 | double Vector_getXOfMinimum (constVector me, double xmin, double xmax, kVector_peakInterpolation peakInterpolationType); |
| 66 | double Vector_getXOfMaximum (constVector me, double xmin, double xmax, kVector_peakInterpolation peakInterpolationType); |
| 67 | integer Vector_getChannelOfMinimum (constVector me, double xmin, double xmax, kVector_peakInterpolation peakInterpolationType); |
| 68 | integer Vector_getChannelOfMaximum (constVector me, double xmin, double xmax, kVector_peakInterpolation peakInterpolationType); |
| 69 | |
| 70 | double Vector_getMean (constVector me, double xmin, double xmax, integer channel); |
| 71 | double Vector_getStandardDeviation (constVector me, double xmin, double xmax, integer channel); |
| 72 | |
| 73 | void Vector_addScalar (mutableVector me, double scalar); |
| 74 | void Vector_subtractMean (mutableVector me); |
| 75 | void Vector_multiplyByScalar (mutableVector me, double scalar); |
| 76 | void Vector_scale (mutableVector me, double scale); |
| 77 | |
| 78 | void Vector_draw (constVector me, Graphics g, double *pxmin, double *pxmax, double *pymin, double *pymax, |
| 79 | double defaultDy, conststring32 method); |
| 80 | /* |
| 81 | If *pxmin equals *pxmax, then autowindowing from my xmin to my xmax. |
| 82 | If *pymin equals *pymax, then autoscaling from minimum to maximum; |
| 83 | if minimum then equals maximum, defaultDy will be subtracted from *pymin and added to *pymax; |
| 84 | it must be a positive real number (e.g. 0.5 Pa for Sound, 1.0 dB for Ltas). |
| 85 | method can be "curve", "bars", "poles", or "speckles"; it must not be null; |
| 86 | if anything else is specified, a curve is drawn. |
| 87 | */ |
| 88 | |
| 89 | /* End of file Vector.h */ |
| 90 | #endif |