def analysis(inputFile1='../../sounds/violin-B3.wav', window1='blackman', M1=1001, N1=1024, t1=(-100), minSineDur1=0.05, nH=60, minf01=200, maxf01=300, f0et1=10, harmDevSlope1=0.01, stocf=0.1, inputFile2='../../sounds/soprano-E4.wav', window2='blackman', M2=901, N2=1024, t2=(-100), minSineDur2=0.05, minf02=250, maxf02=500, f0et2=10, harmDevSlope2=0.01):
 Ns = 512
 H = 128
 (fs1, x1) = UF.wavread(inputFile1)
 (fs2, x2) = UF.wavread(inputFile2)
 w1 = get_window(window1, M1)
 w2 = get_window(window2, M2)
 (hfreq1, hmag1, hphase1, stocEnv1) = HPS.hpsModelAnal(x1, fs1, w1, N1, H, t1, nH, minf01, maxf01, f0et1, harmDevSlope1, minSineDur1, Ns, stocf)
 (hfreq2, hmag2, hphase2, stocEnv2) = HPS.hpsModelAnal(x2, fs2, w2, N2, H, t2, nH, minf02, maxf02, f0et2, harmDevSlope2, minSineDur2, Ns, stocf)
 plt.figure(figsize=(12, 9))
 maxplotfreq = 15000.0
 plt.subplot(2, 1, 1)
 numFrames = int(stocEnv1[:, 0].size)
 sizeEnv = int(stocEnv1[0, :].size)
 frmTime = ((H * np.arange(numFrames)) / float(fs1))
 binFreq = (((0.5 * fs1) * np.arange(((sizeEnv * maxplotfreq) / (0.5 * fs1)))) / sizeEnv)
 plt.pcolormesh(frmTime, binFreq, np.transpose(stocEnv1[:, :(((sizeEnv * maxplotfreq) / (0.5 * fs1)) + 1)]))
 plt.autoscale(tight=True)
 if (hfreq1.shape[1] > 0):
  harms = np.copy(hfreq1)
  harms = (harms * np.less(harms, maxplotfreq))
  harms[(harms == 0)] = np.nan
  numFrames = int(harms[:, 0].size)
  frmTime = ((H * np.arange(numFrames)) / float(fs1))
  plt.plot(frmTime, harms, color='k', ms=3, alpha=1)
  plt.xlabel('time (sec)')
  plt.ylabel('frequency (Hz)')
  plt.autoscale(tight=True)
  plt.title('harmonics + stochastic spectrogram of sound 1')
 plt.subplot(2, 1, 2)
 numFrames = int(stocEnv2[:, 0].size)
 sizeEnv = int(stocEnv2[0, :].size)
 frmTime = ((H * np.arange(numFrames)) / float(fs2))
 binFreq = (((0.5 * fs2) * np.arange(((sizeEnv * maxplotfreq) / (0.5 * fs2)))) / sizeEnv)
 plt.pcolormesh(frmTime, binFreq, np.transpose(stocEnv2[:, :(((sizeEnv * maxplotfreq) / (0.5 * fs2)) + 1)]))
 plt.autoscale(tight=True)
 if (hfreq2.shape[1] > 0):
  harms = np.copy(hfreq2)
  harms = (harms * np.less(harms, maxplotfreq))
  harms[(harms == 0)] = np.nan
  numFrames = int(harms[:, 0].size)
  frmTime = ((H * np.arange(numFrames)) / float(fs2))
  plt.plot(frmTime, harms, color='k', ms=3, alpha=1)
  plt.xlabel('time (sec)')
  plt.ylabel('frequency (Hz)')
  plt.autoscale(tight=True)
  plt.title('harmonics + stochastic spectrogram of sound 2')
 plt.tight_layout()
 plt.show(block=False)
 return (inputFile1, fs1, hfreq1, hmag1, stocEnv1, inputFile2, hfreq2, hmag2, stocEnv2)

def analysis ( inputFile1 = '../../sounds/violin-B3.wav' , window1 = 'blackman' , M1 = 1001 , N1 = 1024 , t1 = ( - 100 ) , minSineDur1 = 0.05 , nH = 60 , minf01 = 200 , maxf01 = 300 , f0et1 = 10 , harmDevSlope1 = 0.01 , stocf = 0.1 , inputFile2 = '../../sounds/soprano-E4.wav' , window2 = 'blackman' , M2 = 901 , N2 = 1024 , t2 = ( - 100 ) , minSineDur2 = 0.05 , minf02 = 250 , maxf02 = 500 , f0et2 = 10 , harmDevSlope2 = 0.01 ) : Ns = 512 H = 128 ( fs1 , x1 ) = UF . wavread ( inputFile1 ) ( fs2 , x2 ) = UF . wavread ( inputFile2 ) w1 = get_window ( window1 , M1 ) w2 = get_window ( window2 , M2 ) ( hfreq1 , hmag1 , hphase1 , stocEnv1 ) = HPS . hpsModelAnal ( x1 , fs1 , w1 , N1 , H , t1 , nH , minf01 , maxf01 , f0et1 , harmDevSlope1 , minSineDur1 , Ns , stocf ) ( hfreq2 , hmag2 , hphase2 , stocEnv2 ) = HPS . hpsModelAnal ( x2 , fs2 , w2 , N2 , H , t2 , nH , minf02 , maxf02 , f0et2 , harmDevSlope2 , minSineDur2 , Ns , stocf ) plt . figure ( figsize = ( 12 , 9 ) ) maxplotfreq = 15000.0 plt . subplot ( 2 , 1 , 1 ) numFrames = int ( stocEnv1 [ : , 0 ] . size ) sizeEnv = int ( stocEnv1 [ 0 , : ] . size ) frmTime = ( ( H * np . arange ( numFrames ) ) / float ( fs1 ) ) binFreq = ( ( ( 0.5 * fs1 ) * np . arange ( ( ( sizeEnv * maxplotfreq ) / ( 0.5 * fs1 ) ) ) ) / sizeEnv ) plt . pcolormesh ( frmTime , binFreq , np . transpose ( stocEnv1 [ : , : ( ( ( sizeEnv * maxplotfreq ) / ( 0.5 * fs1 ) ) + 1 ) ] ) ) plt . autoscale ( tight = True ) if ( hfreq1 . shape [ 1 ] > 0 ) : harms = np . copy ( hfreq1 ) harms = ( harms * np . less ( harms , maxplotfreq ) ) harms [ ( harms == 0 ) ] = np . nan numFrames = int ( harms [ : , 0 ] . size ) frmTime = ( ( H * np . arange ( numFrames ) ) / float ( fs1 ) ) plt . plot ( frmTime , harms , color = 'k' , ms = 3 , alpha = 1 ) plt . xlabel ( 'time (sec)' ) plt . ylabel ( 'frequency (Hz)' ) plt . autoscale ( tight = True ) plt . title ( 'harmonics + stochastic spectrogram of sound 1' ) plt . subplot ( 2 , 1 , 2 ) numFrames = int ( stocEnv2 [ : , 0 ] . size ) sizeEnv = int ( stocEnv2 [ 0 , : ] . size ) frmTime = ( ( H * np . arange ( numFrames ) ) / float ( fs2 ) ) binFreq = ( ( ( 0.5 * fs2 ) * np . arange ( ( ( sizeEnv * maxplotfreq ) / ( 0.5 * fs2 ) ) ) ) / sizeEnv ) plt . pcolormesh ( frmTime , binFreq , np . transpose ( stocEnv2 [ : , : ( ( ( sizeEnv * maxplotfreq ) / ( 0.5 * fs2 ) ) + 1 ) ] ) ) plt . autoscale ( tight = True ) if ( hfreq2 . shape [ 1 ] > 0 ) : harms = np . copy ( hfreq2 ) harms = ( harms * np . less ( harms , maxplotfreq ) ) harms [ ( harms == 0 ) ] = np . nan numFrames = int ( harms [ : , 0 ] . size ) frmTime = ( ( H * np . arange ( numFrames ) ) / float ( fs2 ) ) plt . plot ( frmTime , harms , color = 'k' , ms = 3 , alpha = 1 ) plt . xlabel ( 'time (sec)' ) plt . ylabel ( 'frequency (Hz)' ) plt . autoscale ( tight = True ) plt . title ( 'harmonics + stochastic spectrogram of sound 2' ) plt . tight_layout ( ) plt . show ( block = False ) return ( inputFile1 , fs1 , hfreq1 , hmag1 , stocEnv1 , inputFile2 , hfreq2 , hmag2 , stocEnv2 )
restful crud controller - for completed answers - not editable .