import array


def _prepare_for_sound(mls):
    """
    Re-scale the MLS so that is a proper array of bytes. This allows us to use
    it with an audio device. We assume 16-bit precision.
    """
    new_mls = []
    int_max = 2**15 - 2 
    for sample in mls:
        if sample == 0:
            # Min UInt16
            new_mls.append(-int_max)
        else:
            # Max UInt16
            new_mls.append(int_max)
    # 16-bit array.
    return array.array('h',new_mls)