audio buffer

## GstAudioBuffer

A structure containing the result of an audio buffer map operation, which is executed with gst_audio_buffer_map. For non-interleaved (planar) buffers, the beginning of each channel in the buffer has its own pointer in the planes array. For interleaved buffers, the planes array only contains one item, which is the pointer to the beginning of the buffer, and n_planes equals 1.

The different channels in planes are always in the GStreamer channel order.

### Members

`info` (GstAudioInfo) –

a GstAudioInfo describing the audio properties of this buffer

`n_samples` (gsize) –

the size of the buffer in samples

`n_planes` (gint) –

the number of planes available

`planes` (gpointer *) –

an array of n_planes pointers pointing to the start of each plane in the mapped buffer

`buffer` (GstBuffer *) –

the mapped buffer

## GstAudio.AudioBuffer

A structure containing the result of an audio buffer map operation, which is executed with GstAudio.prototype.audio_buffer_map. For non-interleaved (planar) buffers, the beginning of each channel in the buffer has its own pointer in the planes array. For interleaved buffers, the planes array only contains one item, which is the pointer to the beginning of the buffer, and n_planes equals 1.

The different channels in planes are always in the GStreamer channel order.

### Members

`info` (GstAudio.AudioInfo) –

a GstAudio.AudioInfo describing the audio properties of this buffer

`n_samples` (Number) –

the size of the buffer in samples

`n_planes` (Number) –

the number of planes available

`planes` (Object) –

an array of n_planes pointers pointing to the start of each plane in the mapped buffer

`buffer` (Gst.Buffer) –

the mapped buffer

## GstAudio.AudioBuffer

A structure containing the result of an audio buffer map operation, which is executed with GstAudio.audio_buffer_map. For non-interleaved (planar) buffers, the beginning of each channel in the buffer has its own pointer in the planes array. For interleaved buffers, the planes array only contains one item, which is the pointer to the beginning of the buffer, and n_planes equals 1.

The different channels in planes are always in the GStreamer channel order.

### Members

`info` (GstAudio.AudioInfo) –

a GstAudio.AudioInfo describing the audio properties of this buffer

`n_samples` (int) –

the size of the buffer in samples

`n_planes` (int) –

the number of planes available

`planes` (object) –

an array of n_planes pointers pointing to the start of each plane in the mapped buffer

`buffer` (Gst.Buffer) –

the mapped buffer

### Methods

#### gst_audio_buffer_unmap

    gst_audio_buffer_unmap (GstAudioBuffer * buffer)

Unmaps an audio buffer that was previously mapped with gst_audio_buffer_map.

Parameters:

`buffer` –

the GstAudioBuffer to unmap

Since : 1.16

#### GstAudio.AudioBuffer.prototype.unmap

    function GstAudio.AudioBuffer.prototype.unmap(): {
        // javascript wrapper for 'gst_audio_buffer_unmap'
    }

Unmaps an audio buffer that was previously mapped with GstAudio.prototype.audio_buffer_map.

Parameters:

`buffer` (GstAudio.AudioBuffer) –

the GstAudio.AudioBuffer to unmap

Since : 1.16

#### GstAudio.AudioBuffer.unmap

    def GstAudio.AudioBuffer.unmap (self):
        #python wrapper for 'gst_audio_buffer_unmap'

Unmaps an audio buffer that was previously mapped with GstAudio.audio_buffer_map.

Parameters:

`buffer` (GstAudio.AudioBuffer) –

the GstAudio.AudioBuffer to unmap

Since : 1.16

### Functions

#### gst_audio_buffer_clip

    GstBuffer *
    gst_audio_buffer_clip (GstBuffer * buffer,
                           const GstSegment * segment,
                           gint rate,
                           gint bpf)

Clip the buffer to the given GstSegment.

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

Parameters:

`buffer` ( [transfer: full]) –

The buffer to clip.

`segment` –

Segment in GST_FORMAT_TIME or GST_FORMAT_DEFAULT to which the buffer should be clipped.

`rate` –

sample rate.

`bpf` –

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

Returns ( [transfer: full]) –

NULL if the buffer is completely outside the configured segment, otherwise the clipped buffer is returned.

If the buffer has no timestamp, it is assumed to be inside the segment and is not clipped

#### GstAudio.prototype.audio_buffer_clip

    function GstAudio.prototype.audio_buffer_clip(buffer: Gst.Buffer, segment: Gst.Segment, rate: Number, bpf: Number): {
        // javascript wrapper for 'gst_audio_buffer_clip'
    }

Clip the buffer to the given Gst.Segment.

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

Parameters:

`buffer` (Gst.Buffer) –

The buffer to clip.

`segment` (Gst.Segment) –

Segment in Gst.Format.TIME or Gst.Format.DEFAULT to which the buffer should be clipped.

`rate` (Number) –

sample rate.

`bpf` (Number) –

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

Returns (Gst.Buffer) –

null if the buffer is completely outside the configured segment, otherwise the clipped buffer is returned.

If the buffer has no timestamp, it is assumed to be inside the segment and is not clipped

#### GstAudio.audio_buffer_clip

    def GstAudio.audio_buffer_clip (buffer, segment, rate, bpf):
        #python wrapper for 'gst_audio_buffer_clip'

Clip the buffer to the given Gst.Segment.

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

Parameters:

`buffer` (Gst.Buffer) –

The buffer to clip.

`segment` (Gst.Segment) –

Segment in Gst.Format.TIME or Gst.Format.DEFAULT to which the buffer should be clipped.

`rate` (int) –

sample rate.

`bpf` (int) –

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

Returns (Gst.Buffer) –

None if the buffer is completely outside the configured segment, otherwise the clipped buffer is returned.

If the buffer has no timestamp, it is assumed to be inside the segment and is not clipped

#### gst_audio_buffer_map

    gboolean
    gst_audio_buffer_map (GstAudioBuffer * buffer,
                          const GstAudioInfo * info,
                          GstBuffer * gstbuffer,
                          GstMapFlags flags)

Maps an audio gstbuffer so that it can be read or written and stores the result of the map operation in buffer.

This is especially useful when the gstbuffer is in non-interleaved (planar) layout, in which case this function will use the information in the gstbuffer's attached GstAudioMeta in order to map each channel in a separate "plane" in GstAudioBuffer. If a GstAudioMeta is not attached on the gstbuffer, then it must be in interleaved layout.

If a GstAudioMeta is attached, then the GstAudioInfo on the meta is checked against info. Normally, they should be equal, but in case they are not, a g_critical will be printed and the GstAudioInfo from the meta will be used.

In non-interleaved buffers, it is possible to have each channel on a separate GstMemory. In this case, each memory will be mapped separately to avoid copying their contents in a larger memory area. Do note though that it is not supported to have a single channel spanning over two or more different GstMemory objects. Although the map operation will likely succeed in this case, it will be highly sub-optimal and it is recommended to merge all the memories in the buffer before calling this function.

Note: The actual GstBuffer is not ref'ed, but it is required to stay valid as long as it's mapped.

Parameters:

`buffer` ( [out]) –

pointer to a GstAudioBuffer

`info` –

the audio properties of the buffer

`gstbuffer` ( [transfer: none]) –

the GstBuffer to be mapped

`flags` –

the access mode for the memory

Returns –

TRUE if the map operation succeeded or FALSE on failure

Since : 1.16

#### GstAudio.prototype.audio_buffer_map

    function GstAudio.prototype.audio_buffer_map(info: GstAudio.AudioInfo, gstbuffer: Gst.Buffer, flags: Gst.MapFlags): {
        // javascript wrapper for 'gst_audio_buffer_map'
    }

Maps an audio gstbuffer so that it can be read or written and stores the result of the map operation in buffer.

This is especially useful when the gstbuffer is in non-interleaved (planar) layout, in which case this function will use the information in the gstbuffer's attached GstAudio.AudioMeta in order to map each channel in a separate "plane" in GstAudio.AudioBuffer. If a GstAudio.AudioMeta is not attached on the gstbuffer, then it must be in interleaved layout.

If a GstAudio.AudioMeta is attached, then the GstAudio.AudioInfo on the meta is checked against info. Normally, they should be equal, but in case they are not, a g_critical will be printed and the GstAudio.AudioInfo from the meta will be used.

In non-interleaved buffers, it is possible to have each channel on a separate Gst.Memory. In this case, each memory will be mapped separately to avoid copying their contents in a larger memory area. Do note though that it is not supported to have a single channel spanning over two or more different Gst.Memory objects. Although the map operation will likely succeed in this case, it will be highly sub-optimal and it is recommended to merge all the memories in the buffer before calling this function.

Note: The actual Gst.Buffer is not ref'ed, but it is required to stay valid as long as it's mapped.

Parameters:

`info` (GstAudio.AudioInfo) –

the audio properties of the buffer

`gstbuffer` (Gst.Buffer) –

the Gst.Buffer to be mapped

`flags` (Gst.MapFlags) –

the access mode for the memory

Returns a tuple made of:

(Number ) –

true if the map operation succeeded or false on failure

`buffer` (GstAudio.AudioBuffer ) –

true if the map operation succeeded or false on failure

Since : 1.16

#### GstAudio.audio_buffer_map

    def GstAudio.audio_buffer_map (info, gstbuffer, flags):
        #python wrapper for 'gst_audio_buffer_map'

Maps an audio gstbuffer so that it can be read or written and stores the result of the map operation in buffer.

This is especially useful when the gstbuffer is in non-interleaved (planar) layout, in which case this function will use the information in the gstbuffer's attached GstAudio.AudioMeta in order to map each channel in a separate "plane" in GstAudio.AudioBuffer. If a GstAudio.AudioMeta is not attached on the gstbuffer, then it must be in interleaved layout.

If a GstAudio.AudioMeta is attached, then the GstAudio.AudioInfo on the meta is checked against info. Normally, they should be equal, but in case they are not, a g_critical will be printed and the GstAudio.AudioInfo from the meta will be used.

In non-interleaved buffers, it is possible to have each channel on a separate Gst.Memory. In this case, each memory will be mapped separately to avoid copying their contents in a larger memory area. Do note though that it is not supported to have a single channel spanning over two or more different Gst.Memory objects. Although the map operation will likely succeed in this case, it will be highly sub-optimal and it is recommended to merge all the memories in the buffer before calling this function.

Note: The actual Gst.Buffer is not ref'ed, but it is required to stay valid as long as it's mapped.

Parameters:

`info` (GstAudio.AudioInfo) –

the audio properties of the buffer

`gstbuffer` (Gst.Buffer) –

the Gst.Buffer to be mapped

`flags` (Gst.MapFlags) –

the access mode for the memory

Returns a tuple made of:

(bool ) –

True if the map operation succeeded or False on failure

`buffer` (GstAudio.AudioBuffer ) –

True if the map operation succeeded or False on failure

Since : 1.16

#### gst_audio_buffer_reorder_channels

    gboolean
    gst_audio_buffer_reorder_channels (GstBuffer * buffer,
                                       GstAudioFormat format,
                                       gint channels,
                                       const GstAudioChannelPosition * from,
                                       const GstAudioChannelPosition * to)

Reorders buffer from the channel positions from to the channel positions to. from and to must contain the same number of positions and the same positions, only in a different order. buffer must be writable.

Parameters:

`buffer` –

The buffer to reorder.

`format` –

The GstAudioFormat of the buffer.

`channels` –

The number of channels.

`from` ( [arraylength=channels]) –

The channel positions in the buffer.

`to` ( [arraylength=channels]) –

The channel positions to convert to.

Returns –

TRUE if the reordering was possible.

#### GstAudio.prototype.audio_buffer_reorder_channels

    function GstAudio.prototype.audio_buffer_reorder_channels(buffer: Gst.Buffer, format: GstAudio.AudioFormat, channels: Number, from: [ GstAudio.AudioChannelPosition ], to: [ GstAudio.AudioChannelPosition ]): {
        // javascript wrapper for 'gst_audio_buffer_reorder_channels'
    }

Reorders buffer from the channel positions from to the channel positions to. from and to must contain the same number of positions and the same positions, only in a different order. buffer must be writable.

Parameters:

`buffer` (Gst.Buffer) –

The buffer to reorder.

`format` (GstAudio.AudioFormat) –

The GstAudio.AudioFormat of the buffer.

`channels` (Number) –

The number of channels.

`from` ([ GstAudio.AudioChannelPosition ]) –

The channel positions in the buffer.

`to` ([ GstAudio.AudioChannelPosition ]) –

The channel positions to convert to.

Returns (Number) –

true if the reordering was possible.

#### GstAudio.audio_buffer_reorder_channels

    def GstAudio.audio_buffer_reorder_channels (buffer, format, channels, from, to):
        #python wrapper for 'gst_audio_buffer_reorder_channels'

Reorders buffer from the channel positions from to the channel positions to. from and to must contain the same number of positions and the same positions, only in a different order. buffer must be writable.

Parameters:

`buffer` (Gst.Buffer) –

The buffer to reorder.

`format` (GstAudio.AudioFormat) –

The GstAudio.AudioFormat of the buffer.

`channels` (int) –

The number of channels.

`from` ([ GstAudio.AudioChannelPosition ]) –

The channel positions in the buffer.

`to` ([ GstAudio.AudioChannelPosition ]) –

The channel positions to convert to.

Returns (bool) –

True if the reordering was possible.

#### gst_audio_buffer_truncate

    GstBuffer *
    gst_audio_buffer_truncate (GstBuffer * buffer,
                               gint bpf,
                               gsize trim,
                               gsize 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` ( [transfer: full]) –

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 ( [transfer: full]) –

the truncated buffer or NULL if the arguments were invalid

Since : 1.16

#### GstAudio.prototype.audio_buffer_truncate

    function GstAudio.prototype.audio_buffer_truncate(buffer: Gst.Buffer, bpf: Number, trim: Number, samples: Number): {
        // javascript wrapper for 'gst_audio_buffer_truncate'
    }

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` (Gst.Buffer) –

The buffer to truncate.

`bpf` (Number) –

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

`trim` (Number) –

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

`samples` (Number) –

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 (Gst.Buffer) –

the truncated buffer or null if the arguments were invalid

Since : 1.16

#### GstAudio.audio_buffer_truncate

    def GstAudio.audio_buffer_truncate (buffer, bpf, trim, samples):
        #python wrapper for 'gst_audio_buffer_truncate'

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` (Gst.Buffer) –

The buffer to truncate.

`bpf` (int) –

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

`trim` (int) –

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

`samples` (int) –

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 (Gst.Buffer) –

the truncated buffer or None if the arguments were invalid

Since : 1.16

## Function Macros

### GST_AUDIO_BUFFER_BPF

    #define GST_AUDIO_BUFFER_BPF(b)             (GST_AUDIO_INFO_BPF(&(b)->info))

### GST_AUDIO_BUFFER_BPS

    #define GST_AUDIO_BUFFER_BPS(b)             (GST_AUDIO_INFO_DEPTH(&(b)->info) >> 3)

### GST_AUDIO_BUFFER_CHANNELS

    #define GST_AUDIO_BUFFER_CHANNELS(b)        (GST_AUDIO_INFO_CHANNELS(&(b)->info))

### GST_AUDIO_BUFFER_DEPTH

    #define GST_AUDIO_BUFFER_DEPTH(b)           (GST_AUDIO_INFO_DEPTH(&(b)->info))

### GST_AUDIO_BUFFER_FORMAT

    #define GST_AUDIO_BUFFER_FORMAT(b)          (GST_AUDIO_INFO_FORMAT(&(b)->info))

### GST_AUDIO_BUFFER_LAYOUT

    #define GST_AUDIO_BUFFER_LAYOUT(b)          (GST_AUDIO_INFO_LAYOUT(&(b)->info))

### GST_AUDIO_BUFFER_N_PLANES

    #define GST_AUDIO_BUFFER_N_PLANES(b)        ((b)->n_planes)

### GST_AUDIO_BUFFER_N_SAMPLES

    #define GST_AUDIO_BUFFER_N_SAMPLES(b)       ((b)->n_samples)

### GST_AUDIO_BUFFER_PLANE_DATA

    #define GST_AUDIO_BUFFER_PLANE_DATA(b,p)    ((b)->planes[p])

### GST_AUDIO_BUFFER_PLANE_SIZE

    #define GST_AUDIO_BUFFER_PLANE_SIZE(b)      \
        (GST_AUDIO_BUFFER_N_SAMPLES(b) * GST_AUDIO_BUFFER_SAMPLE_STRIDE(b) * \
         GST_AUDIO_BUFFER_CHANNELS(b) / GST_AUDIO_BUFFER_N_PLANES(b))

### GST_AUDIO_BUFFER_RATE

    #define GST_AUDIO_BUFFER_RATE(b)            (GST_AUDIO_INFO_RATE(&(b)->info))

### GST_AUDIO_BUFFER_SAMPLE_STRIDE

    #define GST_AUDIO_BUFFER_SAMPLE_STRIDE(b)   (GST_AUDIO_INFO_WIDTH(&(b)->info) >> 3)

### GST_AUDIO_BUFFER_WIDTH

    #define GST_AUDIO_BUFFER_WIDTH(b)           (GST_AUDIO_INFO_WIDTH(&(b)->info))

The results of the search are