Copyright | Will Thompson Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria (inaki@blueleaf.cc) |
Safe Haskell | None |
Language | Haskell2010 |
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
- newtype AudioBuffer = AudioBuffer (ManagedPtr AudioBuffer)
- newZeroAudioBuffer :: MonadIO m => m AudioBuffer
- noAudioBuffer :: Maybe AudioBuffer
- audioBufferClip :: (HasCallStack, MonadIO m) => Buffer -> Segment -> Int32 -> Int32 -> m Buffer
- audioBufferMap :: (HasCallStack, MonadIO m) => AudioBuffer -> AudioInfo -> Buffer -> [MapFlags] -> m Bool
- audioBufferReorderChannels :: (HasCallStack, MonadIO m) => Buffer -> AudioFormat -> [AudioChannelPosition] -> [AudioChannelPosition] -> m Bool
- audioBufferTruncate :: (HasCallStack, MonadIO m) => Buffer -> Int32 -> Word64 -> Word64 -> m Buffer
- audioBufferUnmap :: (HasCallStack, MonadIO m) => AudioBuffer -> m ()
- clearAudioBufferBuffer :: MonadIO m => AudioBuffer -> m ()
- getAudioBufferBuffer :: MonadIO m => AudioBuffer -> m (Maybe Buffer)
- setAudioBufferBuffer :: MonadIO m => AudioBuffer -> Ptr Buffer -> m ()
- getAudioBufferInfo :: MonadIO m => AudioBuffer -> m AudioInfo
- getAudioBufferNPlanes :: MonadIO m => AudioBuffer -> m Int32
- setAudioBufferNPlanes :: MonadIO m => AudioBuffer -> Int32 -> m ()
- getAudioBufferNSamples :: MonadIO m => AudioBuffer -> m Word64
- setAudioBufferNSamples :: MonadIO m => AudioBuffer -> Word64 -> m ()
- clearAudioBufferPlanes :: MonadIO m => AudioBuffer -> m ()
- getAudioBufferPlanes :: MonadIO m => AudioBuffer -> m (Ptr ())
- setAudioBufferPlanes :: MonadIO m => AudioBuffer -> Ptr () -> m ()
Exported types
newtype AudioBuffer Source #
Memory-managed wrapper type.
AudioBuffer (ManagedPtr AudioBuffer) |
Instances
WrappedPtr AudioBuffer Source # | |
Defined in GI.GstAudio.Structs.AudioBuffer wrappedPtrCalloc :: IO (Ptr AudioBuffer) wrappedPtrCopy :: AudioBuffer -> IO AudioBuffer wrappedPtrFree :: Maybe (GDestroyNotify AudioBuffer) | |
tag ~ AttrSet => Constructible AudioBuffer tag Source # | |
Defined in GI.GstAudio.Structs.AudioBuffer new :: MonadIO m => (ManagedPtr AudioBuffer -> AudioBuffer) -> [AttrOp AudioBuffer tag] -> m AudioBuffer |
newZeroAudioBuffer :: MonadIO m => m AudioBuffer Source #
Construct a AudioBuffer
struct initialized to zero.
noAudioBuffer :: Maybe AudioBuffer Source #
A convenience alias for Nothing
:: Maybe
AudioBuffer
.
Methods
clip
:: (HasCallStack, MonadIO m) | |
=> Buffer |
|
-> Segment |
|
-> Int32 |
|
-> Int32 |
|
-> m Buffer | Returns: 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
:: (HasCallStack, MonadIO m) | |
=> AudioBuffer |
|
-> AudioInfo |
|
-> Buffer |
|
-> [MapFlags] |
|
-> m Bool | Returns: |
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 #
:: (HasCallStack, MonadIO m) | |
=> Buffer |
|
-> AudioFormat |
|
-> [AudioChannelPosition] |
|
-> [AudioChannelPosition] |
|
-> m Bool | Returns: |
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
:: (HasCallStack, MonadIO m) | |
=> Buffer |
|
-> Int32 |
|
-> Word64 |
|
-> Word64 |
|
-> m Buffer | Returns: the truncated buffer or |
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.
After calling this function the caller does not own a reference to
buffer
anymore.
Since: 1.16
unmap
:: (HasCallStack, MonadIO m) | |
=> AudioBuffer |
|
-> 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 ]