code: def impulse(dur=None, one=1., zero=0.):
    
    if dur is None or (isinf(dur) and dur > 0):
      yield one
      while True:
        yield zero
    elif dur >= .5:
      num_samples = int(dur - .5)
      yield one
      for x in xrange(num_samples):
        yield zero
docs: Impulse stream generator.
  
    Parameters
    ----------
    dur :
      Duration, in number of samples; endless if not given.
  
    Returns
    -------
    Stream that repeats "0.0" during a given time duration (if any) or
    endlessly, but starts with one (and only one) "1.0".