def encode_rate_depth(rate: int, depth: int):
    """return joined rate and byte depth of samples

    Sampling rate and sample depth are encoded in a single 4-byte integer.  The
    first byte is the depth the last 3 bytes give the sampling rate.
    """
    assert depth < 1 << 8, f'depth must be smaller than 256 (got {depth})'
    assert rate < 1 << 24, f'depth must be smaller than {1 << 24} (got {rate})'
    return (rate << 8) + depth
