def hpsTimeScale(hfreq, hmag, stocEnv, timeScaling):
 if ((timeScaling.size % 2) != 0):
  raise ValueError('Time scaling array does not have an even size')
 L = hfreq[:, 0].size
 maxInTime = max(timeScaling[::2])
 maxOutTime = max(timeScaling[1::2])
 outL = int(((L * maxOutTime) / maxInTime))
 inFrames = (((L - 1) * timeScaling[::2]) / maxInTime)
 outFrames = ((outL * timeScaling[1::2]) / maxOutTime)
 timeScalingEnv = interp1d(outFrames, inFrames, fill_value=0)
 indexes = timeScalingEnv(np.arange(outL))
 yhfreq = hfreq[round(indexes[0]), :]
 yhmag = hmag[round(indexes[0]), :]
 ystocEnv = stocEnv[round(indexes[0]), :]
 for l in indexes[1:]:
  yhfreq = np.vstack((yhfreq, hfreq[round(l), :]))
  yhmag = np.vstack((yhmag, hmag[round(l), :]))
  ystocEnv = np.vstack((ystocEnv, stocEnv[round(l), :]))
 return (yhfreq, yhmag, ystocEnv)

def hpsTimeScale ( hfreq , hmag , stocEnv , timeScaling ) : if ( ( timeScaling . size % 2 ) != 0 ) : raise ValueError ( 'Time scaling array does not have an even size' ) L = hfreq [ : , 0 ] . size maxInTime = max ( timeScaling [ : : 2 ] ) maxOutTime = max ( timeScaling [ 1 : : 2 ] ) outL = int ( ( ( L * maxOutTime ) / maxInTime ) ) inFrames = ( ( ( L - 1 ) * timeScaling [ : : 2 ] ) / maxInTime ) outFrames = ( ( outL * timeScaling [ 1 : : 2 ] ) / maxOutTime ) timeScalingEnv = interp1d ( outFrames , inFrames , fill_value = 0 ) indexes = timeScalingEnv ( np . arange ( outL ) ) yhfreq = hfreq [ round ( indexes [ 0 ] ) , : ] yhmag = hmag [ round ( indexes [ 0 ] ) , : ] ystocEnv = stocEnv [ round ( indexes [ 0 ] ) , : ] for l in indexes [ 1 : ] : yhfreq = np . vstack ( ( yhfreq , hfreq [ round ( l ) , : ] ) ) yhmag = np . vstack ( ( yhmag , hmag [ round ( l ) , : ] ) ) ystocEnv = np . vstack ( ( ystocEnv , stocEnv [ round ( l ) , : ] ) ) return ( yhfreq , yhmag , ystocEnv )
time scaling of the harmonic plus stochastic representation hfreq .