def stochasticTimeScale(stocEnv, timeScaling):
 if ((timeScaling.size % 2) != 0):
  raise ValueError('Time scaling array does not have an even size')
 L = stocEnv[:, 0].size
 outL = int(((L * timeScaling[(-1)]) / timeScaling[(-2)]))
 timeScalingEnv = interp1d((timeScaling[::2] / timeScaling[(-2)]), (timeScaling[1::2] / timeScaling[(-1)]))
 indexes = ((L - 1) * timeScalingEnv((np.arange(outL) / float(outL))))
 ystocEnv = stocEnv[0, :]
 for l in indexes[1:]:
  ystocEnv = np.vstack((ystocEnv, stocEnv[round(l), :]))
 return ystocEnv

def stochasticTimeScale ( stocEnv , timeScaling ) : if ( ( timeScaling . size % 2 ) != 0 ) : raise ValueError ( 'Time scaling array does not have an even size' ) L = stocEnv [ : , 0 ] . size outL = int ( ( ( L * timeScaling [ ( - 1 ) ] ) / timeScaling [ ( - 2 ) ] ) ) timeScalingEnv = interp1d ( ( timeScaling [ : : 2 ] / timeScaling [ ( - 2 ) ] ) , ( timeScaling [ 1 : : 2 ] / timeScaling [ ( - 1 ) ] ) ) indexes = ( ( L - 1 ) * timeScalingEnv ( ( np . arange ( outL ) / float ( outL ) ) ) ) ystocEnv = stocEnv [ 0 , : ] for l in indexes [ 1 : ] : ystocEnv = np . vstack ( ( ystocEnv , stocEnv [ round ( l ) , : ] ) ) return ystocEnv
time scaling of the stochastic representation of a sound stocenv: stochastic envelope timescaling: scaling factors .