- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
#Creates an array with the frequencies from C2 to C5, 37 notes in all
for j from 1 to 37
	if j = 1 
	notes [j] = 65.41 # лёгкие пути не нужны
	endif
	if j = 2
	notes [j] = 69.30
	endif
# ...дальше понятно...
endfor
# <...>
#Determining whether or not the scale contains C
#This determines how many notes of the 37 possible must be included.
noCList [1] = 3 # опа, а вот тут уже научились числовые индексы использовать
noCList [2] = 5
noCList [3] = 7
noCList [4] = 10
noCList [5] = 12
noC = 0
for n from 1 to 5
	if 'starter' = noCList['n']
		noC = 1
	endif
endfor
#If there is a C...
if noC = 0
#The for loop mathematically selects the scale notes to use
for m from 1 to 22
	if 'm' = 1
		noteind = 'starter'
	endif
	if 'm' = 2
		noteind = 'starter' + 2
		if 'noteind' > 37
			noteind = 'noteind' - 36
		endif
	endif
# ...ага-ага...
	scalenotes ['m'] = notes['noteind']
endfor
#If there is not a C...
else
for m from 1 to 21
	if 'm' = 1
		noteind = 'starter'
	endif
	if 'm' = 2
		noteind = 'starter' + 2
		if 'noteind' > 37
			noteind = 'noteind' - 36
		endif
	endif
# ...так точно...
	scalenotes ['m'] = notes['noteind']
endfor
endif
# <...>
#Add new pitch information
#For each point, we move the freq to the closest scale note
for q from 1 to 'numPoints'
	#The original freq of pitch
	currentfreq = pitches['q']
	#A starting threhold for difference between original and a musical note
	diff = 50
	#If there is C in the scale, making 22 possible notes to tune to...
	if 'noC' = 0
	#For loop finds the lowest difference between original pitch and a musical note
	for c from 1 to 22
		diff2 = abs('currentfreq' - scalenotes['c'])
		if 'diff2' < 'diff'
			diff = 'diff2'
			noteindex = 'c'
		endif
	endfor
	#Otherwise if there is not a C...
	else
	for c from 1 to 21
		diff2 = abs('currentfreq' - scalenotes['c'])
		if 'diff2' < 'diff'
			diff = 'diff2'
			noteindex = 'c'
		endif
	endfor
	endif
	#Add point at the original time with the new pitch
	Add point... times['q'] scalenotes['noteindex']
endfor
                                 
        
            http://schyzm.wordpress.com/2012/12/05/fun-with-praat-a-script-for-auto-tune/
Скрипт питч-коррекции для речевого анализатора Praat на встроенном языке сценариев. Не знаю, это афтар так жжот или язык располагает к черезжопию, но что-то тут воняет однозначно.
        
        
Короче, гемор...
а их надо кормить и за ними убирать.
А ты подай в суд за оскорбления твоих религиозных чувств.
1) набор частот (01-10, в оригинале 014-127) можно задать гораздо короче, без кучи if'ов и цикла, т.к., судя по 16-20, язык поддерживает явное обращение к индексам массива;
2) ...да и нафига вообще заполнять это вручную, если частоты считаются в цикле по простейшей формуле (степенная зависимость), заодно и опорную высоту вместо хардкода можно предложить юзеру вводить (потребность редкая, но некоторым необходимая);
3) 27-58 (в оригинале 169-438) тоже можно оптимизировать без кучи ненужных if'ов и бредового деления на 21 и 22 (уж как минимум можно было загнать эту величину в переменную и подставить в for);
4) в 62-91 та же история с делением на 21 и 22.