void structBandFilterSpectrogram :: v_info () { structDaata :: v_info (); MelderInfo_writeLine (U"Time domain:"); MelderInfo_writeLine (U" Start time: ", xmin, U" seconds"); MelderInfo_writeLine (U" End time: ", xmax, U" seconds"); MelderInfo_writeLine (U" Total duration: ", xmax - xmin, U" seconds"); MelderInfo_writeLine (U"Time sampling:"); MelderInfo_writeLine (U" Number of time slices (frames): ", nx); MelderInfo_writeLine (U" Time step (frame distance): ", dx, U" seconds"); MelderInfo_writeLine (U" First time slice (frame centre) at: ", x1, U" seconds"); }
void structFormant :: v_info () { structData :: v_info (); MelderInfo_writeLine (U"Time domain:"); MelderInfo_writeLine (U" Start time: ", xmin, U" seconds"); MelderInfo_writeLine (U" End time: ", xmax, U" seconds"); MelderInfo_writeLine (U" Total duration: ", xmax - xmin, U" seconds"); MelderInfo_writeLine (U"Time sampling:"); MelderInfo_writeLine (U" Number of frames: ", nx); MelderInfo_writeLine (U" Time step: ", dx, U" seconds"); MelderInfo_writeLine (U" First frame centred at: ", x1, U" seconds"); }
void structIntensity :: v_info () { structData :: v_info (); MelderInfo_writeLine (L"Time domain:"); MelderInfo_writeLine (L" Start time: ", Melder_double (xmin), L" seconds"); MelderInfo_writeLine (L" End time: ", Melder_double (xmax), L" seconds"); MelderInfo_writeLine (L" Total duration: ", Melder_double (xmax - xmin), L" seconds"); MelderInfo_writeLine (L"Time sampling:"); MelderInfo_writeLine (L" Number of frames: ", Melder_integer (nx)); MelderInfo_writeLine (L" Time step: ", Melder_double (dx), L" seconds"); MelderInfo_writeLine (L" First frame centred at: ", Melder_double (x1), L" seconds"); }
void structMelSpectrogram :: v_info () { structBandFilterSpectrogram :: v_info (); MelderInfo_writeLine (U"Frequency domain:"); MelderInfo_writeLine (U" Lowest frequency: ", ymin, U" ", v_getFrequencyUnit ()); MelderInfo_writeLine (U" Highest frequency: ", ymax, U" ", v_getFrequencyUnit ()); MelderInfo_writeLine (U" Total bandwidth: ", ymax - ymin, U" ", v_getFrequencyUnit ()); MelderInfo_writeLine (U"Frequency sampling:"); MelderInfo_writeLine (U" Number of frequency bands (bins): ", ny); MelderInfo_writeLine (U" Frequency step (bin width): ", dy, U" ", v_getFrequencyUnit ()); MelderInfo_writeLine (U" First frequency band around (bin centre at): ", y1, U" ", v_getFrequencyUnit ()); }
void Pitch_difference (Pitch me, Pitch thee) { long nuvtov = 0, nvtouv = 0, ndfdown = 0, ndfup = 0; if (my nx != thy nx || my dx != thy dx || my x1 != thy x1) { Melder_flushError (U"Pitch_difference: these Pitches are not aligned."); return; } for (long i = 1; i <= my nx; i ++) { double myf = my frame [i]. candidate [1]. frequency, thyf = thy frame [i]. candidate [1]. frequency; int myUnvoiced = myf == 0 || myf > my ceiling; int thyUnvoiced = thyf == 0 || thyf > thy ceiling; double t = Sampled_indexToX (me, i); if (myUnvoiced && ! thyUnvoiced) { Melder_casual ( U"Frame ", i, U" time ", t, U": unvoiced to voiced." ); nuvtov ++; } else if (! myUnvoiced && thyUnvoiced) { Melder_casual ( U"Frame ", i, U" time ", t, U": voiced to unvoiced." ); nvtouv ++; } else if (! myUnvoiced && ! thyUnvoiced) { if (myf > thyf) { //Melder_casual ("Frame %ld time %f: downward frequency jump from %.5g Hz to %.5g Hz.", i, t, myf, thyf); ndfdown ++; } else if (myf < thyf) { //Melder_casual ("Frame %ld time %f: upward frequency jump from %.5g Hz to %.5g Hz.", i, t, myf, thyf); ndfup ++; } } } MelderInfo_open (); MelderInfo_writeLine (U"Difference between two Pitches:"); MelderInfo_writeLine (U"Unvoiced to voiced: ", nuvtov, U" frames."); MelderInfo_writeLine (U"Voiced to unvoiced: ", nvtouv, U" frames."); MelderInfo_writeLine (U"Downward frequency jump: ", ndfdown, U" frames."); MelderInfo_writeLine (U"Upward frequency jump: ", ndfup, U" frames."); MelderInfo_close (); }
void structMovie :: v_info () { structDaata :: v_info (); MelderInfo_writeLine (U"Start time: ", xmin, U" seconds"); MelderInfo_writeLine (U"End time: ", xmax, U" seconds"); MelderInfo_writeLine (U"Total duration: ", xmax - xmin, U" seconds"); MelderInfo_writeLine (U"Time sampling:"); MelderInfo_writeLine (U" Number of frames: ", nx); MelderInfo_writeLine (U" Frame duration: ", dx, U" seconds"); MelderInfo_writeLine (U" Frame rate: ", Melder_single (1.0 / dx), U" frames per second"); MelderInfo_writeLine (U" First frame centred at: ", x1, U" seconds"); }
void praat_reportIntegerProperties () { MelderInfo_open (); MelderInfo_writeLine (U"Integer properties of this edition of Praat on this computer:\n"); MelderInfo_writeLine (U"A \"short integer\" is ", sizeof (short) * 8, U" bits."); MelderInfo_writeLine (U"An \"integer\" is ", sizeof (int) * 8, U" bits."); MelderInfo_writeLine (U"A \"long integer\" is ", sizeof (long) * 8, U" bits."); MelderInfo_writeLine (U"A \"long long integer\" is ", sizeof (long long) * 8, U" bits."); MelderInfo_writeLine (U"A pointer is ", sizeof (void *) * 8, U" bits."); MelderInfo_writeLine (U"A memory object size is ", sizeof (size_t) * 8, U" bits."); MelderInfo_writeLine (U"A file offset is ", sizeof (off_t) * 8, U" bits."); MelderInfo_close (); }
long Thing_listReadableClasses () { Melder_clearInfo (); MelderInfo_open (); for (long iclass = 1; iclass <= theNumberOfReadableClasses; iclass ++) { ClassInfo klas = theReadableClasses [iclass]; MelderInfo_writeLine (klas -> sequentialUniqueIdOfReadableClass, U"\t", klas -> className); } MelderInfo_close (); return theNumberOfReadableClasses; }
void structDurationTier :: v_info () { structData :: v_info (); MelderInfo_writeLine (U"Time domain:"); MelderInfo_writeLine (U" Start time: ", xmin, U" seconds"); MelderInfo_writeLine (U" End time: ", xmax, U" seconds"); MelderInfo_writeLine (U" Total original duration: ", xmax - xmin, U" seconds"); MelderInfo_writeLine (U"Number of points: ", points -> size); MelderInfo_writeLine (U"Minimum relative duration value: ", RealTier_getMinimumValue (this)); MelderInfo_writeLine (U"Maximum relative duration value: ", RealTier_getMaximumValue (this)); }
void structSpectrumTier :: v_info () { structDaata :: v_info (); MelderInfo_writeLine (U"Frequency domain:"); MelderInfo_writeLine (U" Lowest frequency: ", xmin, U" Hz"); MelderInfo_writeLine (U" Highest frequency: ", xmax, U" Hz"); MelderInfo_writeLine (U" Total bandwidth: ", xmax - xmin, U" Hz"); MelderInfo_writeLine (U"Number of points: ", points -> size); MelderInfo_writeLine (U"Minimum power value: ", RealTier_getMinimumValue (this), U" dB/Hz"); MelderInfo_writeLine (U"Maximum power value: ", RealTier_getMaximumValue (this), U" dB/Hz"); }
void structCC :: v_info () { structDaata :: v_info (); MelderInfo_writeLine (U"Time domain:", xmin, U" to ", xmax, U" seconds"); MelderInfo_writeLine (U"Number of frames: ", nx); MelderInfo_writeLine (U"Time step: ", dx, U" seconds"); MelderInfo_writeLine (U"First frame at: ", x1, U" seconds"); MelderInfo_writeLine (U"Number of coefficients: ", maximumNumberOfCoefficients); MelderInfo_writeLine (U"Minimum frequency: ", fmin, U" Hz"); MelderInfo_writeLine (U"Maximum frequency: ", fmax, U" Hz"); }
void structDurationTier :: v_info () { structData :: v_info (); MelderInfo_writeLine (L"Time domain:"); MelderInfo_writeLine (L" Start time: ", Melder_double (xmin), L" seconds"); MelderInfo_writeLine (L" End time: ", Melder_double (xmax), L" seconds"); MelderInfo_writeLine (L" Total original duration: ", Melder_double (xmax - xmin), L" seconds"); MelderInfo_writeLine (L"Number of points: ", Melder_integer (points -> size)); MelderInfo_writeLine (L"Minimum relative duration value: ", Melder_double (RealTier_getMinimumValue (this))); MelderInfo_writeLine (L"Maximum relative duration value: ", Melder_double (RealTier_getMaximumValue (this))); }
void structFFNet :: v_info () { structDaata :: v_info (); MelderInfo_writeLine (U"Number of layers: ", nLayers); MelderInfo_writeLine (U"Total number of units: ", FFNet_getNumberOfUnits (this)); MelderInfo_writeLine (U" Number of units in layer ", nLayers, U" (output): ", nUnitsInLayer[nLayers]); for (long i = nLayers - 1; i >= 1; i--) { MelderInfo_writeLine (U" Number of units in layer ", i, U" (hidden): ", nUnitsInLayer[i]); } MelderInfo_writeLine (U" Number of units in layer 0 (input): ", nUnitsInLayer[0]); MelderInfo_writeLine (U"Outputs are linear: ", Melder_boolean (outputsAreLinear)); MelderInfo_writeLine (U"Number of weights: ", nWeights, U" (", FFNet_dimensionOfSearchSpace (this), U" selected)"); MelderInfo_writeLine (U"Number of nodes: ", nNodes); }
void praat_reportTextProperties () { MelderInfo_open (); MelderInfo_writeLine (U"Text properties of this edition of Praat on this computer:\n"); MelderInfo_writeLine (U"Locale: ", Melder_peek8to32 (setlocale (LC_ALL, nullptr))); MelderInfo_writeLine (U"A \"char\" is ", 8, U" bits."); MelderInfo_writeLine (U"A \"char16_t\" is ", sizeof (char16_t) * 8, U" bits."); MelderInfo_writeLine (U"A \"wchar_t\" is ", sizeof (wchar_t) * 8, U" bits."); MelderInfo_writeLine (U"A \"char32_t\" is ", sizeof (char32_t) * 8, U" bits."); MelderInfo_close (); }
static void infoPeriods (PointProcess me, double shortestPeriod, double longestPeriod, double maximumPeriodFactor, int precision) { long numberOfPeriods = PointProcess_getNumberOfPeriods (me, 0.0, 0.0, shortestPeriod, longestPeriod, maximumPeriodFactor); double meanPeriod = PointProcess_getMeanPeriod (me, 0.0, 0.0, shortestPeriod, longestPeriod, maximumPeriodFactor); double stdevPeriod = PointProcess_getStdevPeriod (me, 0.0, 0.0, shortestPeriod, longestPeriod, maximumPeriodFactor); double jitter_local = PointProcess_getJitter_local (me, 0.0, 0.0, shortestPeriod, longestPeriod, maximumPeriodFactor); double jitter_local_absolute = PointProcess_getJitter_local_absolute (me, 0.0, 0.0, shortestPeriod, longestPeriod, maximumPeriodFactor); double jitter_rap = PointProcess_getJitter_rap (me, 0.0, 0.0, shortestPeriod, longestPeriod, maximumPeriodFactor); double jitter_ppq5 = PointProcess_getJitter_ppq5 (me, 0.0, 0.0, shortestPeriod, longestPeriod, maximumPeriodFactor); double jitter_ddp = PointProcess_getJitter_ddp (me, 0.0, 0.0, shortestPeriod, longestPeriod, maximumPeriodFactor); MelderInfo_writeLine (U" Number of periods: ", numberOfPeriods); MelderInfo_writeLine (U" Mean period: ", meanPeriod, U" seconds"); MelderInfo_writeLine (U" Stdev period: ", stdevPeriod, U" seconds"); MelderInfo_writeLine (U" Jitter (local): ", Melder_percent (jitter_local, precision)); MelderInfo_writeLine (U" Jitter (local, absolute): ", Melder_fixedExponent (jitter_local_absolute, -6, precision), U" seconds"); MelderInfo_writeLine (U" Jitter (rap): ", Melder_percent (jitter_rap, precision)); MelderInfo_writeLine (U" Jitter (ppq5): ", Melder_percent (jitter_ppq5, precision)); MelderInfo_writeLine (U" Jitter (ddp): ", Melder_percent (jitter_ddp, precision)); }
void structLongSound :: v_info () { static const char32 *encodingStrings [1+20] = { U"none", U"linear 8 bit signed", U"linear 8 bit unsigned", U"linear 16 bit big-endian", U"linear 16 bit little-endian", U"linear 24 bit big-endian", U"linear 24 bit little-endian", U"linear 32 bit big-endian", U"linear 32 bit little-endian", U"mu-law", U"A-law", U"shorten", U"polyphone", U"IEEE float 32 bit big-endian", U"IEEE float 32 bit little-endian", U"FLAC", U"FLAC", U"FLAC", U"MP3", U"MP3", U"MP3" }; structDaata :: v_info (); MelderInfo_writeLine (U"Duration: ", xmax - xmin, U" seconds"); MelderInfo_writeLine (U"File name: ", Melder_fileToPath (& file)); MelderInfo_writeLine (U"File type: ", audioFileType > Melder_NUMBER_OF_AUDIO_FILE_TYPES ? U"unknown" : Melder_audioFileTypeString (audioFileType)); MelderInfo_writeLine (U"Number of channels: ", numberOfChannels); MelderInfo_writeLine (U"Encoding: ", encoding > 20 ? U"unknown" : encodingStrings [encoding]); MelderInfo_writeLine (U"Sampling frequency: ", sampleRate, U" Hz"); MelderInfo_writeLine (U"Size: ", nx, U" samples"); MelderInfo_writeLine (U"Start of sample data: ", startOfData, U" bytes from the start of the file"); }
void structRegression :: v_info () { Regression_Parent :: v_info (); MelderInfo_writeLine (U"Factors:"); MelderInfo_writeLine (U" Number of factors: ", parameters -> size); for (long ivar = 1; ivar <= parameters -> size; ivar ++) { RegressionParameter parm = static_cast<RegressionParameter> (parameters -> item [ivar]); MelderInfo_writeLine (U" Factor ", ivar, U": ", parm -> label); } MelderInfo_writeLine (U"Fitted coefficients:"); MelderInfo_writeLine (U" Intercept: ", intercept); for (long ivar = 1; ivar <= parameters -> size; ivar ++) { RegressionParameter parm = static_cast<RegressionParameter> (parameters -> item [ivar]); MelderInfo_writeLine (U" Coefficient of factor ", parm -> label, U": ", parm -> value); } MelderInfo_writeLine (U"Ranges of values:"); for (long ivar = 1; ivar <= parameters -> size; ivar ++) { RegressionParameter parm = static_cast<RegressionParameter> (parameters -> item [ivar]); MelderInfo_writeLine (U" Range of factor ", parm -> label, U": minimum ", parm -> minimum, U", maximum ", parm -> maximum); } }
void structLogisticRegression :: v_info () { LogisticRegression_Parent :: v_info (); MelderInfo_writeLine (U"Dependent 1: ", our dependent1); MelderInfo_writeLine (U"Dependent 2: ", our dependent2); MelderInfo_writeLine (U"Interpretation:"); MelderInfo_write (U" ln (P(", dependent2, U")/P(", dependent1, U")) " UNITEXT_ALMOST_EQUAL_TO U" ", Melder_fixed (intercept, 6)); for (long ivar = 1; ivar <= parameters.size; ivar ++) { RegressionParameter parm = parameters.at [ivar]; MelderInfo_write (parm -> value < 0.0 ? U" - " : U" + ", Melder_fixed (fabs (parm -> value), 6), U" * ", parm -> label); } MelderInfo_writeLine (U""); MelderInfo_writeLine (U"Log odds ratios:"); for (long ivar = 1; ivar <= parameters.size; ivar ++) { RegressionParameter parm = parameters.at [ivar]; MelderInfo_writeLine (U" Log odds ratio of factor ", parm -> label, U": ", Melder_fixed ((parm -> maximum - parm -> minimum) * parm -> value, 6)); } MelderInfo_writeLine (U"Odds ratios:"); for (long ivar = 1; ivar <= parameters.size; ivar ++) { RegressionParameter parm = parameters.at [ivar]; MelderInfo_writeLine (U" Odds ratio of factor ", parm -> label, U": ", exp ((parm -> maximum - parm -> minimum) * parm -> value)); } }
void structConfusion :: v_info () { double h, hx, hy, hygx, hxgy, uygx, uxgy, uxy, frac; long nCorrect; Confusion_getEntropies (this, & h, & hx, & hy, & hygx, & hxgy, & uygx, & uxgy, & uxy); Confusion_getFractionCorrect (this, & frac, & nCorrect); MelderInfo_writeLine (U"Number of rows: ", numberOfRows); MelderInfo_writeLine (U"Number of colums: ", numberOfColumns); MelderInfo_writeLine (U"Entropies (y is row variable):"); MelderInfo_writeLine (U" Total: ", h); MelderInfo_writeLine (U" Y: ", hy); MelderInfo_writeLine (U" X: ", hx); MelderInfo_writeLine (U" Y given x: ", hygx); MelderInfo_writeLine (U" X given y: ", hxgy); MelderInfo_writeLine (U" Dependency of y on x; ", uygx); MelderInfo_writeLine (U" Dependency of x on y: ", uxgy); MelderInfo_writeLine (U" Symmetrical dependency: ", uxy); MelderInfo_writeLine (U" Total number of entries: ", Confusion_getNumberOfEntries (this)); MelderInfo_writeLine (U" Fraction correct: ", frac); }
void structCrossCorrelationTable :: v_info () { structSSCP :: v_info (); double dm = CrossCorrelationTable_getDiagonalityMeasure (this); MelderInfo_writeLine (U"Diagonality measure: ", dm); }
static void readSound (ExperimentMFC me, const char32 *fileNameHead, const char32 *fileNameTail, double medialSilenceDuration, char32 **name, autoSound *sound) { char32 fileNameBuffer [256], *fileNames = & fileNameBuffer [0]; Melder_sprint (fileNameBuffer,256, *name); structMelderFile file = { 0 }; /* * The following conversion is needed when fileNameHead is an absolute path, * and the stimulus names contain slashes for relative paths. * An ugly case, but allowed. */ #if defined (_WIN32) for (;;) { char32 *slash = str32chr (fileNames, U'/'); if (! slash) break; *slash = U'\\'; } #endif sound->reset(); char32 pathName [kMelder_MAXPATH+1]; /* * 'fileNames' can contain commas, which separate partial file names. * The separate files should be concatenated. */ for (;;) { /* * Determine partial file name. */ char32 *comma = str32chr (fileNames, U','); if (comma) *comma = '\0'; /* * Determine complete (relative) file name. */ Melder_sprint (pathName,kMelder_MAXPATH+1, fileNameHead, fileNames, fileNameTail); /* * Make sure we are in the correct directory. */ if (MelderDir_isNull (& my rootDirectory)) { /* * Absolute file name. */ Melder_pathToFile (pathName, & file); } else { /* * Relative or absolute file name. */ MelderDir_relativePathToFile (& my rootDirectory, pathName, & file); if (Melder_debug == 32) { MelderInfo_open (); MelderInfo_writeLine (U"Path name <", pathName, U">"); MelderInfo_writeLine (U"Root directory <", my rootDirectory.path, U">"); MelderInfo_writeLine (U"Full path name <", file.path, U">"); MelderInfo_close (); } } /* * Read the substimulus. */ autoSound substimulus = Data_readFromFile (& file). static_cast_move<structSound>(); if (substimulus -> classInfo != classSound) Melder_throw (U"File ", & file, U" contains a ", Thing_className (substimulus.get()), U" instead of a sound."); /* * Check whether all sounds have the same number of channels. */ if (my numberOfChannels == 0) { my numberOfChannels = substimulus -> ny; } else if (substimulus -> ny != my numberOfChannels) { Melder_throw (U"The sound in file ", & file, U" has a different number of channels than some other sound."); } /* * Check whether all sounds have the same sampling frequency. */ if (my samplePeriod == 0.0) { my samplePeriod = substimulus -> dx; /* This must be the first sound read. */ } else if (substimulus -> dx != my samplePeriod) { Melder_throw (U"The sound in file ", & file, U" has a different sampling frequency than some other sound."); } /* * Append the substimuli, perhaps with silent intervals. */ if (*sound) { *sound = Sounds_append (sound->get(), medialSilenceDuration, substimulus.get()); } else { *sound = substimulus.move(); } /* * Cycle. */ if (! comma) break; fileNames = & comma [1]; } }
void structSpectrogram :: v_info () { structData :: v_info (); MelderInfo_writeLine (U"Time domain:"); MelderInfo_writeLine (U" Start time: ", xmin, U" seconds"); MelderInfo_writeLine (U" End time: ", xmax, U" seconds"); MelderInfo_writeLine (U" Total duration: ", xmax - xmin, U" seconds"); MelderInfo_writeLine (U"Time sampling:"); MelderInfo_writeLine (U" Number of time slices (frames): ", nx); MelderInfo_writeLine (U" Time step (frame distance): ", dx, U" seconds"); MelderInfo_writeLine (U" First time slice (frame centre) at: ", x1, U" seconds"); MelderInfo_writeLine (U"Frequency domain:"); MelderInfo_writeLine (U" Lowest frequency: ", ymin, U" Hz"); MelderInfo_writeLine (U" Highest frequency: ", ymax, U" Hz"); MelderInfo_writeLine (U" Total bandwidth: ", ymax - ymin, U" Hz"); MelderInfo_writeLine (U"Frequency sampling:"); MelderInfo_writeLine (U" Number of frequency bands (bins): ", ny); MelderInfo_writeLine (U" Frequency step (bin width): ", dy, U" Hz"); MelderInfo_writeLine (U" First frequency band around (bin centre at): ", y1, U" Hz"); }
void structTableEditor :: v_info () { our TableEditor_Parent :: v_info (); MelderInfo_writeLine (U"Table uses text styles: ", our p_useTextStyles); //MelderInfo_writeLine (U"Table font size: ", our p_fontSize); }
void structPitch :: v_info () { long nVoiced; autoNUMvector <double> frequencies (Sampled_getSortedValues (this, Pitch_LEVEL_FREQUENCY, kPitch_unit_HERTZ, & nVoiced), 1); structDaata :: v_info (); MelderInfo_writeLine (U"Time domain:"); MelderInfo_writeLine (U" Start time: ", xmin, U" seconds"); MelderInfo_writeLine (U" End time: ", xmax, U" seconds"); MelderInfo_writeLine (U" Total duration: ", xmax - xmin, U" seconds"); MelderInfo_writeLine (U"Time sampling:"); MelderInfo_writeLine (U" Number of frames: ", nx, U" (", nVoiced, U" voiced)"); MelderInfo_writeLine (U" Time step: ", dx, U" seconds"); MelderInfo_writeLine (U" First frame centred at: ", x1, U" seconds"); MelderInfo_writeLine (U"Ceiling at: ", ceiling, U" Hz"); if (nVoiced >= 1) { // quantiles double quantile10, quantile16, quantile50, quantile84, quantile90; quantile10 = NUMquantile (nVoiced, frequencies.peek(), 0.10); quantile16 = NUMquantile (nVoiced, frequencies.peek(), 0.16); quantile50 = NUMquantile (nVoiced, frequencies.peek(), 0.50); // median quantile84 = NUMquantile (nVoiced, frequencies.peek(), 0.84); quantile90 = NUMquantile (nVoiced, frequencies.peek(), 0.90); MelderInfo_writeLine (U"\nEstimated quantiles:"); MelderInfo_write (U" 10% = ", Melder_single (quantile10), U" Hz = ", Melder_single (MEL (quantile10)), U" Mel = "); MelderInfo_writeLine (Melder_single (SEMITONES (quantile10)), U" semitones above 100 Hz = ", Melder_single (ERB (quantile10)), U" ERB"); MelderInfo_write (U" 16% = ", Melder_single (quantile16), U" Hz = ", Melder_single (MEL (quantile16)), U" Mel = "); MelderInfo_writeLine (Melder_single (SEMITONES (quantile16)), U" semitones above 100 Hz = ", Melder_single (ERB (quantile16)), U" ERB"); MelderInfo_write (U" 50% = ", Melder_single (quantile50), U" Hz = ", Melder_single (MEL (quantile50)), U" Mel = "); MelderInfo_writeLine (Melder_single (SEMITONES (quantile50)), U" semitones above 100 Hz = ", Melder_single (ERB (quantile50)), U" ERB"); MelderInfo_write (U" 84% = ", Melder_single (quantile84), U" Hz = ", Melder_single (MEL (quantile84)), U" Mel = "); MelderInfo_writeLine (Melder_single (SEMITONES (quantile84)), U" semitones above 100 Hz = ", Melder_single (ERB (quantile84)), U" ERB"); MelderInfo_write (U" 90% = ", Melder_single (quantile90), U" Hz = ", Melder_single (MEL (quantile90)), U" Mel = "); MelderInfo_writeLine (Melder_single (SEMITONES (quantile90)), U" semitones above 100 Hz = ", Melder_single (ERB (quantile90)), U" ERB"); if (nVoiced > 1) { double corr = sqrt (nVoiced / (nVoiced - 1.0)); MelderInfo_writeLine (U"\nEstimated spreading:"); MelderInfo_write (U" 84%-median = ", Melder_half ((quantile84 - quantile50) * corr), U" Hz = ", Melder_half ((MEL (quantile84) - MEL (quantile50)) * corr), U" Mel = "); MelderInfo_writeLine (Melder_half ((SEMITONES (quantile84) - SEMITONES (quantile50)) * corr), U" semitones = ", Melder_half ((ERB (quantile84) - ERB (quantile50)) * corr), U" ERB"); MelderInfo_write (U" median-16% = ", Melder_half ((quantile50 - quantile16) * corr), U" Hz = ", Melder_half ((MEL (quantile50) - MEL (quantile16)) * corr), U" Mel = "); MelderInfo_writeLine (Melder_half ((SEMITONES (quantile50) - SEMITONES (quantile16)) * corr), U" semitones = ", Melder_half ((ERB (quantile50) - ERB (quantile16)) * corr), U" ERB"); MelderInfo_write (U" 90%-10% = ", Melder_half ((quantile90 - quantile10) * corr), U" Hz = ", Melder_half ((MEL (quantile90) - MEL (quantile10)) * corr), U" Mel = "); MelderInfo_writeLine (Melder_half ((SEMITONES (quantile90) - SEMITONES (quantile10)) * corr), U" semitones = ", Melder_half ((ERB (quantile90) - ERB (quantile10)) * corr), U" ERB"); } } if (nVoiced >= 1) { // extrema, range, mean and standard deviation double minimum = Pitch_getMinimum (this, xmin, xmax, kPitch_unit_HERTZ, false); double maximum = Pitch_getMaximum (this, xmin, xmax, kPitch_unit_HERTZ, false); double meanHertz, meanMel, meanSemitones, meanErb; MelderInfo_write (U"\nMinimum ", Melder_single (minimum), U" Hz = ", Melder_single (MEL (minimum)), U" Mel = "); MelderInfo_writeLine (Melder_single (SEMITONES (minimum)), U" semitones above 100 Hz = ", Melder_single (ERB (minimum)), U" ERB"); MelderInfo_write (U"Maximum ", Melder_single (maximum), U" Hz = ", Melder_single (MEL (maximum)), U" Mel = "); MelderInfo_writeLine (Melder_single (SEMITONES (maximum)), U" semitones above 100 Hz = ", Melder_single (ERB (maximum)), U" ERB"); MelderInfo_write (U"Range ", Melder_half (maximum - minimum), U" Hz = ", Melder_single (MEL (maximum) - MEL (minimum)), U" Mel = "); MelderInfo_writeLine (Melder_half (SEMITONES (maximum) - SEMITONES (minimum)), U" semitones = ", Melder_half (ERB (maximum) - ERB (minimum)), U" ERB"); meanHertz = Pitch_getMean (this, 0, 0, kPitch_unit_HERTZ); meanMel = Pitch_getMean (this, 0, 0, kPitch_unit_MEL); meanSemitones = Pitch_getMean (this, 0, 0, kPitch_unit_SEMITONES_100); meanErb = Pitch_getMean (this, 0, 0, kPitch_unit_ERB); MelderInfo_write (U"Average: ", Melder_single (meanHertz), U" Hz = ", Melder_single (meanMel), U" Mel = "); MelderInfo_writeLine (Melder_single (meanSemitones), U" semitones above 100 Hz = ", Melder_single (meanErb), U" ERB"); if (nVoiced >= 2) { double stdevHertz = Pitch_getStandardDeviation (this, 0, 0, kPitch_unit_HERTZ); double stdevMel = Pitch_getStandardDeviation (this, 0, 0, kPitch_unit_MEL); double stdevSemitones = Pitch_getStandardDeviation (this, 0, 0, kPitch_unit_SEMITONES_100); double stdevErb = Pitch_getStandardDeviation (this, 0, 0, kPitch_unit_ERB); MelderInfo_write (U"Standard deviation: ", Melder_half (stdevHertz), U" Hz = ", Melder_half (stdevMel), U" Mel = "); MelderInfo_writeLine (Melder_half (stdevSemitones), U" semitones = ", Melder_half (stdevErb), U" ERB"); } } if (nVoiced > 1) { // variability: mean absolute slope double slopeHertz, slopeMel, slopeSemitones, slopeErb, slopeWithoutOctaveJumps; Pitch_getMeanAbsoluteSlope (this, & slopeHertz, & slopeMel, & slopeSemitones, & slopeErb, & slopeWithoutOctaveJumps); MelderInfo_write (U"\nMean absolute slope: ", Melder_half (slopeHertz), U" Hz/s = ", Melder_half (slopeMel), U" Mel/s = "); MelderInfo_writeLine (Melder_half (slopeSemitones), U" semitones/s = ", Melder_half (slopeErb), U" ERB/s"); MelderInfo_writeLine (U"Mean absolute slope without octave jumps: ", Melder_half (slopeWithoutOctaveJumps), U" semitones/s"); } }
void structDistributions :: v_info () { structDaata :: v_info (); MelderInfo_writeLine (U"Number of distributions: ", numberOfColumns); MelderInfo_writeLine (U"Number of values: ", numberOfRows); }
int Praat_tests (int itest, char32 *arg1, char32 *arg2, char32 *arg3, char32 *arg4) { int64 n = Melder_atoi (arg1); double t = 0.0; (void) arg1; (void) arg2; (void) arg3; (void) arg4; Melder_clearInfo (); Melder_stopwatch (); switch (itest) { case kPraatTests_TIME_RANDOM_FRACTION: { for (int64 i = 1; i <= n; i ++) (void) NUMrandomFraction (); t = Melder_stopwatch (); } break; case kPraatTests_TIME_RANDOM_GAUSS: { for (int64 i = 1; i <= n; i ++) (void) NUMrandomGauss (0.0, 1.0); t = Melder_stopwatch (); } break; case kPraatTests_TIME_SORT: { long m = Melder_atoi (arg2); long *array = NUMvector <long> (1, m); for (int64 i = 1; i <= m; i ++) array [i] = NUMrandomInteger (1, 100); Melder_stopwatch (); for (int64 i = 1; i <= n; i ++) NUMsort_l (m, array); t = Melder_stopwatch (); NUMvector_free (array, 1); } break; case kPraatTests_TIME_INTEGER: { int64 sum = 0; for (int64 i = 1; i <= n; i ++) sum += i * (i - 1) * (i - 2); t = Melder_stopwatch (); MelderInfo_writeLine (sum); } break; case kPraatTests_TIME_FLOAT: { double sum = 0.0, fn = n; for (double fi = 1.0; fi <= fn; fi = fi + 1.0) sum += fi * (fi - 1.0) * (fi - 2.0); t = Melder_stopwatch (); MelderInfo_writeLine (sum); } break; case kPraatTests_TIME_FLOAT_TO_UNSIGNED_BUILTIN: { uint64_t sum = 0; double fn = n; for (double fi = 1.0; fi <= fn; fi = fi + 1.0) sum += (uint32) fi; t = Melder_stopwatch (); // 2.59 // 1.60 MelderInfo_writeLine (sum); } break; case kPraatTests_TIME_FLOAT_TO_UNSIGNED_EXTERN: { uint64_t sum = 0; double fn = n; for (double fi = 1.0; fi <= fn; fi = fi + 1.0) sum += (uint32) ((int32) (fi - 2147483648.0) + 2147483647L + 1); t = Melder_stopwatch (); // 1.60 MelderInfo_writeLine (sum); } break; case kPraatTests_TIME_UNSIGNED_TO_FLOAT_BUILTIN: { double sum = 0.0; uint32 nu = (uint32) n; for (uint32 iu = 1; iu <= nu; iu ++) sum += (double) iu; t = Melder_stopwatch (); // 1.35 MelderInfo_writeLine (sum); } break; case kPraatTests_TIME_UNSIGNED_TO_FLOAT_EXTERN: { double sum = 0.0; uint32 nu = (uint32) n; for (uint32 iu = 1; iu <= nu; iu ++) sum += (double) (int32) (iu - 2147483647L - 1) + 2147483648.0; t = Melder_stopwatch (); // 0.96 MelderInfo_writeLine (sum); } break; case kPraatTests_TIME_STRING_MELDER_32: { autoMelderString string; char32 word [] { U"abc" }; word [2] = NUMrandomInteger ('a', 'z'); for (int64 i = 1; i <= n; i ++) { MelderString_copy (& string, word); for (int j = 1; j <= 30; j ++) MelderString_append (& string, word); } t = Melder_stopwatch (); } break; case kPraatTests_TIME_STRING_MELDER_32_ALLOC: { char32 word [] { U"abc" }; word [2] = NUMrandomInteger ('a', 'z'); for (int64 i = 1; i <= n; i ++) { autoMelderString string; MelderString_copy (& string, word); for (int j = 1; j <= 30; j ++) MelderString_append (& string, word); } t = Melder_stopwatch (); } break; case kPraatTests_TIME_STRING_CPP_S: { std::string s = ""; char word [] { "abc" }; word [2] = (char) NUMrandomInteger ('a', 'z'); for (int64 i = 1; i <= n; i ++) { s = word; for (int j = 1; j <= 30; j ++) s += word; } t = Melder_stopwatch (); } break; case kPraatTests_TIME_STRING_CPP_C: { std::basic_string<char> s = ""; char word [] { "abc" }; word [2] = (char) NUMrandomInteger ('a', 'z'); for (int64 i = 1; i <= n; i ++) { s = word; for (int j = 1; j <= 30; j ++) s += word; } t = Melder_stopwatch (); } break; case kPraatTests_TIME_STRING_CPP_WS: { std::wstring s = L""; wchar_t word [] { L"abc" }; word [2] = NUMrandomInteger ('a', 'z'); for (int64 i = 1; i <= n; i ++) { s = word; for (int j = 1; j <= 30; j ++) s += word; } t = Melder_stopwatch (); } break; case kPraatTests_TIME_STRING_CPP_WC: { std::basic_string<wchar_t> s = L""; wchar_t word [] { L"abc" }; word [2] = NUMrandomInteger ('a', 'z'); for (int64 i = 1; i <= n; i ++) { s = word; for (int j = 1; j <= 30; j ++) s += word; } t = Melder_stopwatch (); } break; case kPraatTests_TIME_STRING_CPP_32: { std::basic_string<char32_t> s = U""; char32 word [] { U"abc" }; word [2] = NUMrandomInteger ('a', 'z'); for (int64 i = 1; i <= n; i ++) { s = word; for (int j = 1; j <= 30; j ++) s += word; } t = Melder_stopwatch (); } break; case kPraatTests_TIME_STRING_CPP_U32STRING: { std::u32string s = U""; char32 word [] { U"abc" }; word [2] = NUMrandomInteger ('a', 'z'); for (int64 i = 1; i <= n; i ++) { s = word; for (int j = 1; j <= 30; j ++) s += word; } t = Melder_stopwatch (); } break; case kPraatTests_TIME_STRCPY: { char buffer [100]; char word [] { "abc" }; word [2] = (char) NUMrandomInteger ('a', 'z'); for (int64 i = 1; i <= n; i ++) { strcpy (buffer, word); for (int j = 1; j <= 30; j ++) strcpy (buffer + strlen (buffer), word); } t = Melder_stopwatch (); MelderInfo_writeLine (Melder_peek8to32 (buffer)); } break; case kPraatTests_TIME_WCSCPY: { wchar_t buffer [100]; wchar_t word [] { L"abc" }; word [2] = NUMrandomInteger ('a', 'z'); for (int64 i = 1; i <= n; i ++) { wcscpy (buffer, word); for (int j = 1; j <= 30; j ++) wcscpy (buffer + wcslen (buffer), word); } t = Melder_stopwatch (); } break; case kPraatTests_TIME_STR32CPY: { char32 buffer [100]; char32 word [] { U"abc" }; word [2] = NUMrandomInteger ('a', 'z'); for (int64 i = 1; i <= n; i ++) { str32cpy (buffer, word); for (int j = 1; j <= 30; j ++) str32cpy (buffer + str32len (buffer), word); } t = Melder_stopwatch (); MelderInfo_writeLine (buffer); } break; case kPraatTests_TIME_GRAPHICS_TEXT_TOP: { autoPraatPicture picture; for (int64 i = 1; i <= n; i ++) { Graphics_textTop (GRAPHICS, false, U"hello world"); } t = Melder_stopwatch (); } break; case kPraatTests_THING_AUTO: { int numberOfThingsBefore = theTotalNumberOfThings; { Melder_casual (U"1\n"); autoDaata data = Thing_new (Daata); Thing_setName (data.get(), U"hello"); Melder_casual (U"2\n"); testData (data.get()); testAutoData (data.move()); autoDaata data18 = Thing_new (Daata); testAutoData (data18.move()); fprintf (stderr, "3\n"); autoDaata data2 = newAutoData (); fprintf (stderr, "4\n"); autoDaata data3 = newAutoData (); fprintf (stderr, "5\n"); //data2 = data; // disabled l-value copy assignment from same class fprintf (stderr, "6\n"); autoOrdered ordered = Thing_new (Ordered); fprintf (stderr, "7\n"); //data = ordered; // disabled l-value copy assignment from subclass data = ordered.move(); //ordered = data; // disabled l-value copy assignment from superclass //ordered = data.move(); // assignment from superclass to subclass is rightfully refused by compiler fprintf (stderr, "8\n"); data2 = newAutoData (); fprintf (stderr, "8a\n"); autoDaata data5 = newAutoData (); fprintf (stderr, "8b\n"); data2 = data5.move(); fprintf (stderr, "9\n"); //ordered = data; // rightfully refused by compiler fprintf (stderr, "10\n"); //autoOrdered ordered2 = Thing_new (Daata); // rightfully refused by compiler fprintf (stderr, "11\n"); autoDaata data4 = Thing_new (Ordered); // constructor fprintf (stderr, "12\n"); //autoDaata data6 = data4; // disabled l-value copy constructor from same class fprintf (stderr, "13\n"); autoDaata data7 = data4.move(); fprintf (stderr, "14\n"); autoOrdered ordered3 = Thing_new (Ordered); autoDaata data8 = ordered3.move(); fprintf (stderr, "15\n"); //autoDaata data9 = ordered; // disabled l-value copy constructor from subclass fprintf (stderr, "16\n"); autoDaata data10 = data7.move(); fprintf (stderr, "17\n"); autoDaata data11 = Thing_new (Daata); // constructor, move assignment, null destructor fprintf (stderr, "18\n"); data11 = Thing_new (Ordered); fprintf (stderr, "19\n"); testAutoDataRef (data11); fprintf (stderr, "20\n"); //data11 = nullptr; // disabled implicit assignment of pointer to autopointer fprintf (stderr, "21\n"); } int numberOfThingsAfter = theTotalNumberOfThings; fprintf (stderr, "Number of things: before %d, after %d\n", numberOfThingsBefore, numberOfThingsAfter); #if 1 MelderCallback<void,structDaata>::FunctionType f; typedef void (*DataFunc) (Daata); typedef void (*OrderedFunc) (Ordered); DataFunc dataFun; OrderedFunc orderedFun; MelderCallback<void,structDaata> dataFun2 (dataFun); MelderCallback<void,structOrdered> orderedFun2 (orderedFun); MelderCallback<void,structDaata> dataFun3 (orderedFun); //MelderCallback<void,structOrdered> orderedFun3 (dataFun); // rightfully refused by compiler autoDaata data = Thing_new (Daata); dataFun3 (data.get()); #endif } break; } MelderInfo_writeLine (Melder_single (t / n * 1e9), U" nanoseconds"); MelderInfo_close (); return 1; }
void structPermutation :: v_info () { structData :: v_info (); MelderInfo_writeLine (L"Number of elements: ", Melder_integer (numberOfElements)); }
void structEditDistanceTable :: v_info () { EditDistanceTable_Parent :: v_info (); MelderInfo_writeLine (U"Target:", numberOfRows, U" symbols."); MelderInfo_writeLine (U"Source:", numberOfColumns, U" symbols."); }
int Praat_tests (int itest, char32 *arg1, char32 *arg2, char32 *arg3, char32 *arg4) { int64 n = Melder_atoi (arg1); double t; (void) arg1; (void) arg2; (void) arg3; (void) arg4; Melder_clearInfo (); Melder_stopwatch (); switch (itest) { case kPraatTests_TIME_RANDOM_FRACTION: { for (int64 i = 1; i <= n; i ++) (void) NUMrandomFraction (); t = Melder_stopwatch (); } break; case kPraatTests_TIME_RANDOM_GAUSS: { for (int64 i = 1; i <= n; i ++) (void) NUMrandomGauss (0.0, 1.0); t = Melder_stopwatch (); } break; case kPraatTests_TIME_SORT: { long m = Melder_atoi (arg2); long *array = NUMvector <long> (1, m); for (int64 i = 1; i <= m; i ++) array [i] = NUMrandomInteger (1, 100); Melder_stopwatch (); for (int64 i = 1; i <= n; i ++) NUMsort_l (m, array); t = Melder_stopwatch (); NUMvector_free (array, 1); } break; case kPraatTests_TIME_INTEGER: { double sum = 0; for (int64 i = 1; i <= n; i ++) sum += i * (i - 1) * (i - 2); t = Melder_stopwatch (); MelderInfo_writeLine (sum); } break; case kPraatTests_TIME_FLOAT: { double sum = 0.0, fn = n; for (double fi = 1.0; fi <= fn; fi = fi + 1.0) sum += fi * (fi - 1.0) * (fi - 2.0); t = Melder_stopwatch (); MelderInfo_writeLine (sum); } break; case kPraatTests_TIME_FLOAT_TO_UNSIGNED_BUILTIN: { uint64_t sum = 0; double fn = n; for (double fi = 1.0; fi <= fn; fi = fi + 1.0) sum += (uint32_t) fi; t = Melder_stopwatch (); // 2.59 // 1.60 MelderInfo_writeLine (sum); } break; case kPraatTests_TIME_FLOAT_TO_UNSIGNED_EXTERN: { uint64_t sum = 0; double fn = n; for (double fi = 1.0; fi <= fn; fi = fi + 1.0) sum += (uint32_t) ((int32_t) (fi - 2147483648.0) + 2147483647L + 1); t = Melder_stopwatch (); // 1.60 MelderInfo_writeLine (sum); } break; case kPraatTests_TIME_UNSIGNED_TO_FLOAT_BUILTIN: { double sum = 0.0; uint32_t nu = (uint32_t) n; for (uint32_t iu = 1; iu <= nu; iu ++) sum += (double) iu; t = Melder_stopwatch (); // 1.35 MelderInfo_writeLine (sum); } break; case kPraatTests_TIME_UNSIGNED_TO_FLOAT_EXTERN: { double sum = 0.0; uint32_t nu = (uint32_t) n; for (uint32_t iu = 1; iu <= nu; iu ++) sum += (double) (int32_t) (iu - 2147483647L - 1) + 2147483648.0; t = Melder_stopwatch (); // 0.96 MelderInfo_writeLine (sum); } break; case kPraatTests_TIME_STRING_MELDER_32: { autoMelderString string; char32 word [] { U"abc" }; word [2] = NUMrandomInteger ('a', 'z'); for (int64 i = 1; i <= n; i ++) { MelderString_copy (& string, word); for (int j = 1; j <= 30; j ++) MelderString_append (& string, word); } t = Melder_stopwatch (); } break; case kPraatTests_TIME_STRING_CPP_S: { std::string s = ""; char word [] { "abc" }; word [2] = (char) NUMrandomInteger ('a', 'z'); for (int64 i = 1; i <= n; i ++) { s = word; for (int j = 1; j <= 30; j ++) s += word; } t = Melder_stopwatch (); } break; case kPraatTests_TIME_STRING_CPP_C: { std::basic_string<char> s = ""; char word [] { "abc" }; word [2] = (char) NUMrandomInteger ('a', 'z'); for (int64 i = 1; i <= n; i ++) { s = word; for (int j = 1; j <= 30; j ++) s += word; } t = Melder_stopwatch (); } break; case kPraatTests_TIME_STRING_CPP_WS: { std::wstring s = L""; wchar_t word [] { L"abc" }; word [2] = NUMrandomInteger ('a', 'z'); for (int64 i = 1; i <= n; i ++) { s = word; for (int j = 1; j <= 30; j ++) s += word; } t = Melder_stopwatch (); } break; case kPraatTests_TIME_STRING_CPP_WC: { std::basic_string<wchar_t> s = L""; wchar_t word [] { L"abc" }; word [2] = NUMrandomInteger ('a', 'z'); for (int64 i = 1; i <= n; i ++) { s = word; for (int j = 1; j <= 30; j ++) s += word; } t = Melder_stopwatch (); } break; case kPraatTests_TIME_STRING_CPP_32: { std::basic_string<char32_t> s = U""; char32 word [] { U"abc" }; word [2] = NUMrandomInteger ('a', 'z'); for (int64 i = 1; i <= n; i ++) { s = word; for (int j = 1; j <= 30; j ++) s += word; } t = Melder_stopwatch (); } break; case kPraatTests_TIME_STRING_CPP_U32STRING: { #if ! defined (macintosh) || ! useCarbon std::u32string s = U""; char32 word [] { U"abc" }; word [2] = NUMrandomInteger ('a', 'z'); for (int64 i = 1; i <= n; i ++) { s = word; for (int j = 1; j <= 30; j ++) s += word; } #endif t = Melder_stopwatch (); } break; case kPraatTests_TIME_STRCPY: { char buffer [100]; char word [] { "abc" }; word [2] = (char) NUMrandomInteger ('a', 'z'); for (int64 i = 1; i <= n; i ++) { strcpy (buffer, word); for (int j = 1; j <= 30; j ++) strcpy (buffer + strlen (buffer), word); } t = Melder_stopwatch (); MelderInfo_writeLine (Melder_peek8to32 (buffer)); } break; case kPraatTests_TIME_WCSCPY: { wchar_t buffer [100]; wchar_t word [] { L"abc" }; word [2] = NUMrandomInteger ('a', 'z'); for (int64 i = 1; i <= n; i ++) { wcscpy (buffer, word); for (int j = 1; j <= 30; j ++) wcscpy (buffer + wcslen (buffer), word); } t = Melder_stopwatch (); } break; case kPraatTests_TIME_STR32CPY: { char32 buffer [100]; char32 word [] { U"abc" }; word [2] = NUMrandomInteger ('a', 'z'); for (int64 i = 1; i <= n; i ++) { str32cpy (buffer, word); for (int j = 1; j <= 30; j ++) str32cpy (buffer + str32len (buffer), word); } t = Melder_stopwatch (); MelderInfo_writeLine (buffer); } break; case kPraatTests_TIME_GRAPHICS_TEXT_TOP: { autoPraatPicture picture; for (int64 i = 1; i <= n; i ++) { Graphics_textTop (GRAPHICS, false, U"hello world"); } t = Melder_stopwatch (); } break; } MelderInfo_writeLine (Melder_single (t / n * 1e9), U" nanoseconds"); MelderInfo_close (); return 1; }
void structPairDistribution :: v_info () { PairDistribution_Parent :: v_info (); MelderInfo_writeLine (U"Number of pairs: ", pairs -> size); }