SampledXY_def.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* SampledXY_def.h
  2. *
  3. * Copyright (C) 1992-2005,2008,2011-2018 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. #define ooSTRUCT SampledXY
  19. oo_DEFINE_CLASS (SampledXY, Sampled)
  20. oo_DOUBLE (ymin)
  21. oo_DOUBLE (ymax)
  22. oo_INTEGER (ny)
  23. oo_DOUBLE (dy)
  24. oo_DOUBLE (y1)
  25. #if oo_READING
  26. if (ymin > ymax) {
  27. Melder_throw (U"ymax should be at least as great as ymin.");
  28. }
  29. if (ny < 1) {
  30. Melder_throw (U"ny should be at least 1.");
  31. }
  32. if (dy <= 0.0) {
  33. Melder_throw (U"dy should be positive.");
  34. }
  35. #endif
  36. #if oo_DECLARING
  37. bool v_hasGetYmin ()
  38. override { return true; }
  39. double v_getYmin ()
  40. override { return ymin; }
  41. bool v_hasGetYmax ()
  42. override { return true; }
  43. double v_getYmax ()
  44. override { return ymax; }
  45. bool v_hasGetNy ()
  46. override { return true; }
  47. double v_getNy ()
  48. override { return ny; }
  49. bool v_hasGetDy ()
  50. override { return true; }
  51. double v_getDy ()
  52. override { return dy; }
  53. bool v_hasGetY ()
  54. override { return true; }
  55. double v_getY (integer iy)
  56. override { return y1 + (iy - 1) * dy; }
  57. #endif
  58. oo_END_CLASS (SampledXY)
  59. #undef ooSTRUCT
  60. /* End of file SampledXY_def.h */