| 1 |
/* praat_TimeFrameSampled.cpp |
| 2 |
* |
| 3 |
* Copyright (C) 2016,2017,2019,2021,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 "praat_TimeFrameSampled.h" |
| 20 |
|
| 21 |
// MARK: - TIMEFRAMESAMPLED |
| 22 |
|
| 23 |
DIRECT (INTEGER_TimeFrameSampled_getNumberOfFrames) { |
| 24 |
QUERY_ONE_FOR_REAL (Sampled) |
| 25 |
const integer result = my nx; |
| 26 |
QUERY_ONE_FOR_REAL_END (U" frames"); |
| 27 |
} |
| 28 |
|
| 29 |
FORM (REAL_TimeFrameSampled_getFrameNumberFromTime, U"Get frame number from time", U"Get frame number from time...") { |
| 30 |
REAL (time, U"Time (s)", U"0.5") |
| 31 |
OK |
| 32 |
DO |
| 33 |
QUERY_ONE_FOR_REAL (Sampled) |
| 34 |
const double result = Sampled_xToIndex (me, time); |
| 35 |
QUERY_ONE_FOR_REAL_END (U" (frame as a real number)") |
| 36 |
} |
| 37 |
|
| 38 |
DIRECT (REAL_TimeFrameSampled_getTimeStep) { |
| 39 |
QUERY_ONE_FOR_REAL (Sampled) |
| 40 |
const double result = my dx; |
| 41 |
QUERY_ONE_FOR_REAL_END (U" seconds") |
| 42 |
} |
| 43 |
|
| 44 |
FORM (REAL_TimeFrameSampled_getTimeFromFrameNumber, U"Get time from frame number", U"Get time from frame number...") { |
| 45 |
NATURAL (frameNumber, U"Frame number", U"1") |
| 46 |
OK |
| 47 |
DO |
| 48 |
QUERY_ONE_FOR_REAL (Sampled) |
| 49 |
const double result = Sampled_indexToX (me, frameNumber); |
| 50 |
QUERY_ONE_FOR_REAL_END (U" seconds") |
| 51 |
} |
| 52 |
|
| 53 |
DIRECT (NUMVEC_TimeFrameSampled_listAllFrameTimes) { |
| 54 |
QUERY_ONE_FOR_REAL_VECTOR (Sampled) |
| 55 |
autoVEC result = Sampled_listAllXValues (me); |
| 56 |
QUERY_ONE_FOR_REAL_VECTOR_END |
| 57 |
} |
| 58 |
|
| 59 |
// MARK: - buttons |
| 60 |
|
| 61 |
void praat_TimeFrameSampled_query_init (ClassInfo klas) { |
| 62 |
praat_TimeFunction_query_init (klas); |
| 63 |
praat_addAction1 (klas, 1, U"Query time sampling", nullptr, 1, nullptr); |
| 64 |
praat_addAction1 (klas, 1, U"Get number of frames", nullptr, 2, INTEGER_TimeFrameSampled_getNumberOfFrames); |
| 65 |
praat_addAction1 (klas, 1, U"Get time step || Get frame length || Get frame duration", nullptr, 2, REAL_TimeFrameSampled_getTimeStep); |
| 66 |
// alternatives GuiMenu_DEPRECATED_2004 |
| 67 |
praat_addAction1 (klas, 1, U"Get time from frame number... || Get time from frame...", nullptr, 2, REAL_TimeFrameSampled_getTimeFromFrameNumber); |
| 68 |
// alternatives GuiMenu_DEPRECATED_2004 |
| 69 |
praat_addAction1 (klas, 1, U"List all frame times", nullptr, 2, NUMVEC_TimeFrameSampled_listAllFrameTimes); |
| 70 |
praat_addAction1 (klas, 1, U"Get frame number from time... || Get frame from time...", nullptr, 2, REAL_TimeFrameSampled_getFrameNumberFromTime); |
| 71 |
// alternatives GuiMenu_DEPRECATED_2004 |
| 72 |
} |
| 73 |
|
| 74 |
/* End of file praat_TimeFrameSampled.cpp */ |