title: Python simple audio tone generator
body: <p>Looking for some (simple) python tone generator to use in following script running on raspi with USB sound card. On-fly tone on/off and frequency change are required.</p>
  
  <pre><code>import serial, time
  ser = serial.Serial('/dev/ttyUSB0', 9600, timeout=0.1)
  
  def monitor(inp=0):
      if inp != inpold:
          if inp != 0:
              ser.setDTR(1)   # LED on (GPIO?)
                  # start tone here, generate tone forever or change tone freq
          else:
              ser.setDTR(0)   # LED off
                  # stop tone without clicks
          inpold = inp 
  While True:
      time.sleep(0.01)        # min lenght tone pulse 10 milliseconds
      input = ser.getCTS()        # or GPIO input
      monitor(input)
  </code></pre>