def calc_rc(bitrate, soft, cval=0.22 * 10 ** -6):
    """
    Calculate R and C values from a softnes constant and desired BitRate.

    Parameters
    ----------

    bitrate : int
              Desired bitrate to use
    soft : int 
           Desire softness constant to use
    cval : float
           Desire capacitor value in Farads. By default 0.22 uF

    Returns a tuple of Resistor value in Ohms and Capacitor value in Farads
    
    """
    from math import log
    if bitrate < 50:
        raise Exception('Invalid bitrate value %d Hz. Must be >= 50 Hz' %
            bitrate, bitrate)
    if soft < 2:
        raise Exception('Invalid softness value %d. Must be >= 2' % soft, soft)
    if cval <= 0:
        raise Exception('Invalid capacitor value %f. Must be > 0' % cval, cval)
    rval = -1.0 / (log(-1.0 / soft + 1) * bitrate * cval)
    return rval, cval
