<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def adsr(dur, a, d, s, r):
 """ Linear ADSR envelope. Parameters dur : Duration, in number of samples, including the release time. a : "Attack" time, in number of samples. d : "Decay" time, in number of samples. s : "Sustain" amplitude level (should be based on attack amplitude). r : "Release" time, in number of samples. Returns ------- Stream instance yielding a finite ADSR envelope, starting and finishing with 0.0, having peak value of 1.0. """

  m_a = 1. / a
  m_d = (s - 1.) / d
  m_r = - s * 1. / r
  len_a = int(a + .5)
  len_d = int(d + .5)
  len_r = int(r + .5)
  len_s = int(dur + .5) - len_a - len_d - len_r
  for sample in xrange(len_a):
    yield sample * m_a
  for sample in xrange(len_d):
    yield 1. + sample * m_d
  for sample in xrange(len_s):
    yield s
  for sample in xrange(len_r):
    yield s + sample * m_r