truncate


Description:

public static Buffer truncate (owned Buffer buffer, int bpf, size_t trim, size_t samples)

Truncate the buffer to finally have samples number of samples, removing the necessary amount of samples from the end and trim number of samples from the beginning.

This function does not know the audio rate, therefore the caller is responsible for re-setting the correct timestamp and duration to the buffer. However, timestamp will be preserved if trim == 0, and duration will also be preserved if there is no trimming to be done. Offset and offset end will be preserved / updated.

After calling this function the caller does not own a reference to buffer anymore.

Parameters:

buffer

The buffer to truncate.

bpf

size of one audio frame in bytes. This is the size of one sample * number of channels.

trim

the number of samples to remove from the beginning of the buffer

samples

the final number of samples that should exist in this buffer or -1 to use all the remaining samples if you are only removing samples from the beginning.

Returns:

the truncated buffer