Sampled_def.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* Sampled_def.h
  2. *
  3. * Copyright (C) 1992-2005,2011,2014-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 Sampled
  19. oo_DEFINE_CLASS (Sampled, Function)
  20. oo_INTEGER (nx)
  21. oo_DOUBLE (dx)
  22. oo_DOUBLE (x1)
  23. #if oo_READING
  24. Melder_require (xmax >= xmin,
  25. U"xmax should be at least as great as xmin.");
  26. Melder_require (nx >= 1,
  27. U"nx should be at least 1.");
  28. Melder_require (dx > 0.0,
  29. U"dx should be positive.");
  30. #endif
  31. #if oo_DECLARING
  32. bool v_hasGetNx ()
  33. override { return true; }
  34. double v_getNx ()
  35. override { return nx; }
  36. bool v_hasGetDx ()
  37. override { return true; }
  38. double v_getDx ()
  39. override { return dx; }
  40. bool v_hasGetX ()
  41. override { return true; }
  42. double v_getX (integer ix)
  43. override { return x1 + (ix - 1) * dx; }
  44. void v_shiftX (double xfrom, double xto)
  45. override;
  46. void v_scaleX (double xminfrom, double xmaxfrom, double xminto, double xmaxto)
  47. override;
  48. virtual double v_getValueAtSample (integer /* isamp */, integer /* ilevel */, int /* unit */)
  49. { return undefined; }
  50. #endif
  51. oo_END_CLASS (Sampled)
  52. #undef ooSTRUCT
  53. /* End of file Sampled_def.h */