Commit 35380a8f authored by Rafael Laboissière's avatar Rafael Laboissière
Browse files

New upstream version 6.1.05

parent c019ac80
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@

autoSpectrogram LPC_to_Spectrogram (LPC me, double dfMin, double bandwidthReduction, double deEmphasisFrequency) {
	try {
		double samplingFrequency = 1.0 / my samplingPeriod;
		const double samplingFrequency = 1.0 / my samplingPeriod;
		integer nfft = 2;
		if (dfMin <= 0.0) {
			nfft = 512; 
@@ -33,15 +33,15 @@ autoSpectrogram LPC_to_Spectrogram (LPC me, double dfMin, double bandwidthReduct
		}
		while (samplingFrequency / nfft > dfMin || nfft <= my maxnCoefficients)
			nfft *= 2;
		double freqStep = samplingFrequency / nfft;
		const double freqStep = samplingFrequency / nfft;

		autoSpectrogram thee = Spectrogram_create (my xmin, my xmax, my nx, my dx, my x1, 0.0, samplingFrequency / 2.0, nfft / 2 + 1, freqStep, 0.0);

		for (integer i = 1; i <= my nx; i ++) {
			double t = Sampled_indexToX (me, i);
			const double t = Sampled_indexToX (me, i);
			autoSpectrum spec = LPC_to_Spectrum (me, t, dfMin, bandwidthReduction, deEmphasisFrequency);
			for (integer j = 1; j <= spec -> nx; j ++) {
				double re = spec -> z [1] [j], im = spec -> z [2] [j];
				const double re = spec -> z [1] [j], im = spec -> z [2] [j];
				thy z [j] [i] = re * re + im * im;
			}
		}
+128 −10
Original line number Diff line number Diff line
@@ -96,7 +96,9 @@ MAN_END
#define PowerCepstrum_manual_trendRange \
	U"the quefrency range for which the amplitudes (in dB) will be modelled by a straight line. " \
	"The lower value for this range in the @@Hillenbrand et al. (1994)@ article was chosen as 0.001 s " \
	"in order to reduce the effect of very low quefrency data on the straight line fit. In our analysis this value is not so critical as we use a more robust fitting procedure."
	"in order to reduce the effect of very low quefrency data on the straight line fit. In our analysis this value " \
	"is not so critical if we use the robust fitting procedure. If you choose the \"Least squares\" fit method " \
	"then it matters more."

#define PowerCepstrum_manual_trendType \
	U"defines how to model the cepstrum background. We can model it with a straight line as was " \
@@ -152,17 +154,17 @@ TAG (U"##Fit method#")
DEFINITION (PowerCepstrum_manual_fitMethod)
MAN_END

MAN_BEGIN (U"PowerCepstrogram: To Table (peak prominence)...", U"djmw", 20190910)
MAN_BEGIN (U"PowerCepstrogram: To Table (peak prominence)...", U"djmw", 20191008)
INTRO (U"A command to create a table with @@PowerCepstrum: Get peak prominence...|cepstral peak prominence@ values.")
ENTRY (U"Settings")
SCRIPT (5, Manual_SETTINGS_WINDOW_HEIGHT (7), U""
	Manual_DRAW_SETTINGS_WINDOW ("PowerCepstrogram: To Table (peak prominence)", 7)
	Manual_DRAW_SETTINGS_WINDOW_RANGE("Peak search pitch range (Hz)", U"60.0", U"300.0")
	Manual_DRAW_SETTINGS_WINDOW_RADIO (U"Interpolation", U"None", 0)
	Manual_DRAW_SETTINGS_WINDOW_RADIO (U"", U"Parabolic", 0)
	Manual_DRAW_SETTINGS_WINDOW_RADIO (U"", U"Cubic", 1)
	Manual_DRAW_SETTINGS_WINDOW_RADIO (U"", U"Parabolic", 1)
	Manual_DRAW_SETTINGS_WINDOW_RADIO (U"", U"Cubic", 0)
	Manual_DRAW_SETTINGS_WINDOW_RADIO (U"", U"Sinc70", 0)
	Manual_DRAW_SETTINGS_WINDOW_RANGE("Trend line quefrency range (s)", U"0.001", U"0.0 (= end)")
	Manual_DRAW_SETTINGS_WINDOW_RANGE("Trend line quefrency range (s)", U"0.001", U"0.05")
	Manual_DRAW_SETTINGS_WINDOW_OPTIONMENU(U"Trend type", U"Exponential decay")
	Manual_DRAW_SETTINGS_WINDOW_OPTIONMENU(U"Fit method", U"Robust")
)
@@ -260,8 +262,50 @@ TAG (U"##Trend type#")
DEFINITION (PowerCepstrum_manual_trendType)
TAG (U"##Fit method")
DEFINITION (PowerCepstrum_manual_fitMethod)
ENTRY (U"Note")
NORMAL (U"The CPP value does not depend on the reference value used in the dB calculation of the power cepstrum.")
ENTRY (U"Examples")
NORMAL (U"Next picture of a PowerCepstrum with its straight blue trend line and its corresponding "
	"peak prominence value was generated with the following script. Note that the first four lines in the "
	"script are only necessary to generate a PowerCepstrum of a part of a vowel. ")
CODE (U"Create KlattGrid from vowel: \"a\", 0.3, 125, 800, 80, 1200, 80, 2300, 100, 2800, 0.1, 1000")
CODE (U"To Sound")
CODE (U"To PowerCepstrogram: 60, 0.002, 5000, 50")
CODE (U"To PowerCepstrum (slice): 0.1")
CODE (U"prominence = Get peak prominence: 60, 333.3, \"Parabolic\", 0.001, 0.05, \"Straight\", \"Robust slow\"")
CODE (U"Text top: \"no\", \"Peak prominence = \" + fixed$ (prominence, 2) + \" dB\"")
CODE (U"Draw: 0, 0, 0, 110, \"yes\"")
CODE (U"Colour: \"Blue\"")
CODE (U"Draw trend line: 0, 0, 0, 110, 0.001, 0.05, \"Straight\", \"Robust slow\"")
CODE (U"Colour: \"Black\"")
CODE (U"Text top: \"no\", \"Peak prominence = \" + fixed$ (prominence, 2) + \" dB\"")
SCRIPT (5, 3, U""
	"kg = Create KlattGrid from vowel: \"a\", 0.3, 125, 800, 80, 1200, 80, 2300, 100, 2800, 0.1, 1000\n"
	"vowel = To Sound\n"
	"cepstrogram = To PowerCepstrogram: 60, 0.002, 5000, 50\n"
	"cepstrum = To PowerCepstrum (slice): 0.1\n"
	"prominence = Get peak prominence: 60, 333.3, \"Parabolic\", 0.001, 0.05, \"Straight\", \"Robust slow\"\n"
	"Text top: \"no\", \"Peak prominence = \" + fixed$ (prominence, 2) + \" dB\"\n"
	"Draw: 0, 0, 0, 110, \"yes\"\n"
	"Colour: \"Blue\"\n"
	"Draw trend line: 0, 0, 0, 110, 0.001, 0.05, \"Straight\", \"Robust slow\"\n"
	"Colour: \"Black\"\n"
	"Text top: \"no\", \"Peak prominence = \" + fixed$ (prominence, 2) + \" dB\"\n"
	"removeObject: kg, vowel, cepstrogram, cepstrum\n")
NORMAL (U"In the next picture the trend line is of exponential decay type and consequently the "
	"peak prominence value has changed a little bit.")
SCRIPT (5, 3, U""
	"kg = Create KlattGrid from vowel: \"a\", 0.3, 125, 800, 80, 1200, 80, 2300, 100, 2800, 0.1, 1000\n"
	"vowel = To Sound\n"
	"cepstrogram = To PowerCepstrogram: 60, 0.002, 5000, 50\n"
	"cepstrum = To PowerCepstrum (slice): 0.1\n"
	"prominence = Get peak prominence: 60, 333.3, \"Parabolic\", 0.001, 0.05, \"Exponential decay\", \"Robust slow\"\n"
	"Text top: \"no\", \"Peak prominence = \" + fixed$ (prominence, 2) + \" dB\"\n"
	"Draw: 0, 0, 0, 110, \"yes\"\n"
	"Colour: \"Blue\"\n"
	"Draw trend line: 0, 0, 0, 110, 0.001, 0.05, \"Exponential decay\", \"Robust slow\"\n"
	"Colour: \"Black\"\n"
	"Text top: \"no\", \"Peak prominence = \" + fixed$ (prominence, 2) + \" dB\"\n"
	"removeObject: kg, vowel, cepstrogram, cepstrum\n")

MAN_END

MAN_BEGIN (U"PowerCepstrum: Draw...", U"djmw", 20190914)
@@ -276,7 +320,7 @@ NORMAL (U"Cepstrum values are drawn as 20\\.clog10 (value +\\ep), "
	"where \\ep is a small number that avoids taking the logarithm of zero if the cepstrum value happens to be zero.")
MAN_END

MAN_BEGIN (U"PowerCepstrum: Draw trend line...", U"djmw", 20190909)
MAN_BEGIN (U"PowerCepstrum: Draw trend line...", U"djmw", 20191008)
INTRO (U"Draws the line that models the background of the selected @@PowerCepstrum@.")
ENTRY (U"Settings")
TAG (U"##Quefrency range (s)#")
@@ -289,6 +333,32 @@ TAG (U"##Trend type#")
DEFINITION (PowerCepstrum_manual_trendType)
TAG (U"##Fit method")
DEFINITION (PowerCepstrum_manual_fitMethod)
ENTRY (U"Examples")
NORMAL (U"The next picture shows a PowerCepstrum with %%two% drawn trend lines, a straight line in blue "
	"and an exponential decay line in green.  The picture was generated by the following script. "
	"Note that the first four lines in the script are only necessary to generate a PowerCepstrum of a part of a vowel.")
CODE (U"Create KlattGrid from vowel: \"a\", 0.3, 125, 800, 80, 1200, 80, 2300, 100, 2800, 0.1, 1000")
CODE (U"To Sound")
CODE (U"To PowerCepstrogram: 60, 0.002, 5000, 50")
CODE (U"To PowerCepstrum (slice): 0.1")
CODE (U"Draw: 0, 0, 0, 110, \"yes\"")
CODE (U"Colour: \"Blue\"")
CODE (U"Draw trend line: 0, 0, 0, 110, 0.001, 0.05, \"Straight\", \"Robust slow\"")
CODE (U"Colour: \"Green\"")
CODE (U"Draw trend line: 0, 0, 0, 110, 0.001, 0.05, \"Exponential decay\", \"Robust slow\"")
CODE (U"Colour: \"Black\"")
SCRIPT (5, 3, U""
	"kg = Create KlattGrid from vowel: \"a\", 0.3, 125, 800, 80, 1200, 80, 2300, 100, 2800, 0.1, 1000\n"
	"vowel = To Sound\n"
	"cepstrogram = To PowerCepstrogram: 60, 0.002, 5000, 50\n"
	"cepstrum = To PowerCepstrum (slice): 0.1\n"
	"Draw: 0, 0, 0, 110, \"yes\"\n"
	"Colour: \"Blue\"\n"
	"Draw trend line: 0, 0, 0, 110, 0.001, 0.05, \"Straight\", \"Robust slow\"\n"
	"Colour: \"Green\"\n"
	"Draw trend line: 0, 0, 0, 110, 0.001, 0.05, \"Exponential decay\", \"Robust slow\"\n"
	"Colour: \"Black\"\n"
	"removeObject: kg, vowel, cepstrogram, cepstrum\n")
MAN_END

MAN_BEGIN (U"PowerCepstrum: Get peak...", U"djmw", 20190910)
@@ -331,7 +401,7 @@ TAG (U"##Fit method")
DEFINITION (PowerCepstrum_manual_fitMethod)
MAN_END

MAN_BEGIN (U"PowerCepstrum: Smooth...", U"djmw", 20190914)
MAN_BEGIN (U"PowerCepstrum: Smooth...", U"djmw", 20191005)
INTRO (U"A command to smooth the selected @@PowerCepstrum@ by averaging values at successive quefrencies.")
ENTRY (U"Settings")
TAG (U"##Quefrency averaging window (s)#")
@@ -339,7 +409,46 @@ DEFINITION (PowerCepstrum_manual_quefrencyAveragingWindow)
TAG (U"##Number of iterations#")
DEFINITION (U"determines how often the averaging will take place. If chosen 2, for example, the output PowerCepstrum "
	"after the first averaging will be averaged once again.")

ENTRY (U"Examples")
NORMAL (U"The figure below is the PowerCepstrum taken from an artificial /a/ vowel synthesized as follows:")
CODE (U"Create KlattGrid from vowel: \"a\", 0.3, 125, 800, 80, 1200, 80, 2300, 100, 2800, 0.1, 1000")
CODE (U"To Sound")
CODE (U"To PowerCepstrogram: 60, 0.002, 5000, 50")
CODE (U"To PowerCepstrum (slice): 0.1")
CODE (U"prominence = Get peak prominence: 60, 333.3, \"Parabolic\", 0.001, 0.05, \"Straight\", \"Robust slow\"")
CODE (U"Draw: 0, 0, 0, 110, \"yes\"")
CODE (U"Text top: \"no\", \"Peak prominence = \" + fixed$ (prominence, 2) + \" dB\"")
SCRIPT (5, 3, U""
	"kg = Create KlattGrid from vowel: \"a\", 0.3, 125, 800, 80, 1200, 80, 2300, 100, 2800, 0.1, 1000\n"
	"vowel = To Sound\n"
	"cepstrogram = To PowerCepstrogram: 60, 0.002, 5000, 50\n"
	"cepstrum = To PowerCepstrum (slice): 0.3\n"
	"prominence = Get peak prominence: 60, 333.3, \"Parabolic\", 0.001, 0.05, \"Straight\", \"Robust slow\"\n"
	"Draw: 0, 0, 0, 110, \"yes\"\n"
	"Text top: \"no\", \"Peak prominence = \" + fixed$ (prominence, 2) + \" dB\"\n"
	"removeObject: kg, vowel, cepstrogram, cepstrum\n")
NORMAL (U"After 1 iteration with an averaging window of 0.0005 s the PowerCepstrum is:")
SCRIPT (5, 3, U""
	"kg = Create KlattGrid from vowel: \"a\", 0.3, 125, 800, 80, 1200, 80, 2300, 100, 2800, 0.1, 1000\n"
	"vowel = To Sound\n"
	"cepstrogram = To PowerCepstrogram: 60, 0.002, 5000, 50\n"
	"cepstrum = To PowerCepstrum (slice): 0.3\n"
	"smooth = Smooth: 0.0005, 1\n"
	"prominence = Get peak prominence: 60, 333.3, \"Parabolic\", 0.001, 0.05, \"Straight\", \"Robust slow\"\n"
	"Text top: \"no\", \"Peak prominence = \" + fixed$ (prominence, 2) + \" dB\"\n"
	"Draw: 0, 0, 0, 110, \"yes\"\n"
	"removeObject: kg, vowel, cepstrogram, cepstrum, smooth\n")
NORMAL (U"After 2 iterations with an averaging window of 0.0005 s the PowerCepstrum is:")
SCRIPT (5, 3, U""
	"kg = Create KlattGrid from vowel: \"a\", 0.3, 125, 800, 80, 1200, 80, 2300, 100, 2800, 0.1, 1000\n"
	"vowel = To Sound\n"
	"cepstrogram = To PowerCepstrogram: 60, 0.002, 5000, 50\n"
	"cepstrum = To PowerCepstrum (slice): 0.3\n"
	"smooth = Smooth: 0.0005, 2\n"
	"prominence = Get peak prominence: 60, 333.3, \"Parabolic\", 0.001, 0.05, \"Straight\", \"Robust slow\"\n"
	"Draw: 0, 0, 0, 110, \"yes\"\n"
	"Text top: \"no\", \"Peak prominence = \" + fixed$ (prominence, 2) + \" dB\"\n"
	"removeObject: kg, vowel, cepstrogram, cepstrum, smooth\n")
MAN_END

MAN_BEGIN (U"PowerCepstrum: Subtract trend...", U"djmw", 20190914)
@@ -799,6 +908,15 @@ NORMAL (U"N. Anderson (1978): \"On the calculation of filter coefficients for "
	"IEEE Press: 252\\--255.")
MAN_END

MAN_BEGIN (U"Fleisher et al. (2015)", U"djmw", 20191008)
NORMAL (U"M. Fleisher, S. Pinkert, W. Mattheus, A. Mainka & D. Mürbe (2015): \"Formant frequencies and bandwidths of the vocal transfer function are affected by the mechanical impedance of the vocal tract wall.\", %%Biomech Model Mechanobiol% #14: 719\\--733.")
MAN_END

MAN_BEGIN (U"Hawks & Miller (1995)", U"djmw", 20191008)
NORMAL (U"J. Hawks &  J. Miller (1995): \"A formant bandwidth estimation procedure for vowel synthesis.\", "
	"%%Journal of the Acoustical Society of America% #97: 1343\\--1344.")
MAN_END

MAN_BEGIN (U"Hillenbrand et al. (1994)", U"djmw", 20121017)
NORMAL (U"J. Hillenbrand, R.A. Cleveland & R.L. Erickson (1994): \"Acoustic correlates of breathy vocal quality\", %%Journal of speech and hearing research% #37: 769\\--778.")
MAN_END
+3 −3
Original line number Diff line number Diff line
@@ -156,8 +156,8 @@ FORM (REAL_PowerCepstrum_getQuefrencyOfPeak, U"PowerCepstrum: Get quefrency of p
DO
	NUMBER_ONE (PowerCepstrum)
		double result, quefrency;
		PowerCepstrum_getMaximumAndQuefrency (me, fromPitch, toPitch, interpolationMethod - 1, & quefrency, & result);
		double f = 1.0 / quefrency;
		PowerCepstrum_getMaximumAndQuefrency (me, fromPitch, toPitch, interpolationMethod - 1, nullptr, & result);
		double f = 1.0 / result;
	NUMBER_ONE_END (U" s (f =", f, U" Hz)")
}

@@ -406,7 +406,7 @@ FORM (REAL_PowerCepstrogram_getCPPS, U"PowerCepstrogram: Get CPPS", U"PowerCepst
		RADIOBUTTON (U"Sinc70")
	LABEL (U"Trend line:")
	REAL (fromQuefrency_trendLine, U"left Trend line quefrency range (s)", U"0.001")
	REAL (toQuefrency_trendLine, U"right Trend line quefrency range (s)", U"0.05)")
	REAL (toQuefrency_trendLine, U"right Trend line quefrency range (s)", U"0.05")
	OPTIONMENU_ENUM (kCepstrumTrendType, lineType, U"Trend type", kCepstrumTrendType::DEFAULT)
	OPTIONMENU_ENUM (kCepstrumTrendFit, fitMethod, U"Fit method", kCepstrumTrendFit::DEFAULT)
	OK

dwtest/KlattGrid_test.praat

deleted100644 → 0
+0 −314
Original line number Diff line number Diff line
# KlattGrid_test.praat
# djmw 20081208, 20090420, 20140113


printline ===========		KlattGrid test start

call test_get_add_remove_extract_replace_old_interface

call test_get_add_remove_replace

printline ===========		KlattGrid test end

procedure test_get_add_remove_replace
	numberOfOralFormants = 6
	numberOfNasalFormants = 1
	numberOfTrachealFormants = 1
	numberOfFricationFormants = 5
	numberOfNasalAntiFormants = 1
	numberOfTrachealAntiFormants = 1
	numberOfDeltaFormants = 1
	tmin = 0
	tmax = 1

	kg = Create KlattGrid... kg tmin tmax numberOfOralFormants numberOfNasalFormants numberOfNasalAntiFormants 
		... numberOfFricationFormants numberOfTrachealFormants numberOfTrachealAntiFormants numberOfDeltaFormants

	printline ===========		KlattGrid test_get_add_remove_extract_replace start
	for .itime to 20
		call setget_1 "pitch" 130
		call setget_1 "voicing amplitude" 90
		call setget_1 "flutter" 0.5
		call setget_1 "power1" 2
		call setget_1 "power2" 3
		call setget_1 "open phase" 0.5
		call setget_1 "collision phase" 0.035
		call setget_1 "double pulsing" 0.4
		call setget_1 "spectral tilt" 20
		call setget_1 "aspiration amplitude" 90
		call setget_1 "breathiness amplitude" 90

		call setget_1 "frication bypass" 20
		call setget_1 "frication amplitude" 50
	
		call setget_formants Oral
		call setget_formants Nasal
		call setget_formants Tracheal
		call setget_formants Delta
		call setget_formants Frication
		call setget_antiformants Nasal
		call setget_antiformants Tracheal

	endfor

	call test_deltaFormants

	removeObject (kg)

	printline ===========		KlattGrid test_get_add_remove_extract_replace succesful

endproc

procedure test_get_add_remove_extract_replace_old_interface
	numberOfOralFormants = 6
	numberOfNormalFormants = numberOfOralFormants
	numberOfNasalFormants = 1
	numberOfTrachealFormants = 1
	numberOfFricationFormants = 5
	numberOfNasalAntiFormants = 1
	numberOfTrachealAntiFormants = 1
	numberOfDeltaFormants = 1
	tmin = 0
	tmax = 1

	printline ===========		KlattGrid test_get_add_remove_extract_replace_old_interface start

	kg = Create KlattGrid... kg tmin tmax numberOfOralFormants numberOfNasalFormants numberOfNasalAntiFormants 
		... numberOfFricationFormants numberOfTrachealFormants numberOfTrachealAntiFormants numberOfDeltaFormants

	for .itime to 20
		call setget_1 "pitch" 130
		call setget_1 "voicing amplitude" 90
		call setget_1 "flutter" 0.5
		call setget_1 "power1" 2
		call setget_1 "power2" 3
		call setget_1 "open phase" 0.5
		call setget_1 "collision phase" 0.035
		call setget_1 "double pulsing" 0.4
		call setget_1 "spectral tilt" 20
		call setget_1 "aspiration amplitude" 90
		call setget_1 "breathiness amplitude" 90

		call setget_1 "frication bypass" 20
		call setget_1 "frication amplitude" 50
	
		call setget_formants_old Normal
		call setget_formants_old Nasal
		call setget_formants_old Tracheal
		call setget_formants_old Frication
		call setget_antiformants_old Nasal
		call setget_antiformants_old Tracheal

		call setget_deltaformants

	endfor

	call test_deltaFormants_old

	removeObject (kg)
	printline ===========		KlattGrid test_get_add_remove_extract_replace_old_interface succesful
endproc

procedure setget_1 .var$ .value
	selectObject (kg)
	.time = randomUniform (tmin,tmax)
	Add '.var$' point... .time .value
	.val = Get '.var$' at time... .time
	.vt = Extract '.var$' tier
	selectObject (kg)
	Remove '.var$' points between... tmin tmax
	.val1 = Get '.var$' at time... .time
	assert .val1 = undefined; Add '.var$' at time... '.time' '.value'
	
	plusObject (.vt)
	Replace '.var$' tier
	selectObject (kg)
	.val1 = Get '.var$' at time... .time
	assert .val1 =.val; Add '.var$' at time... '.time' '.value'
	removeObject (.vt)
endproc

procedure setget_2p .var$ .ifor .time .value
	selectObject (kg)
	Add delta '.var$' point... .ifor .time .value
	.val = Get delta '.var$' at time... .ifor .time
	assert .val = .value; Add delta '.var$' point... .ifor .time .value
	.fg = Extract delta formant grid
	selectObject (kg)
	Remove delta '.var$' points between... .ifor tmin tmax
	.val1 = Get delta '.var$' at time... .ifor .time
	assert .val1 = undefined; Get delta '.var$' at time... .ifor .time
	plusObject (.fg)
	Replace delta formant grid
	selectObject (kg)
	.val1 = Get delta '.var$' at time... .ifor .time
	assert .val1 =.val; Get delta '.var$' at time... .ifor .time
	removeObject (.fg)
endproc

procedure setget_3_old .var$ .choice$ .ifor .time .value
	selectObject (kg)
	Add '.var$' point... "'.choice$'" .ifor .time .value
	.val = Get '.var$' at time... "'.choice$'" .ifor .time
	assert .val = .value; Add '.var$' point... "'.choice$'" .ifor .time .value
	.fg = Extract formant grid... '.choice$'
	selectObject (kg)
	Remove '.var$' points between... "'.choice$'" .ifor tmin tmax
	.val1 = Get '.var$' at time... "'.choice$'" .ifor .time
	assert .val1 = undefined; Get '.var$' at time... "'.choice$'" .ifor .time
	plusObject (.fg)
	Replace formant grid... '.choice$'
	selectObject (kg)
	.val1 = Get '.var$' at time... "'.choice$'" .ifor .time
	assert .val1 =.val; Get '.var$' at time... "'.choice$'" .ifor .time
	removeObject (.fg)

endproc

procedure setget_3a_old .var$ .choice$ .ifor .time .value
	selectObject (kg)
	Add '.var$' point... "'.choice$'" .ifor .time .value
	.val = Get '.var$' at time... "'.choice$'" .ifor .time
	assert .val = .value; Add '.var$' point... "'.choice$'" .ifor .time .value
	.tier = Extract amplitude tier... "'.choice$'" .ifor
	selectObject (kg)
	Remove '.var$' points between... "'.choice$'" .ifor tmin tmax
	.val1 = Get '.var$' at time... "'.choice$'" .ifor .time
	assert .val1 = undefined; Get '.var$' at time... "'.choice$'" .ifor .time
	plusObject (.tier)
	Replace amplitude tier... "'.choice$'" .ifor
	selectObject (kg)
	.val1 = Get '.var$' at time... "'.choice$'" .ifor .time
	assert .val1 =.val; Get '.var$' at time... "'.choice$'" .ifor .time
	removeObject (.tier)
endproc

procedure setget_formants_old .type$
	for .i to numberOf'.type$'Formants
		.time = randomUniform (tmin, tmax)
		.f = (2*.i-1) * randomUniform (450, 550)
		.b = .f /10
		.a = randomUniform (70, 90)
		call setget_3_old "formant" "'.type$' formant" .i .time .f
		call setget_3_old "bandwidth" "'.type$' formant" .i .time .b
		call setget_3a_old "amplitude" "'.type$' formant" .i .time .a
	endfor
	selectObject (kg)
	Formula (frequencies)... "'.type$' formant" self + 100
	Formula (bandwidths)... "'.type$' formant" self * 2
endproc


procedure setget_3 .type$ .formant$ .var$ .ifor .time .value
	selectObject (kg)
	what$ = "'.type$' '.formant$' '.var$'"
	Remove 'what$' points... .ifor tmin tmax
	Add 'what$' point... .ifor .time .value
	.val = Get 'what$' at time... .ifor .time
	assert .val = .value;	'.val' '.value' (Get 'what$' at time... '.ifor' '.time')
	.fg = Extract '.type$' '.formant$' grid
	selectObject (kg)
	Remove 'what$' points... .ifor tmin tmax
	.val1 = Get 'what$' at time... .ifor .time
	assert .val1 = undefined;	'.val1' (Get 'what$' at time... '.ifor' '.time')
	plusObject (.fg)
	Replace '.type$' '.formant$' grid
	selectObject (kg)
	.val1 = Get 'what$' at time... .ifor .time
	if .var$ = "amplitude"
		.val = undefined
	endif
	assert .val1 =.val; '.val1' '.val' (Get 'what$' at time... '.ifor' '.time')
	removeObject (.fg)
endproc

procedure setget_formants .tYPE$
	.type$ = replace_regex$ (.tYPE$, "(^.)","\L\1", 1)
	for .i to numberOf'.tYPE$'Formants
		.time = randomUniform (tmin, tmax)
		.f = (2*.i-1) * randomUniform (450, 550)
		.b = .f /10
		.a = randomUniform (70, 90)
		call setget_3 '.type$' "formant" "frequency" .i .time .f
		call setget_3 '.type$' "formant" "bandwidth" .i .time .b
		if .tYPE$ <> "Delta"
			call setget_3 '.type$' "formant" "amplitude" .i .time .a
		endif
	endfor
	selectObject (kg)
	Formula ('.type$' formant frequencies)... self + 100
	Formula ('.type$' formant bandwidths)... self * 2
endproc

procedure setget_antiformants .tYPE$
	.type$ = replace_regex$ (.tYPE$, "(^.)","\L\1", 1)
	for .i to numberOf'.tYPE$'AntiFormants
		.time = randomUniform (tmin, tmax)
		.f = (2*.i-1) * randomUniform (450, 550)
		.b = .f /10
		call setget_3 '.type$' "antiformant" "frequency" .i .time .f
		call setget_3 '.type$' "antiformant" "bandwidth" .i .time .b
	endfor
	selectObject (kg)
	Formula ('.type$' antiformant frequencies)... self + 100
	Formula ('.type$' antiformant bandwidths)... self * 2
endproc


procedure setget_deltaformants
	for .i to numberOfDeltaFormants
		.time = randomUniform (tmin, tmax)
		.f = randomUniform (50, 60)
		.b = .f /10
		call setget_2p "formant" .i .time .f
		call setget_2p "bandwidth" .i .time .b
	endfor
endproc

procedure setget_antiformants_old .type$
	for .i to numberOf'.type$'AntiFormants
		.time = randomUniform (tmin, tmax)
		.f = (2*.i-1) * randomUniform (450, 550)
		.b = .f /10
		call setget_3_old "formant" "'.type$' antiformant" .i .time .f
		call setget_3_old "bandwidth" "'.type$' antiformant" .i .time .b
	endfor
endproc

procedure test_deltaFormants_old
	.kg = Create KlattGrid... kg 0 1 6 1 1 6 1 1 1
	Add pitch point... 0.5 100
	Add voicing amplitude point... 0.5 90
	Add bandwidth point... "Normal formant" 1 0.5 50
	Add delta formant point... 1 0.5 500
	Remove formant points between... "Normal formant" 1 0 2
	Add formant point... "Normal formant" 1 0 400
	Add formant point... "Normal formant" 1 1 600
	Add formant point... "Normal formant" 1 0.003553 400
	Add formant point... "Normal formant" 1 0.002 300
	Add formant point... "Normal formant" 1 0.0112 430
	.sound = To Sound
	selectObject (.kg)
	.fg = Extract formant grid (open phases)... 0.1
	removeObject (.sound, .kg, .fg)
endproc

procedure test_deltaFormants
	.kg = Create KlattGrid... kg 0 1 6 1 1 6 1 1 1
	Add pitch point... 0.5 100
	Add voicing amplitude point... 0.5 90
	Add oral formant bandwidth point... 1 0.5 50
	Add delta formant frequency point... 1 0.5 500
	Remove oral formant frequency points... 1 0 2
	Add oral formant frequency point... 1 0 400
	Add oral formant frequency point... 1 1 600
	Add oral formant frequency point... 1 0.003553 400
	Add oral formant frequency point... 1 0.002 300
	Add oral formant frequency point... 1 0.0112 430
	.sound = To Sound
	selectObject (.kg)
	.fg = Extract oral formant grid (open phases)... 0.1
	removeObject (.sound, .fg, .kg)
endproc

+22 −15

File changed.

Preview size limit exceeded, changes collapsed.

Loading