(body)
return data
Patch header to the given wave body.

    :param body: the wave content body, it should be bytearray.
Patch header to the given wave body.
Patch header to the given wave body .
def patch_wave_header(body):
    """Patch header to the given wave body.

    :param body: the wave content body, it should be bytearray.
    """
    length = len(body)

    padded = length + length % 2
    total = WAVE_HEADER_LENGTH + padded

    header = copy.copy(WAVE_HEADER)
    # fill the total length position
    header[4:8] = bytearray(struct.pack('<I', total))
    header += bytearray(struct.pack('<I', length))

    data = header + body

    # the total length is even
    if length != padded:
        data = data + bytearray([0])

    return data
def patch_wave_header ( body ) : length = len ( body ) padded = length + length % 2 total = WAVE_HEADER_LENGTH + padded header = copy . copy ( WAVE_HEADER ) # fill the total length position header [ 4 : 8 ] = bytearray ( struct . pack ( '<I' , total ) ) header += bytearray ( struct . pack ( '<I' , length ) ) data = header + body # the total length is even if length != padded : data = data + bytearray ( [ 0 ] ) return data