code: def getDEHL(duration, pitch):
      
      intPitch = int(pitch)
      fractPitch = pitch - intPitch  # Gets fractional part
      tmp = 1 + 0.0577622606 * fractPitch
      if not -60 <= intPitch <= 127:
          raise BeepError('Pitch out of range: must be between [-60, 127]')
  
      if duration < 0 or duration > 10:
          raise BeepError('Invalid duration: must be between [0, 10]')
  
      A = intPitch + 60
      B = -5 + int(A / 12)  # -5 <= B <= 10
      A %= 0xC  # Semitones above C
  
      frec = TABLE[A]
      tmp2 = tmp * frec
      f = tmp2 * 2.0 ** B
  
      DE = int(0.5 + f * duration - 1)
      HL = int(0.5 + 437500.0 / f - 30.125)
      return DE, HL
docs: Converts duration,pitch to a pair of unsigned 16 bit integers,
      to be loaded in DE,HL, following the ROM listing.
      Returns a t-uple with the DE, HL values.