title: cracking sound sine tone in pyaudio
body: <p>I am using python and pyaudio to stream a pure sine tone using a callback method, in order to later modulate the sound via user input. Everything is fine except that when i run the code, i get 1-2 seconds of a cracking-buzzing sound associated to the warning message
  ALSA lib pcm.c:7339:(snd_pcm_recover) underrun occurred
  After that, the sine tone is streamed correctly. Any hints about how to remove the initial popping sound?
  here is the code that stream the sound for one second</p>
  
  <pre><code>import pyaudio
  import time
  import numpy as np
  
  CHANNELS = 1
  RATE = 44100
  freq = 600
  CHUNK = 1024
  lastchunk = 0
  def sine(current_time):
      global freq,lastchunk
      length = CHUNK
      factor = float(freq)*2*np.pi/RATE
      this_chunk = np.arange(length)+lastchunk
      lastchunk = this_chunk[-1]
      return np.sin(this_chunk*factor)
  
  def get_chunk(): 
      data  = sine(time.time())
      return data * 0.1
  
  
  def callback(in_data, frame_count, time_info, status):
      chunk = get_chunk() * 0.25
      data = chunk.astype(np.float32).tostring()
      return (data, pyaudio.paContinue)
  
  p = pyaudio.PyAudio()
  
  stream = p.open(format=pyaudio.paFloat32,
              channels=CHANNELS,
              rate=RATE,
              output=True,
              stream_callback=callback)
  
  stream.start_stream()
  time.sleep(1)   
  
  
  
  
  stream.stop_stream()
  stream.close()
  </code></pre>
  
  <p>Cheers</p>