当前位置: 首页>>代码示例>>Python>>正文


Python Stream.pop方法代码示例

本文整理汇总了Python中stream.Stream.pop方法的典型用法代码示例。如果您正苦于以下问题:Python Stream.pop方法的具体用法?Python Stream.pop怎么用?Python Stream.pop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在stream.Stream的用法示例。


在下文中一共展示了Stream.pop方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from stream import Stream [as 别名]
# 或者: from stream.Stream import pop [as 别名]
def main():
  # Start interactive mode
  plt.ion()

  # Load sample
  wavfile  = sp.io.wavfile.read('sample.wav')
  wavdata  = np.float64(wavfile[1])
  wavdata /= np.float64(np.iinfo(wavfile[1].dtype).max)
  wavdata *= 10.0
  stream   = Stream(wavfile[0])
  stream.write(wavdata)

  # Search for training symbol
  training_spectrum = np.array([complex() for x in range(64)])
  training_spectrum[2      + 4*0] = complex(1, 0)
  training_spectrum[2      + 4*1] = complex(1, 0)
  training_spectrum[2      + 4*2] = complex(1, 0)
  training_spectrum[64 - 2 - 4*2] = complex(1, 0)
  training_spectrum[64 - 2 - 4*1] = complex(1, 0)
  training_spectrum[64 - 2 - 4*0] = complex(1, 0)
  training_signal = np.fft.ifft(training_spectrum)*40.0
  training_spectrum /= np.linalg.norm(training_spectrum)
  training_signal   /= np.linalg.norm(training_signal)
  for i in range(len(stream.buffer) - 64):
    window_signal  = stream.buffer[i: i + 64]
    window_signal /= np.linalg.norm(window_signal)
    #window_spectrum = np.fft.fft(window_signal)
    #window_spectrum /= np.linalg.norm(window_spectrum)
    corr = abs(np.correlate(training_signal, window_signal))
    print(corr)
    return
    if(corr > 0.9):
      print('Signal @ %s' % str(i/SAMPLE_RATE))
      stream.pop(i)
      break

  # Display signal
  spectrum = Spectrum(stream, COMPONENETS)
  waveform = Waveform(stream, COMPONENETS)
  spectrum.tick()
  waveform.tick()
  plt.show()
  while(True):
    plt.pause(0.10)
    stream.pop(1)
    spectrum.tick()
    waveform.tick()
开发者ID:d-b,项目名称:CSC372,代码行数:49,代码来源:modem.py


注:本文中的stream.Stream.pop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。