| 1 |
/* FujisakiPitch.cpp |
| 2 |
* |
| 3 |
* Copyright (C) 2002-2011,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 |
|
| 19 |
#include "FujisakiPitch.h" |
| 20 |
|
| 21 |
#include "oo_DESTROY.h" |
| 22 |
#include "FujisakiPitch_def.h" |
| 23 |
#include "oo_COPY.h" |
| 24 |
#include "FujisakiPitch_def.h" |
| 25 |
#include "oo_EQUAL.h" |
| 26 |
#include "FujisakiPitch_def.h" |
| 27 |
#include "oo_CAN_WRITE_AS_ENCODING.h" |
| 28 |
#include "FujisakiPitch_def.h" |
| 29 |
#include "oo_WRITE_TEXT.h" |
| 30 |
#include "FujisakiPitch_def.h" |
| 31 |
#include "oo_READ_TEXT.h" |
| 32 |
#include "FujisakiPitch_def.h" |
| 33 |
#include "oo_WRITE_BINARY.h" |
| 34 |
#include "FujisakiPitch_def.h" |
| 35 |
#include "oo_READ_BINARY.h" |
| 36 |
#include "FujisakiPitch_def.h" |
| 37 |
#include "oo_DESCRIPTION.h" |
| 38 |
#include "FujisakiPitch_def.h" |
| 39 |
|
| 40 |
Thing_implement (FujisakiCommand, Function, 0); |
| 41 |
|
| 42 |
autoFujisakiCommand FujisakiCommand_create (double tmin, double tmax, double amplitude) { |
| 43 |
try { |
| 44 |
autoFujisakiCommand me = Thing_new (FujisakiCommand); |
| 45 |
Function_init (me.get(), tmin, tmax); |
| 46 |
my amplitude = amplitude; |
| 47 |
return me; |
| 48 |
} catch (MelderError) { |
| 49 |
Melder_throw (U"Fujisaki command not created."); |
| 50 |
} |
| 51 |
} |
| 52 |
|
| 53 |
Thing_implement (FujisakiPitch, Function, 0); |
| 54 |
|
| 55 |
autoFujisakiPitch FujisakiPitch_create (double tmin, double tmax, |
| 56 |
double baseFrequency, double alpha, double beta, double gamma) |
| 57 |
{ |
| 58 |
try { |
| 59 |
autoFujisakiPitch me = Thing_new (FujisakiPitch); |
| 60 |
Function_init (me.get(), tmin, tmax); |
| 61 |
my baseFrequency = baseFrequency; |
| 62 |
my alpha = alpha; |
| 63 |
my beta = beta; |
| 64 |
my gamma = gamma; |
| 65 |
return me; |
| 66 |
} catch (MelderError) { |
| 67 |
Melder_throw (U"FujisakiPitch not created."); |
| 68 |
} |
| 69 |
} |
| 70 |
|
| 71 |
autoFujisakiPitch Pitch_to_FujisakiPitch (Pitch me, double gamma, double /* timeResolution */, |
| 72 |
autoFujisakiPitch *intermediate1, autoFujisakiPitch *intermediate2, autoFujisakiPitch *intermediate3) |
| 73 |
{ |
| 74 |
try { |
| 75 |
autoFujisakiPitch thee = FujisakiPitch_create (my xmin, my xmax, 0, 0, 0, gamma); |
| 76 |
/* |
| 77 |
* Get phrase commands. |
| 78 |
*/ |
| 79 |
while (/* ... */ 0) { |
| 80 |
double onsetTime = /* ... */ 0.0; |
| 81 |
double offsetTime = /* ... */ 3.0; |
| 82 |
double amplitude = /* ... */ 1.0; |
| 83 |
autoFujisakiCommand phraseCommand = FujisakiCommand_create (onsetTime, offsetTime, amplitude); |
| 84 |
thy phraseCommands. addItem_move (phraseCommand.move()); |
| 85 |
} |
| 86 |
if (intermediate1) *intermediate1 = Data_copy (thee.get()); |
| 87 |
/* |
| 88 |
* Get accent commands. |
| 89 |
*/ |
| 90 |
while (/* ... */ 0) { |
| 91 |
double onsetTime = /* ... */ 0.0; |
| 92 |
double offsetTime = /* ... */ 3.0; |
| 93 |
double amplitude = /* ... */ 1.0; |
| 94 |
autoFujisakiCommand accentCommand = FujisakiCommand_create (onsetTime, offsetTime, amplitude); |
| 95 |
thy accentCommands. addItem_move (accentCommand.move()); |
| 96 |
} |
| 97 |
if (intermediate2) *intermediate2 = Data_copy (thee.get()); |
| 98 |
/* |
| 99 |
* Do some extra processing. |
| 100 |
*/ |
| 101 |
/* ... */ |
| 102 |
if (intermediate3) *intermediate3 = Data_copy (thee.get()); |
| 103 |
/* |
| 104 |
* Tidy up. |
| 105 |
*/ |
| 106 |
for (integer i = 1; i <= thy phraseCommands.size; i ++) { |
| 107 |
FujisakiCommand phraseCommand = thy phraseCommands.at [i]; |
| 108 |
/* ... */ |
| 109 |
} |
| 110 |
for (integer i = 1; i <= thy accentCommands.size; i ++) { |
| 111 |
FujisakiCommand accentCommand = thy accentCommands.at [i]; |
| 112 |
/* ... */ |
| 113 |
} |
| 114 |
return thee; |
| 115 |
} catch (MelderError) { |
| 116 |
Melder_throw (me, U": not converted to FujisakiPitch."); |
| 117 |
} |
| 118 |
} |
| 119 |
|
| 120 |
/* End of file FujisakiPitch.cpp */ |