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 |
This object is used to convert audio samples from one format to another. The object can perform conversion of:
- audio format with optional dithering and noise shaping
- audio samplerate
- audio channels and channel layout
Synopsis
- newtype AudioConverter = AudioConverter (ManagedPtr AudioConverter)
- noAudioConverter :: Maybe AudioConverter
- audioConverterConvert :: (HasCallStack, MonadIO m) => AudioConverter -> [AudioConverterFlags] -> ByteString -> m (Bool, ByteString)
- audioConverterFree :: (HasCallStack, MonadIO m) => AudioConverter -> m ()
- audioConverterGetConfig :: (HasCallStack, MonadIO m) => AudioConverter -> m (Structure, Int32, Int32)
- audioConverterGetInFrames :: (HasCallStack, MonadIO m) => AudioConverter -> Word64 -> m Word64
- audioConverterGetMaxLatency :: (HasCallStack, MonadIO m) => AudioConverter -> m Word64
- audioConverterGetOutFrames :: (HasCallStack, MonadIO m) => AudioConverter -> Word64 -> m Word64
- audioConverterIsPassthrough :: (HasCallStack, MonadIO m) => AudioConverter -> m Bool
- audioConverterNew :: (HasCallStack, MonadIO m) => [AudioConverterFlags] -> AudioInfo -> AudioInfo -> Maybe Structure -> m AudioConverter
- audioConverterReset :: (HasCallStack, MonadIO m) => AudioConverter -> m ()
- audioConverterSamples :: (HasCallStack, MonadIO m) => AudioConverter -> [AudioConverterFlags] -> Ptr () -> Word64 -> Ptr () -> Word64 -> m Bool
- audioConverterSupportsInplace :: (HasCallStack, MonadIO m) => AudioConverter -> m Bool
- audioConverterUpdateConfig :: (HasCallStack, MonadIO m) => AudioConverter -> Int32 -> Int32 -> Maybe Structure -> m Bool
Exported types
newtype AudioConverter Source #
Memory-managed wrapper type.
Instances
BoxedObject AudioConverter Source # | |
Defined in GI.GstAudio.Structs.AudioConverter boxedType :: AudioConverter -> IO GType # |
noAudioConverter :: Maybe AudioConverter Source #
A convenience alias for Nothing
:: Maybe
AudioConverter
.
Methods
convert
audioConverterConvert Source #
:: (HasCallStack, MonadIO m) | |
=> AudioConverter |
|
-> [AudioConverterFlags] |
|
-> ByteString |
|
-> m (Bool, ByteString) | Returns: |
Convenience wrapper around audioConverterSamples
, which will
perform allocation of the output buffer based on the result from
audioConverterGetOutFrames
.
Since: 1.14
free
:: (HasCallStack, MonadIO m) | |
=> AudioConverter |
|
-> m () |
Free a previously allocated convert
instance.
getConfig
audioConverterGetConfig Source #
:: (HasCallStack, MonadIO m) | |
=> AudioConverter |
|
-> m (Structure, Int32, Int32) | Returns:
a |
Get the current configuration of convert
.
getInFrames
audioConverterGetInFrames Source #
:: (HasCallStack, MonadIO m) | |
=> AudioConverter |
|
-> Word64 |
|
-> m Word64 | Returns: the number of input frames |
Calculate how many input frames are currently needed by convert
to produce
outFrames
of output frames.
getMaxLatency
audioConverterGetMaxLatency Source #
:: (HasCallStack, MonadIO m) | |
=> AudioConverter |
|
-> m Word64 | Returns: the latency of |
Get the maximum number of input frames that the converter would need before producing output.
getOutFrames
audioConverterGetOutFrames Source #
:: (HasCallStack, MonadIO m) | |
=> AudioConverter |
|
-> Word64 |
|
-> m Word64 | Returns: the number of output frames |
Calculate how many output frames can be produced when inFrames
input
frames are given to convert
.
isPassthrough
audioConverterIsPassthrough Source #
:: (HasCallStack, MonadIO m) | |
=> AudioConverter | |
-> m Bool | Returns: |
Returns whether the audio converter will operate in passthrough mode.
The return value would be typically input to baseTransformSetPassthrough
Since: 1.16
new
:: (HasCallStack, MonadIO m) | |
=> [AudioConverterFlags] |
|
-> AudioInfo |
|
-> AudioInfo |
|
-> Maybe Structure |
|
-> m AudioConverter | Returns: a |
Create a new AudioConverter
that is able to convert between in
and out
audio formats.
config
contains extra configuration options, see GST_AUDIO_CONVERTER_OPT_
*
parameters for details about the options and values.
reset
:: (HasCallStack, MonadIO m) | |
=> AudioConverter |
|
-> m () |
Reset convert
to the state it was when it was first created, clearing
any history it might currently have.
samples
audioConverterSamples Source #
:: (HasCallStack, MonadIO m) | |
=> AudioConverter |
|
-> [AudioConverterFlags] |
|
-> Ptr () |
|
-> Word64 |
|
-> Ptr () |
|
-> Word64 |
|
-> m Bool | Returns: |
Perform the conversion with inFrames
in in
to outFrames
in out
using convert
.
In case the samples are interleaved, in
and out
must point to an
array with a single element pointing to a block of interleaved samples.
If non-interleaved samples are used, in
and out
must point to an
array with pointers to memory blocks, one for each channel.
in
may be Nothing
, in which case inFrames
of silence samples are processed
by the converter.
This function always produces outFrames
of output and consumes inFrames
of
input. Use audioConverterGetOutFrames
and
audioConverterGetInFrames
to make sure inFrames
and outFrames
are matching and in
and out
point to enough memory.
supportsInplace
audioConverterSupportsInplace Source #
:: (HasCallStack, MonadIO m) | |
=> AudioConverter |
|
-> m Bool | Returns: |
Returns whether the audio converter can perform the conversion in-place.
The return value would be typically input to baseTransformSetInPlace
updateConfig
audioConverterUpdateConfig Source #
:: (HasCallStack, MonadIO m) | |
=> AudioConverter |
|
-> Int32 |
|
-> Int32 |
|
-> Maybe Structure | |
-> m Bool | Returns: |
Set inRate
, outRate
and config
as extra configuration for convert
.
inRate
and outRate
specify the new sample rates of input and output
formats. A value of 0 leaves the sample rate unchanged.
config
can be Nothing
, in which case, the current configuration is not
changed.
If the parameters in config
can not be set exactly, this function returns
False
and will try to update as much state as possible. The new state can
then be retrieved and refined with audioConverterGetConfig
.
Look at the GST_AUDIO_CONVERTER_OPT_
* fields to check valid configuration
option and values.