Vector.h 4.0 KB

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