gi-gstaudio-1.0.27: GStreamerAudio bindings
CopyrightWill Thompson and Iñaki García Etxebarria
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellSafe-Inferred
LanguageHaskell2010

GI.GstAudio.Structs.AudioBuffer

Description

A structure containing the result of an audio buffer map operation, which is executed with audioBufferMap. 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 nPlanes equals 1.

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

Since: 1.16

Synopsis

Exported types

newtype AudioBuffer Source #

Memory-managed wrapper type.

Constructors

AudioBuffer (ManagedPtr AudioBuffer) 

Instances

Instances details
Eq AudioBuffer Source # 
Instance details

Defined in GI.GstAudio.Structs.AudioBuffer

BoxedPtr AudioBuffer Source # 
Instance details

Defined in GI.GstAudio.Structs.AudioBuffer

CallocPtr AudioBuffer Source # 
Instance details

Defined in GI.GstAudio.Structs.AudioBuffer

ManagedPtrNewtype AudioBuffer Source # 
Instance details

Defined in GI.GstAudio.Structs.AudioBuffer

Methods

toManagedPtr :: AudioBuffer -> ManagedPtr AudioBuffer

tag ~ 'AttrSet => Constructible AudioBuffer tag Source # 
Instance details

Defined in GI.GstAudio.Structs.AudioBuffer

Methods

new :: MonadIO m => (ManagedPtr AudioBuffer -> AudioBuffer) -> [AttrOp AudioBuffer tag] -> m AudioBuffer

newZeroAudioBuffer :: MonadIO m => m AudioBuffer Source #

Construct a AudioBuffer struct initialized to zero.

Methods

Click to display all available methods, including inherited ones

Expand

Methods

unmap.

Getters

None.

Setters

None.

clip

audioBufferClip Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buffer: The buffer to clip.

-> Segment

segment: Segment in FormatTime or FormatDefault to which the buffer should be clipped.

-> Int32

rate: sample rate.

-> Int32

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

-> m (Maybe Buffer)

Returns: Nothing 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

Clip the buffer to the given GstSegment.

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

map

audioBufferMap Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> AudioInfo

info: the audio properties of the buffer

-> Buffer

gstbuffer: the Buffer to be mapped

-> [MapFlags]

flags: the access mode for the memory

-> m (Bool, AudioBuffer)

Returns: True if the map operation succeeded or False on failure

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 AudioMeta in order to map each channel in a separate "plane" in AudioBuffer. If a AudioMeta is not attached on the gstbuffer, then it must be in interleaved layout.

If a AudioMeta is attached, then the 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 AudioInfo from the meta will be used.

In non-interleaved buffers, it is possible to have each channel on a separate 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 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 Buffer is not ref'ed, but it is required to stay valid as long as it's mapped.

Since: 1.16

reorderChannels

audioBufferReorderChannels Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buffer: The buffer to reorder.

-> AudioFormat

format: The GstAudioFormat of the buffer.

-> [AudioChannelPosition]

from: The channel positions in the buffer.

-> [AudioChannelPosition]

to: The channel positions to convert to.

-> m Bool

Returns: True if the reordering was possible.

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.

truncate

audioBufferTruncate Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Buffer

buffer: The buffer to truncate.

-> Int32

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

-> Word64

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

-> Word64

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.

-> m Buffer

Returns: the truncated buffer

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.

Since: 1.16

unmap

audioBufferUnmap Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> AudioBuffer

buffer: the AudioBuffer to unmap

-> m () 

Unmaps an audio buffer that was previously mapped with audioBufferMap.

Since: 1.16

Properties

buffer

the mapped buffer

clearAudioBufferBuffer :: MonadIO m => AudioBuffer -> m () Source #

Set the value of the “buffer” field to Nothing. When overloading is enabled, this is equivalent to

clear #buffer

getAudioBufferBuffer :: MonadIO m => AudioBuffer -> m (Maybe Buffer) Source #

Get the value of the “buffer” field. When overloading is enabled, this is equivalent to

get audioBuffer #buffer

setAudioBufferBuffer :: MonadIO m => AudioBuffer -> Ptr Buffer -> m () Source #

Set the value of the “buffer” field. When overloading is enabled, this is equivalent to

set audioBuffer [ #buffer := value ]

info

a AudioInfo describing the audio properties of this buffer

getAudioBufferInfo :: MonadIO m => AudioBuffer -> m AudioInfo Source #

Get the value of the “info” field. When overloading is enabled, this is equivalent to

get audioBuffer #info

nPlanes

the number of planes available

getAudioBufferNPlanes :: MonadIO m => AudioBuffer -> m Int32 Source #

Get the value of the “n_planes” field. When overloading is enabled, this is equivalent to

get audioBuffer #nPlanes

setAudioBufferNPlanes :: MonadIO m => AudioBuffer -> Int32 -> m () Source #

Set the value of the “n_planes” field. When overloading is enabled, this is equivalent to

set audioBuffer [ #nPlanes := value ]

nSamples

the size of the buffer in samples

getAudioBufferNSamples :: MonadIO m => AudioBuffer -> m Word64 Source #

Get the value of the “n_samples” field. When overloading is enabled, this is equivalent to

get audioBuffer #nSamples

setAudioBufferNSamples :: MonadIO m => AudioBuffer -> Word64 -> m () Source #

Set the value of the “n_samples” field. When overloading is enabled, this is equivalent to

set audioBuffer [ #nSamples := value ]

planes

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

clearAudioBufferPlanes :: MonadIO m => AudioBuffer -> m () Source #

Set the value of the “planes” field to Nothing. When overloading is enabled, this is equivalent to

clear #planes

getAudioBufferPlanes :: MonadIO m => AudioBuffer -> m (Ptr ()) Source #

Get the value of the “planes” field. When overloading is enabled, this is equivalent to

get audioBuffer #planes

setAudioBufferPlanes :: MonadIO m => AudioBuffer -> Ptr () -> m () Source #

Set the value of the “planes” field. When overloading is enabled, this is equivalent to

set audioBuffer [ #planes := value ]