# # ## ### ##### ########  #############  ##################### 
# Praat Script
# gradually blend two sounds
#
# Matthew Winn
# August 2014
##################################
##################### 
############# 
######## 
#####
###
##
#
#
clearinfo

numberOfSteps = 7

pause select two sounds to blend

sound1$ = selected$("Sound",1)
sound2$ = selected$("Sound",2)

# call the blending function with the specified number of steps,
# name the files using a combination of both sound names (the last argument) 
call gradualBlend2Sounds 'sound1$' 'sound2$' numberOfSteps 'sound1$'_'sound2$'_

procedure gradualBlend2Sounds .sound1$ .sound2$ .steps .namePrefix$

for .thisStep from 1 to .steps

.sound2Multiplier = (.thisStep-1)/(.steps-1)
.sound1Multiplier = 1-.sound2Multiplier

print Step '.thisStep''tab$''.sound1Multiplier:3''tab$''.sound2Multiplier:3''newline$'

select Sound '.sound1$'
Copy... '.namePrefix$''.thisStep'
Multiply... .sound1Multiplier
Formula... self [col] + (.sound2Multiplier*Sound_'.sound2$' [col])

endfor