DurationTier.cpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* DurationTier.cpp
  2. *
  3. * Copyright (C) 1992-2012,2015,2016,2017 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. #include "DurationTier.h"
  19. Thing_implement (DurationTier, RealTier, 0);
  20. void structDurationTier :: v_info () {
  21. our structDaata :: v_info ();
  22. MelderInfo_writeLine (U"Time domain:");
  23. MelderInfo_writeLine (U" Start time: ", our xmin, U" seconds");
  24. MelderInfo_writeLine (U" End time: ", our xmax, U" seconds");
  25. MelderInfo_writeLine (U" Total original duration: ", our xmax - our xmin, U" seconds");
  26. MelderInfo_writeLine (U"Number of points: ", our points.size);
  27. MelderInfo_writeLine (U"Minimum relative duration value: ", RealTier_getMinimumValue (this));
  28. MelderInfo_writeLine (U"Maximum relative duration value: ", RealTier_getMaximumValue (this));
  29. }
  30. autoDurationTier DurationTier_create (double tmin, double tmax) {
  31. try {
  32. autoDurationTier me = Thing_new (DurationTier);
  33. RealTier_init (me.get(), tmin, tmax);
  34. return me;
  35. } catch (MelderError) {
  36. Melder_throw (U"DurationTier not created.");
  37. }
  38. }
  39. void DurationTier_draw (DurationTier me, Graphics g, double tmin, double tmax,
  40. double ymin, double ymax, conststring32 method, int garnish)
  41. {
  42. RealTier_draw (me, g, tmin, tmax, ymin, ymax, garnish, method, U"Relative duration");
  43. }
  44. autoDurationTier PointProcess_upto_DurationTier (PointProcess me) {
  45. try {
  46. autoDurationTier thee = DurationTier_create (my xmin, my xmax);
  47. for (integer i = 1; i <= my nt; i ++) {
  48. RealTier_addPoint (thee.get(), my t [i], 1.0);
  49. }
  50. return thee;
  51. } catch (MelderError) {
  52. Melder_throw (me, U": not converted to DurationTier.");
  53. }
  54. }
  55. /* End of file DurationTier.cpp */