本文整理汇总了C++中Thing_new函数的典型用法代码示例。如果您正苦于以下问题:C++ Thing_new函数的具体用法?C++ Thing_new怎么用?C++ Thing_new使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Thing_new函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Configuration_create
autoConfiguration Configuration_create (long numberOfPoints, long numberOfDimensions) {
try {
autoConfiguration me = Thing_new (Configuration);
TableOfReal_init (me.peek(), numberOfPoints, numberOfDimensions);
my w = NUMvector<double> (1, numberOfDimensions);
TableOfReal_setSequentialRowLabels (me.peek(), 0, 0, nullptr, 1, 1);
TableOfReal_setSequentialColumnLabels (me.peek(), 0, 0, U"dimension ", 1, 1);
my metric = 2;
Configuration_setDefaultWeights (me.peek());
Configuration_randomize (me.peek());
return me;
} catch (MelderError) {
Melder_throw (U"Configuration not created.");
}
}
示例2: FujisakiPitch_create
FujisakiPitch FujisakiPitch_create (double tmin, double tmax,
double baseFrequency, double alpha, double beta, double gamma)
{
try {
autoFujisakiPitch me = Thing_new (FujisakiPitch);
Function_init (me.peek(), tmin, tmax);
my baseFrequency = baseFrequency;
my alpha = alpha;
my beta = beta;
my gamma = gamma;
my phraseCommands = SortedSetOfDouble_create ();
my accentCommands = SortedSetOfDouble_create ();
return me.transfer();
} catch (MelderError) {
Melder_throw ("FujisakiPitch not created.");
}
}
示例3: Strings_to_Categories
autoCategories Strings_to_Categories (Strings me) {
try {
if (my numberOfStrings < 1) {
Melder_throw (U"Empty strings.");
}
autoCategories thee = Thing_new (Categories);
thy _grow (my numberOfStrings);
for (long i = 1; i <= my numberOfStrings; i++) {
autoSimpleString s = SimpleString_create (my strings [i]);
thy addItem_move (s.move());
}
return thee;
} catch (MelderError) {
Melder_throw (me, U": not converted.");
}
}
示例4: espeakdata_voices_getNames
Strings espeakdata_voices_getNames (Table me, long column) {
try {
if (column < 0 || column > 2) {
Melder_throw (U"Illegal columnn.");
}
autoStrings thee = Thing_new (Strings);
thy strings = NUMvector <char32 *> (1, my rows -> size);
thy numberOfStrings = 0;
for (long irow = 1; irow <= my rows -> size; irow++) {
thy strings[irow] = Melder_dup (Table_getStringValue_Assert (me, irow, column));
thy numberOfStrings++;
}
return thee.transfer();
} catch (MelderError) {
Melder_throw (U"Espeakdata: voices not initialized.");
}
}
示例5: SPINET_create
autoSPINET SPINET_create (double tmin, double tmax, long nt, double dt, double t1, double minimumFrequency, double maximumFrequency, long nFilters, double excitationErbProportion, double inhibitionErbProportion) {
try {
autoSPINET me = Thing_new (SPINET);
double minErb = NUMhertzToErb (minimumFrequency);
double maxErb = NUMhertzToErb (maximumFrequency);
double dErb = (maxErb - minErb) / nFilters;
SampledXY_init (me.peek(), tmin, tmax, nt, dt, t1, minErb - dErb / 2.0, maxErb + dErb / 2.0, nFilters, dErb, minErb);
my y = NUMmatrix<double> (1, nFilters, 1, nt);
my s = NUMmatrix<double> (1, nFilters, 1, nt);
my gamma = 4;
my excitationErbProportion = excitationErbProportion;
my inhibitionErbProportion = inhibitionErbProportion;
return me;
} catch (MelderError) {
Melder_throw (U"SPINET not created.");
}
}
示例6: Categories_to_Strings
autoStrings Categories_to_Strings (Categories me) {
try {
if (my size < 1) {
Melder_throw (U"No elements.");
}
autoStrings thee = Thing_new (Strings);
thy strings = NUMvector<char32 *> (1, my size);
thy numberOfStrings = my size;
for (long i = 1; i <= my size; i ++) {
SimpleString s = my at [i];
thy strings [i] = Melder_dup (s -> string);
}
return thee;
} catch (MelderError) {
Melder_throw (me, U": not converted to Strings.");
}
}
示例7: IntervalTier_to_Strings_withOriginData
static autoStrings IntervalTier_to_Strings_withOriginData (IntervalTier me, long *from) {
try {
autoStrings thee = Thing_new (Strings);
thy strings = NUMvector<char32 *> (1, my intervals.size);
for (long i = 1; i <= my intervals.size; i ++) {
TextInterval ti = my intervals.at [i];
if (ti -> text && ti -> text [0] != U'\0') {
thy strings [++ thy numberOfStrings] = Melder_dup (ti -> text);
if (from) {
from [thy numberOfStrings] = i;
}
}
}
return thee;
} catch (MelderError) {
Melder_throw (me, U": no Strings created.");
}
}
示例8: KlattGrid_FormantGridEditor_create
autoKlattGrid_FormantGridEditor KlattGrid_FormantGridEditor_create (const char32 *title, KlattGrid data, int formantType) {
try {
Melder_assert (data);
autoFormantGrid* fg = KlattGrid_getAddressOfFormantGrid (data, formantType);
if (! fg) {
Melder_throw (U"Formant type unknown.");
}
if (FormantGrid_isEmpty (fg -> get())) {
Melder_throw (U"Cannot edit an empty formant grid.");
}
autoKlattGrid_FormantGridEditor me = Thing_new (KlattGrid_FormantGridEditor);
my klattgrid = data;
FormantGridEditor_init (me.peek(), title, fg->get());
return me;
} catch (MelderError) {
Melder_throw (U"KlattGrid formant window not created.");
}
}
示例9: Spectrum_to_Ltas
Ltas Spectrum_to_Ltas (Spectrum me, double bandWidth) {
try {
long numberOfBands = ceil ((my xmax - my xmin) / bandWidth);
if (bandWidth <= my dx)
Melder_throw ("Bandwidth must be greater than ", my dx, ".");
autoLtas thee = Thing_new (Ltas);
Matrix_init (thee.peek(), my xmin, my xmax, numberOfBands, bandWidth, my xmin + 0.5 * bandWidth, 1, 1, 1, 1, 1);
for (long iband = 1; iband <= numberOfBands; iband ++) {
double fmin = thy xmin + (iband - 1) * bandWidth;
double meanEnergyDensity = Sampled_getMean (me, fmin, fmin + bandWidth, 0, 1, FALSE);
double meanPowerDensity = meanEnergyDensity * my dx; // as an approximation for a division by the original duration
thy z [1] [iband] = meanPowerDensity == 0.0 ? -300.0 : 10.0 * log10 (meanPowerDensity / 4.0e-10);
}
return thee.transfer();
} catch (MelderError) {
Melder_throw (me, ": not converted to Ltas.");
}
}
示例10: RunnerMFC_create
RunnerMFC RunnerMFC_create (const wchar_t *title, Ordered experiments) {
try {
autoRunnerMFC me = Thing_new (RunnerMFC);
Editor_init (me.peek(), 0, 0, 2000, 2000, title, NULL);
my experiments = experiments;
my graphics = Graphics_create_xmdrawingarea (my d_drawingArea);
struct structGuiDrawingAreaResizeEvent event = { my d_drawingArea, 0 };
event. width = my d_drawingArea -> f_getWidth ();
event. height = my d_drawingArea -> f_getHeight ();
gui_drawingarea_cb_resize (me.peek(), & event);
my iexperiment = 1;
RunnerMFC_startExperiment (me.peek());
return me.transfer();
} catch (MelderError) {
Melder_throw ("Experiment window not created.");
}
}
示例11: Pitch_create
autoPitch Pitch_create (double tmin, double tmax, long nt, double dt, double t1,
double ceiling, int maxnCandidates)
{
try {
autoPitch me = Thing_new (Pitch);
Sampled_init (me.peek(), tmin, tmax, nt, dt, t1);
my ceiling = ceiling;
my maxnCandidates = maxnCandidates;
my frame = NUMvector <structPitch_Frame> (1, nt);
/* Put one candidate in every frame (unvoiced, silent). */
for (long it = 1; it <= nt; it ++) {
Pitch_Frame_init (& my frame [it], 1);
}
return me;
} catch (MelderError) {
Melder_throw (U"Pitch not created.");
}
}
示例12: Strings_insertAndExpand
static Strings Strings_insertAndExpand (Strings me, long position, const char32 *newstring) {
try {
if (position == 0) position = my numberOfStrings + 1;
Melder_assert (position >= 1);
Melder_assert (position <= my numberOfStrings + 1);
autoStrings thee = Thing_new (Strings);
thy strings = NUMvector<char32 *> (1, my numberOfStrings + 1);
for (long i = 1, from = 1; i <= my numberOfStrings + 1; i++, from++) {
const char32 *to_copy = my strings[from];
if (i == position) {
to_copy = newstring; from--;
}
thy strings[i] = Melder_dup (to_copy);
}
thy numberOfStrings = my numberOfStrings + 1;
return thee.transfer();
} catch (MelderError) {
Melder_throw (me, U" not expanded.");
}
}
示例13: Matrix_eigen
void Matrix_eigen (Matrix me, autoMatrix *out_eigenvectors, autoMatrix *out_eigenvalues) {
try {
if (my nx != my ny)
Melder_throw (U"(Matrix not square.");
autoEigen eigen = Thing_new (Eigen);
Eigen_initFromSymmetricMatrix (eigen.peek(), my z, my nx);
autoMatrix eigenvectors = Data_copy (me);
autoMatrix eigenvalues = Matrix_create (1.0, 1.0, 1, 1.0, 1.0, my ymin, my ymax, my ny, my dy, my y1);
for (long i = 1; i <= my nx; i ++) {
eigenvalues -> z [i] [1] = eigen -> eigenvalues [i];
for (long j = 1; j <= my nx; j ++)
eigenvectors -> z [i] [j] = eigen -> eigenvectors [j] [i];
}
*out_eigenvectors = eigenvectors.move();
*out_eigenvalues = eigenvalues.move();
} catch (MelderError) {
Melder_throw (me, U": eigenstructure not computed.");
}
}
示例14: VDSmagtMinimizer_create
autoVDSmagtMinimizer VDSmagtMinimizer_create (long nParameters, Daata object, double (*func) (Daata object, const double x[]), void (*dfunc) (Daata object, const double x[], double dx[])) {
try {
autoVDSmagtMinimizer me = Thing_new (VDSmagtMinimizer);
Minimizer_init (me.peek(), nParameters, object);
my dp = NUMvector<double> (1, nParameters);
my pc = NUMvector<double> (1, nParameters);
my gc = NUMvector<double> (1, nParameters);
my g0 = NUMvector<double> (1, nParameters);
my s = NUMvector<double> (1, nParameters);
my srst = NUMvector<double> (1, nParameters);
my grst = NUMvector<double> (1, nParameters);
my func = func;
my dfunc = dfunc;
my lineSearchGradient = 0.9;
my lineSearchMaxNumOfIterations = 5;
return me;
} catch (MelderError) {
Melder_throw (U"VDSmagtMinimizer not created.");
}
}
示例15: Movie_openFromSoundFile
autoMovie Movie_openFromSoundFile (MelderFile file)
{
try {
autoMovie me = Thing_new (Movie);
autoSound sound = Sound_readFromSoundFile (file);
autoMelderString fileNameHead;
MelderString_copy (& fileNameHead, Melder_fileToPath (file));
char32 *extensionLocation = str32rchr (fileNameHead.string, U'.');
if (! extensionLocation)
extensionLocation = & fileNameHead.string [fileNameHead.length];
*extensionLocation = U'\0';
fileNameHead.length = extensionLocation - fileNameHead.string;
autoStrings strings = Strings_createAsFileList (Melder_cat (fileNameHead.string, U"*.png"));
struct structMelderDir folder;
MelderFile_getParentDir (file, & folder);
Movie_init (me.peek(), sound.transfer(), Melder_dirToPath (& folder), strings.transfer());
return me;
} catch (MelderError) {
Melder_throw (U"Movie object not read from file ", file, U".");
}
}