Exemplo n.º 1
0
double Ltas_getLocalPeakHeight (Ltas me, double environmentMin, double environmentMax, double peakMin, double peakMax, int averagingUnits) {
	double environmentLow = Sampled_getMean (me, environmentMin, peakMin, 0, averagingUnits, FALSE);
	double environmentHigh = Sampled_getMean (me, peakMax, environmentMax, 0, averagingUnits, FALSE);
	double peak = Sampled_getMean (me, peakMin, peakMax, 0, averagingUnits, FALSE);
	if (environmentLow == NUMundefined || environmentHigh == NUMundefined || peak == NUMundefined) return NUMundefined;
	return averagingUnits == 3 ? peak - 0.5 * (environmentLow + environmentHigh) :
		ClassFunction_convertSpecialToStandardUnit (classLtas, peak / (0.5 * (environmentLow + environmentHigh)), 0, averagingUnits);
}
Exemplo n.º 2
0
void structLtas :: v_info () {
	double meanPowerDensity;
	structData :: v_info ();
	MelderInfo_writeLine1 (L"Frequency domain:");
	MelderInfo_writeLine3 (L"   Lowest frequency: ", Melder_double (xmin), L" Hz");
	MelderInfo_writeLine3 (L"   Highest frequency: ", Melder_double (xmax), L" Hz");
	MelderInfo_writeLine3 (L"   Total frequency domain: ", Melder_double (xmax - xmin), L" Hz");
	MelderInfo_writeLine1 (L"Frequency sampling:");
	MelderInfo_writeLine2 (L"   Number of frequency bands: ", Melder_integer (nx));
	MelderInfo_writeLine3 (L"   Width of each band: ", Melder_double (dx), L" Hz");
	MelderInfo_writeLine3 (L"   First band centred at: ", Melder_double (x1), L" Hz");
	meanPowerDensity = Sampled_getMean (this, xmin, xmax, 0, 1, FALSE);
	MelderInfo_writeLine3 (L"Total SPL: ", Melder_single (10.0 * log10 (meanPowerDensity * (xmax - xmin))), L" dB");
}
Exemplo n.º 3
0
void structLtas :: v_info () {
	double meanPowerDensity;
	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 frequency domain: ", xmax - xmin, U" Hz");
	MelderInfo_writeLine (U"Frequency sampling:");
	MelderInfo_writeLine (U"   Number of frequency bands: ", nx);
	MelderInfo_writeLine (U"   Width of each band: ", dx, U" Hz");
	MelderInfo_writeLine (U"   First band centred at: ", x1, U" Hz");
	meanPowerDensity = Sampled_getMean (this, xmin, xmax, 0, 1, false);
	MelderInfo_writeLine (U"Total SPL: ", Melder_single (10.0 * log10 (meanPowerDensity * (xmax - xmin))), U" dB");
}
Exemplo n.º 4
0
static void info (I) {
	iam (Ltas);
	double meanPowerDensity;
	classData -> info (me);
	MelderInfo_writeLine1 (L"Frequency domain:");
	MelderInfo_writeLine3 (L"   Lowest frequency: ", Melder_double (my xmin), L" Hz");
	MelderInfo_writeLine3 (L"   Highest frequency: ", Melder_double (my xmax), L" Hz");
	MelderInfo_writeLine3 (L"   Total frequency domain: ", Melder_double (my xmax - my xmin), L" Hz");
	MelderInfo_writeLine1 (L"Frequency sampling:");
	MelderInfo_writeLine2 (L"   Number of frequency bands: ", Melder_integer (my nx));
	MelderInfo_writeLine3 (L"   Width of each band: ", Melder_double (my dx), L" Hz");
	MelderInfo_writeLine3 (L"   First band centred at: ", Melder_double (my x1), L" Hz");
	meanPowerDensity = Sampled_getMean (me, my xmin, my xmax, 0, 1, FALSE);
	MelderInfo_writeLine3 (L"Total SPL: ", Melder_single (10 * log10 (meanPowerDensity * (my xmax - my xmin))), L" dB");
}
Exemplo n.º 5
0
Ltas Spectrum_to_Ltas (Spectrum me, double bandWidth) {
	Ltas thee = NULL;
	long numberOfBands = ceil ((my xmax - my xmin) / bandWidth), iband;
	if (bandWidth <= my dx) error3 (L"Bandwidth must be greater than ", Melder_double (my dx), L".")
	thee = Thing_new (Ltas); cherror
	Matrix_init (thee, my xmin, my xmax, numberOfBands, bandWidth, my xmin + 0.5 * bandWidth, 1, 1, 1, 1, 1); cherror
	for (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 * log10 (meanPowerDensity / 4.0e-10);
	}
end:
	iferror forget (thee);
	return thee;
}
Exemplo n.º 6
0
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.");
	}
}
Exemplo n.º 7
0
double Ltas_getSlope (Ltas me, double f1min, double f1max, double f2min, double f2max, int averagingUnits) {
	double low = Sampled_getMean (me, f1min, f1max, 0, averagingUnits, FALSE);
	double high = Sampled_getMean (me, f2min, f2max, 0, averagingUnits, FALSE);
	if (low == NUMundefined || high == NUMundefined) return NUMundefined;
	return averagingUnits == 3 ? high - low : ClassFunction_convertSpecialToStandardUnit (classLtas, high / low, 0, averagingUnits);
}
Exemplo n.º 8
0
double Pitch_getMeanStrength (Pitch me, double tmin, double tmax, int unit) {
	return Sampled_getMean (me, tmin, tmax, Pitch_LEVEL_STRENGTH, unit, true);
}
Exemplo n.º 9
0
double Pitch_getMean (Pitch me, double tmin, double tmax, int unit) {
	return Sampled_getMean (me, tmin, tmax, Pitch_LEVEL_FREQUENCY, unit, true);
}
Exemplo n.º 10
0
double Spectrum_getBandDensity (Spectrum me, double fmin, double fmax) {
	if (my xmin < 0.0) return NUMundefined;   /* No negative frequencies allowed in one-sided spectral density. */
	return Sampled_getMean (me, fmin, fmax, 0, 1, FALSE);
}
Exemplo n.º 11
0
double Formant_getMean (Formant me, int iformant, double tmin, double tmax, int bark) {
	return Sampled_getMean (me, tmin, tmax, iformant << 1, bark, TRUE);
}
Exemplo n.º 12
0
double Vector_getMean (Vector me, double xmin, double xmax, long channel) {
	return Sampled_getMean (me, xmin, xmax, channel, 0, TRUE);
}
double Sampled_getMean_standardUnit (Sampled me, double xmin, double xmax, long ilevel, int averagingUnit, int interpolate) {
	return Function_convertSpecialToStandardUnit (me, Sampled_getMean (me, xmin, xmax, ilevel, averagingUnit, interpolate), ilevel, averagingUnit);
}
Exemplo n.º 14
0
double Sampled_getMean_standardUnit (I, double xmin, double xmax, long ilevel, int averagingUnit, int interpolate) {
	iam (Sampled);
	return ClassFunction_convertSpecialToStandardUnit (my methods, Sampled_getMean (me, xmin, xmax, ilevel, averagingUnit, interpolate), ilevel, averagingUnit);
}