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