def sineTimeScaling(sfreq, smag, timeScaling):
 if ((timeScaling.size % 2) != 0):
  raise ValueError('Time scaling array does not have an even size')
 L = sfreq.shape[0]
 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))
 ysfreq = sfreq[round(indexes[0]), :]
 ysmag = smag[round(indexes[0]), :]
 for l in indexes[1:]:
  ysfreq = np.vstack((ysfreq, sfreq[round(l), :]))
  ysmag = np.vstack((ysmag, smag[round(l), :]))
 return (ysfreq, ysmag)

def sineTimeScaling ( sfreq , smag , timeScaling ) : if ( ( timeScaling . size % 2 ) != 0 ) : raise ValueError ( 'Time scaling array does not have an even size' ) L = sfreq . shape [ 0 ] 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 ) ) ysfreq = sfreq [ round ( indexes [ 0 ] ) , : ] ysmag = smag [ round ( indexes [ 0 ] ) , : ] for l in indexes [ 1 : ] : ysfreq = np . vstack ( ( ysfreq , sfreq [ round ( l ) , : ] ) ) ysmag = np . vstack ( ( ysmag , smag [ round ( l ) , : ] ) ) return ( ysfreq , ysmag )
time scaling of sinusoidal tracks sfreq .