def linear_scale(input, in_low, in_high, out_low, out_high):
    """ (number, number, number, number, number) -> float

    Linear scaling. Scales old_value in the range (in_high - in-low) to a value
    in the range (out_high - out_low). Returns the result.

    >>> linear_scale(0.5, 0.0, 1.0, 0, 127)
    63.5

    """

    in_range = (in_high - in_low)
    out_range = (out_high - out_low)
    result = (((input - in_low) * out_range) / in_range) + out_low

    return result