Module: GstAudio

Defined in:
lib/gst/audio-loader.rb

Overview

Copyright (C) 2024 Ruby-GNOME Project Team

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

Defined Under Namespace

Modules: AudioBaseSinkDiscontReason, AudioBaseSinkSlaveMethod, AudioBaseSrcSlaveMethod, AudioCdSrcMode, AudioChannelMixerFlags, AudioChannelPosition, AudioConverterFlags, AudioDitherMethod, AudioFlags, AudioFormat, AudioFormatFlags, AudioLayout, AudioNoiseShapingMethod, AudioPackFlags, AudioQuantizeFlags, AudioResamplerFilterInterpolation, AudioResamplerFilterMode, AudioResamplerFlags, AudioResamplerMethod, AudioRingBufferFormatType, AudioRingBufferState, DsdFormat, StreamVolume, StreamVolumeFormat Classes: AudioAggregator, AudioAggregatorConvertPad, AudioAggregatorPad, AudioBaseSink, AudioBaseSrc, AudioCdSrc, AudioClock, AudioDecoder, AudioEncoder, AudioFilter, AudioRingBuffer, AudioSink, AudioSrc, Loader

Constant Summary collapse

AUDIO_CHANNELS_RANGE =

Maximum range of allowed channels, for use in template caps strings.

(int) [ 1, max ]
AUDIO_CONVERTER_OPT_DITHER_METHOD =

Gst::AudioDitherMethod, The dither method to use when changing bit depth. Default is #GST_AUDIO_DITHER_NONE.

GstAudioConverter.dither-method
AUDIO_CONVERTER_OPT_DITHER_THRESHOLD =

Threshold for the output bit depth at/below which to apply dithering.

Default is 20 bit.

GstAudioConverter.dither-threshold
AUDIO_CONVERTER_OPT_MIX_MATRIX =

#GST_TYPE_LIST, The channel mapping matrix.

The matrix coefficients must be between -1 and 1: the number of rows is equal to the number of output channels and the number of columns is equal to the number of input channels.

Example matrix generation code

To generate the matrix using code:

|[ GValue v = G_VALUE_INIT; GValue v2 = G_VALUE_INIT; GValue v3 = G_VALUE_INIT;

g_value_init (&v2, GST_TYPE_ARRAY); g_value_init (&v3, G_TYPE_DOUBLE); g_value_set_double (&v3, 1); gst_value_array_append_value (&v2, &v3); g_value_unset (&v3); [ Repeat for as many double as your input channels - unset and reinit v3 ] g_value_init (&v, GST_TYPE_ARRAY); gst_value_array_append_value (&v, &v2); g_value_unset (&v2); [ Repeat for as many v2's as your output channels - unset and reinit v2] g_object_set_property (G_OBJECT (audiomixmatrix), "matrix", &v); g_value_unset (&v); ]|

GstAudioConverter.mix-matrix
AUDIO_CONVERTER_OPT_NOISE_SHAPING_METHOD =

Gst::AudioNoiseShapingMethod, The noise shaping method to use to mask noise from quantization errors. Default is #GST_AUDIO_NOISE_SHAPING_NONE.

GstAudioConverter.noise-shaping-method
AUDIO_CONVERTER_OPT_QUANTIZATION =

#G_TYPE_UINT, The quantization amount. Components will be quantized to multiples of this value. Default is 1

GstAudioConverter.quantization
AUDIO_CONVERTER_OPT_RESAMPLER_METHOD =

Gst::AudioResamplerMethod, The resampler method to use when changing sample rates. Default is #GST_AUDIO_RESAMPLER_METHOD_BLACKMAN_NUTTALL.

GstAudioConverter.resampler-method
AUDIO_DECODER_MAX_ERRORS =

Default maximum number of errors tolerated before signaling error.

-1
AUDIO_DECODER_SINK_NAME =

The name of the templates for the sink pad.

sink
AUDIO_DECODER_SRC_NAME =

The name of the templates for the source pad.

src
AUDIO_DEF_CHANNELS =

Standard number of channels used in consumer audio.

2
AUDIO_DEF_FORMAT =

Standard format used in consumer audio.

S16LE
AUDIO_DEF_RATE =

Standard sampling rate used in consumer audio.

44100
AUDIO_ENCODER_SINK_NAME =

the name of the templates for the sink pad

sink
AUDIO_ENCODER_SRC_NAME =

the name of the templates for the source pad

src
AUDIO_FORMATS_ALL =

List of all audio formats, for use in template caps strings.

Formats are sorted by decreasing "quality", using these criteria by priority:

  • depth
  • width
  • Float > Signed > Unsigned
  • native endianness preferred
{ F64BE, F64LE, F32BE, F32LE, S32BE, S32LE, U32BE, U32LE, S24_32BE, S24_32LE, U24_32BE, U24_32LE, S24BE, S24LE, U24BE, U24LE, S20BE, S20LE, U20BE, U20LE, S18BE, S18LE, U18BE, U18LE, S16BE, S16LE, U16BE, U16LE, S8, U8 }
AUDIO_RATE_RANGE =

Maximum range of allowed sample rates, for use in template caps strings.

(int) [ 1, max ]
AUDIO_RESAMPLER_OPT_CUBIC_B =

G_TYPE_DOUBLE, B parameter of the cubic filter. Values between 0.0 and 2.0 are accepted. 1.0 is the default.

Below are some values of popular filters: B C Hermite 0.0 0.0 Spline 1.0 0.0 Catmull-Rom 0.0 1/2

GstAudioResampler.cubic-b
AUDIO_RESAMPLER_OPT_CUBIC_C =

G_TYPE_DOUBLE, C parameter of the cubic filter. Values between 0.0 and 2.0 are accepted. 0.0 is the default.

See #GST_AUDIO_RESAMPLER_OPT_CUBIC_B for some more common values

GstAudioResampler.cubic-c
AUDIO_RESAMPLER_OPT_CUTOFF =

G_TYPE_DOUBLE, Cutoff parameter for the filter. 0.940 is the default.

GstAudioResampler.cutoff
AUDIO_RESAMPLER_OPT_FILTER_INTERPOLATION =

GST_TYPE_AUDIO_RESAMPLER_INTERPOLATION: how the filter coefficients should be interpolated. GST_AUDIO_RESAMPLER_FILTER_INTERPOLATION_CUBIC is default.

GstAudioResampler.filter-interpolation
AUDIO_RESAMPLER_OPT_FILTER_MODE =

GST_TYPE_AUDIO_RESAMPLER_FILTER_MODE: how the filter tables should be constructed. GST_AUDIO_RESAMPLER_FILTER_MODE_AUTO is the default.

GstAudioResampler.filter-mode
AUDIO_RESAMPLER_OPT_FILTER_MODE_THRESHOLD =

G_TYPE_UINT: the amount of memory to use for full filter tables before switching to interpolated filter tables. 1048576 is the default.

GstAudioResampler.filter-mode-threshold
AUDIO_RESAMPLER_OPT_FILTER_OVERSAMPLE =

G_TYPE_UINT, oversampling to use when interpolating filters 8 is the default.

GstAudioResampler.filter-oversample
AUDIO_RESAMPLER_OPT_MAX_PHASE_ERROR =

G_TYPE_DOUBLE: The maximum allowed phase error when switching sample rates. 0.1 is the default.

GstAudioResampler.max-phase-error
AUDIO_RESAMPLER_OPT_N_TAPS =

G_TYPE_INT: the number of taps to use for the filter. 0 is the default and selects the taps automatically.

GstAudioResampler.n-taps
AUDIO_RESAMPLER_OPT_STOP_ATTENUATION =

G_TYPE_DOUBLE, stopband attenuation in decibels. The attenuation after the stopband for the kaiser window. 85 dB is the default.

GstAudioResampler.stop-attenutation
AUDIO_RESAMPLER_OPT_TRANSITION_BANDWIDTH =

G_TYPE_DOUBLE, transition bandwidth. The width of the transition band for the kaiser window. 0.087 is the default.

GstAudioResampler.transition-bandwidth
AUDIO_RESAMPLER_QUALITY_DEFAULT =
4
AUDIO_RESAMPLER_QUALITY_MAX =
10
AUDIO_RESAMPLER_QUALITY_MIN =
0
DSD_FORMATS_ALL =

List of all DSD formats, for use in template caps strings.

Big endian formats are preferred, since little-endian ones flip around the DSD bytes, and most DSD hardware uses big endian formats.

{ DSDU32BE, DSDU16BE, DSDU8, DSDU32LE, DSDU16LE }
DSD_MEDIA_TYPE =

The GStreamer media type for DSD.

audio/x-dsd
DSD_SILENCE_PATTERN_BYTE =

Silence pattern for DSD data.

In DSD, a nullbyte does not correspond to silence. To fill memory regions with "DSD silence", these regions must be filled with byte 0x69 instead (this is the DSD silence pattern). This constant provides that pattern in a more readable fashion.

105
META_TAG_AUDIO_CHANNELS_STR =

This metadata stays relevant as long as channels are unchanged.

channels
META_TAG_AUDIO_RATE_STR =

This metadata stays relevant as long as sample rate is unchanged.

rate
META_TAG_AUDIO_STR =

This metadata is relevant for audio streams.

audio
META_TAG_DSD_PLANE_OFFSETS_STR =

This metadata stays relevant as long as the DSD plane offsets are unchanged.

dsdplaneoffsets

Instance Method Summary collapse

Instance Method Details

#audio_buffer_clip(buffer, segment, rate, bpf) ⇒ Gst::Buffer

Clip the buffer to the given %GstSegment.

After calling this function the caller does not own a reference to buffer anymore. number of channels. otherwise the clipped buffer is returned.

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

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 (Integer)

    sample rate.

  • bpf (Integer)

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

Returns:

  • (Gst::Buffer)

    nil if the buffer is completely outside the configured segment,

#audio_buffer_map(buffer, info, gstbuffer, flags) ⇒ Boolean

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

If a Gst::AudioMeta 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 Gst::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:

  • buffer (GstAudio::AudioBuffer)

    pointer to a Gst::AudioBuffer

  • 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:

  • (Boolean)

    true if the map operation succeeded or false on failure

#audio_buffer_reorder_channels(buffer, format, channels, from, to) ⇒ Boolean

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:

Returns:

  • (Boolean)

    true if the reordering was possible.

#audio_buffer_truncate(buffer, bpf, trim, samples) ⇒ Gst::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. number of channels. to use all the remaining samples if you are only removing samples from the beginning.

Parameters:

  • buffer (Gst::Buffer)

    The buffer to truncate.

  • bpf (Integer)

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

  • trim (Integer)

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

  • samples (Integer)

    the final number of samples that should exist in this buffer or -1

Returns:

#audio_channel_get_fallback_mask(channels) ⇒ Integer

Get the fallback channel-mask for the given number of channels.

This function returns a reasonable fallback channel-mask and should be called as a last resort when the specific channel map is unknown. mask and mono.

Parameters:

  • channels (Integer)

    the number of channels

Returns:

  • (Integer)

    a fallback channel-mask for channels or 0 when there is no

#audio_channel_mixer_new(flags, format, in_channels, in_position, out_channels, out_position) ⇒ GstAudio::AudioChannelMixer

Create a new channel mixer object for the given parameters.

Parameters:

Returns:

  • (GstAudio::AudioChannelMixer)

    a new Gst::AudioChannelMixer object. Free with gst_audio_channel_mixer_free() after usage.

#audio_channel_mixer_new_with_matrix(flags, format, in_channels, out_channels, matrix) ⇒ GstAudio::AudioChannelMixer

Create a new channel mixer object for the given parameters.

Parameters:

  • flags (GstAudio::AudioChannelMixerFlags)

    Gst::AudioChannelMixerFlags

  • format (GstAudio::AudioFormat)
  • in_channels (Integer)

    number of input channels

  • out_channels (Integer)

    number of output channels

  • matrix (GstAudio::gfloat)

    channel conversion matrix, m[in_channels][out_channels]. If identity matrix, passthrough applies. If nil, a (potentially truncated) identity matrix is generated.

Returns:

  • (GstAudio::AudioChannelMixer)

    a new Gst::AudioChannelMixer object. Free with gst_audio_channel_mixer_free() after usage.

#audio_channel_positions_from_mask(channels, channel_mask, position) ⇒ Boolean

Convert the channels present in channel_mask to a position array (which should have at least channels entries ensured by caller). If channel_mask is set to 0, it is considered as 'not present' for purpose of conversion. A partially valid channel_mask with less bits set than the number of channels is considered valid.

Parameters:

  • channels (Integer)

    The number of channels

  • channel_mask (Integer)

    The input channel_mask

  • position (Array<GstAudio::AudioChannelPosition>)

    The %GstAudioChannelPositions

Returns:

  • (Boolean)

    true if channel and channel mask are valid and could be converted

#audio_channel_positions_to_mask(position, channels, force_order, channel_mask) ⇒ Boolean

Convert the position array of channels channels to a bitmask.

If force_order is true it additionally checks if the channels are in the order required by GStreamer.

Parameters:

  • position (Array<GstAudio::AudioChannelPosition>)

    The %GstAudioChannelPositions

  • channels (Integer)

    The number of channels.

  • force_order (Boolean)

    Only consider the GStreamer channel order.

  • channel_mask (Integer)

    the output channel mask

Returns:

  • (Boolean)

    true if the channel positions are valid and could be converted.

#audio_channel_positions_to_string(position, channels) ⇒ String

Converts position to a human-readable string representation for debugging purposes. position

Parameters:

Returns:

  • (String)

    a newly allocated string representing

#audio_channel_positions_to_valid_order(position, channels) ⇒ Boolean

Reorders the channel positions in position from any order to the GStreamer channel order. was successful.

Parameters:

Returns:

  • (Boolean)

    true if the channel positions are valid and reordering

#audio_check_valid_channel_positions(position, channels, force_order) ⇒ Boolean

Checks if position contains valid channel positions for channels channels. If force_order is true it additionally checks if the channels are in the order required by GStreamer.

Parameters:

  • position (Array<GstAudio::AudioChannelPosition>)

    The %GstAudioChannelPositions to check.

  • channels (Integer)

    The number of channels.

  • force_order (Boolean)

    Only consider the GStreamer channel order.

Returns:

  • (Boolean)

    true if the channel positions are valid.

#audio_clipping_meta_api_get_typeGLib::Type

Returns:

  • (GLib::Type)

#audio_clipping_meta_get_infoGst::MetaInfo

Returns:

  • (Gst::MetaInfo)

#audio_downmix_meta_api_get_typeGLib::Type

Returns:

  • (GLib::Type)

#audio_downmix_meta_get_infoGst::MetaInfo

Returns:

  • (Gst::MetaInfo)

#audio_format_build_integer(sign, endianness, width, depth) ⇒ GstAudio::AudioFormat

Construct a Gst::AudioFormat with given parameters. exists with the given parameters.

Parameters:

  • sign (Boolean)

    signed or unsigned format

  • endianness (Integer)

    G_LITTLE_ENDIAN or G_BIG_ENDIAN

  • width (Integer)

    amount of bits used per sample

  • depth (Integer)

    amount of used bits in width

Returns:

#audio_format_fill_silence(info, dest, length) ⇒ nil

Fill length bytes in dest with silence samples for info.

Parameters:

  • info (GstAudio::AudioFormatInfo)

    a Gst::AudioFormatInfo

  • dest (Array<Integer>)

    a destination to fill

  • length (Integer)

    the length to fill

Returns:

  • (nil)

#audio_format_from_string(format) ⇒ GstAudio::AudioFormat

Convert the format string to its Gst::AudioFormat. string is not a known format.

Parameters:

  • format (String)

    a format string

Returns:

#audio_format_get_info(format) ⇒ GstAudio::AudioFormatInfo

Get the Gst::AudioFormatInfo for format

Parameters:

Returns:

  • (GstAudio::AudioFormatInfo)

    The Gst::AudioFormatInfo for format.

#audio_format_info_get_typeGLib::Type

Returns:

  • (GLib::Type)

#audio_format_to_string(format) ⇒ String

Parameters:

Returns:

  • (String)

#audio_formats_raw(len) ⇒ Array<GstAudio::AudioFormat>

Return all the raw audio formats supported by GStreamer.

Parameters:

  • len (Integer)

    the number of elements in the returned array

Returns:

#audio_get_channel_reorder_map(channels, from, to, reorder_map) ⇒ Boolean

Returns a reorder map for from to to that can be used in custom channel reordering code, e.g. to convert from or to the GStreamer channel order. from and to must contain the same number of positions and the same positions, only in a different order.

The resulting reorder_map can be used for reordering by assigning channel i of the input to channel reorder_map[i] of the output. is possible.

Parameters:

Returns:

  • (Boolean)

    true if the channel positions are valid and reordering

#audio_iec61937_frame_size(spec) ⇒ Integer

Calculated the size of the buffer expected by gst_audio_iec61937_payload() for payloading type from spec. payloaded.

Parameters:

  • spec (GstAudio::AudioRingBufferSpec)

    the ringbufer spec

Returns:

  • (Integer)

    the size or 0 if the given type is not supported or cannot be

#audio_iec61937_payload(src, src_n, dst, dst_n, spec, endianness) ⇒ Boolean

Payloads src in the form specified by IEC 61937 for the type from spec and stores the result in dst. src must contain exactly one frame of data and the frame is not checked for errors. otherwise.

Parameters:

  • src (Array<Integer>)

    a buffer containing the data to payload

  • src_n (Integer)

    size of src in bytes

  • dst (Array<Integer>)

    the destination buffer to store the payloaded contents in. Should not overlap with src

  • dst_n (Integer)

    size of dst in bytes

  • spec (GstAudio::AudioRingBufferSpec)

    the ringbufer spec for src

  • endianness (Integer)

    the expected byte order of the payloaded data

Returns:

  • (Boolean)

    transfer-full: true if the payloading was successful, false

#audio_info_from_caps(info, caps) ⇒ Boolean

Parse caps and update info.

Parameters:

  • info (GstAudio::AudioInfo)

    a Gst::AudioInfo

  • caps (Gst::Caps)

    a Gst::Caps

Returns:

  • (Boolean)

    TRUE if caps could be parsed

#audio_info_init(info) ⇒ nil

Initialize info with default values.

Parameters:

  • info (GstAudio::AudioInfo)

    a Gst::AudioInfo

Returns:

  • (nil)

#audio_level_meta_api_get_typeGLib::Type

Return the #GType associated with Gst::AudioLevelMeta.

Returns:

  • (GLib::Type)

    a #GType

#audio_level_meta_get_infoGst::MetaInfo

Return the Gst::MetaInfo associated with #GstAudioLevelMeta.

Returns:

  • (Gst::MetaInfo)

    a Gst::MetaInfo

#audio_make_raw_caps(formats, len, layout) ⇒ Gst::Caps

Return a generic raw audio caps for formats defined in formats. If formats is nil returns a caps for all the supported raw audio formats, see gst_audio_formats_raw().

Parameters:

Returns:

#audio_meta_api_get_typeGLib::Type

Returns:

  • (GLib::Type)

#audio_meta_get_infoGst::MetaInfo

Returns:

  • (Gst::MetaInfo)

#audio_quantize_new(dither, ns, flags, format, channels, quantizer) ⇒ GstAudio::AudioQuantize

Create a new quantizer object with the given parameters.

Output samples will be quantized to a multiple of quantizer. Better performance is achieved when quantizer is a power of 2.

Dithering and noise-shaping can be performed during quantization with the dither and ns parameters.

Parameters:

Returns:

  • (GstAudio::AudioQuantize)

    a new Gst::AudioQuantize. Free with gst_audio_quantize_free().

#audio_reorder_channels(data, size, format, channels, from, to) ⇒ Boolean

Reorders data 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.

Note: this function assumes the audio data is in interleaved layout

Parameters:

Returns:

  • (Boolean)

    true if the reordering was possible.

#audio_resampler_new(method, flags, format, channels, in_rate, out_rate, options) ⇒ GstAudio::AudioResampler

Make a new resampler.

Parameters:

Returns:

  • (GstAudio::AudioResampler)

    The new Gst::AudioResampler.

#audio_resampler_options_set_quality(method, quality, in_rate, out_rate, options) ⇒ nil

Set the parameters for resampling from in_rate to out_rate using method for quality in options.

Parameters:

  • method (GstAudio::AudioResamplerMethod)

    a Gst::AudioResamplerMethod

  • quality (Integer)

    the quality

  • in_rate (Integer)

    the input rate

  • out_rate (Integer)

    the output rate

  • options (Gst::Structure)

    a Gst::Structure

Returns:

  • (nil)

#buffer_add_audio_clipping_meta(buffer, format, start, end) ⇒ GstAudio::AudioClippingMeta

Attaches Gst::AudioClippingMeta metadata to buffer with the given parameters.

Parameters:

  • buffer (Gst::Buffer)

    a Gst::Buffer

  • format (Gst::Format)

    GstFormat of start and stop, GST_FORMAT_DEFAULT is samples

  • start (Integer)

    Amount of audio to clip from start of buffer

  • end (Integer)

    Amount of to clip from end of buffer

Returns:

  • (GstAudio::AudioClippingMeta)

    the Gst::AudioClippingMeta on buffer.

#buffer_add_audio_downmix_meta(buffer, from_position, from_channels, to_position, to_channels, matrix) ⇒ GstAudio::AudioDownmixMeta

Attaches Gst::AudioDownmixMeta metadata to buffer with the given parameters.

matrix is an two-dimensional array of to_channels times from_channels coefficients, i.e. the i-th output channels is constructed by multiplicating the input channels with the coefficients in matrix[i] and taking the sum of the results.

Parameters:

  • buffer (Gst::Buffer)

    a Gst::Buffer

  • from_position (Array<GstAudio::AudioChannelPosition>)

    the channel positions of the source

  • from_channels (Integer)

    The number of channels of the source

  • to_position (Array<GstAudio::AudioChannelPosition>)

    the channel positions of the destination

  • to_channels (Integer)

    The number of channels of the destination

  • matrix (GstAudio::gfloat)

    The matrix coefficients.

Returns:

  • (GstAudio::AudioDownmixMeta)

    the Gst::AudioDownmixMeta on buffer.

#buffer_add_audio_level_meta(buffer, level, voice_activity) ⇒ GstAudio::AudioLevelMeta

Attaches audio level information to buffer. (RFC 6464)

Parameters:

  • buffer (Gst::Buffer)

    a Gst::Buffer

  • level (Integer)

    the -dBov from 0-127 (127 is silence).

  • voice_activity (Boolean)

    whether the buffer contains voice activity.

Returns:

  • (GstAudio::AudioLevelMeta)

    the Gst::AudioLevelMeta on buffer.

#buffer_add_audio_meta(buffer, info, samples, offsets) ⇒ GstAudio::AudioMeta

Allocates and attaches a Gst::AudioMeta on buffer, which must be writable for that purpose. The fields of the Gst::AudioMeta are directly populated from the arguments of this function.

When info->layout is %GST_AUDIO_LAYOUT_NON_INTERLEAVED and offsets is nil, the offsets are calculated with a formula that assumes the planes are tightly packed and in sequence: offsets[channel] = channel * samples * sample_stride

It is not allowed for channels to overlap in memory, i.e. for each i in [0, channels), the range [offsets[i], offsets[i] + samples * sample_stride) must not overlap with any other such range. This function will assert if the parameters specified cause this restriction to be violated.

It is, obviously, also not allowed to specify parameters that would cause out-of-bounds memory access on buffer. This is also checked, which means that you must add enough memory on the buffer before adding this meta.

Parameters:

  • buffer (Gst::Buffer)

    a Gst::Buffer

  • info (GstAudio::AudioInfo)

    the audio properties of the buffer

  • samples (Integer)

    the number of valid samples in the buffer

  • offsets (Integer)

    the offsets (in bytes) where each channel plane starts in the buffer or nil to calculate it (see below); must be nil also when info->layout is %GST_AUDIO_LAYOUT_INTERLEAVED

Returns:

  • (GstAudio::AudioMeta)

    the Gst::AudioMeta that was attached on the buffer

#buffer_add_dsd_plane_offset_meta(buffer, num_channels, num_bytes_per_channel, offsets) ⇒ GstAudio::DsdPlaneOffsetMeta

Allocates and attaches a Gst::DsdPlaneOffsetMeta on buffer, which must be writable for that purpose. The fields of the Gst::DsdPlaneOffsetMeta are directly populated from the arguments of this function.

If offsets is NULL, then the meta's offsets field is left uninitialized. This is useful if for example offset values are to be calculated in the meta's offsets field in-place. Similarly, num_bytes_per_channel can be set to 0, but only if offsets is NULL. This is useful if the number of bytes per channel is known only later.

It is not allowed for channels to overlap in memory, i.e. for each i in [0, channels), the range [offsets[i], offsets[i] + num_bytes_per_channel) must not overlap with any other such range. This function will assert if the parameters specified cause this restriction to be violated.

It is, obviously, also not allowed to specify parameters that would cause out-of-bounds memory access on buffer. This is also checked, which means that you must add enough memory on the buffer before adding this meta.

This meta is only needed for non-interleaved (= planar) DSD data.

Parameters:

  • buffer (Gst::Buffer)

    a Gst::Buffer

  • num_channels (Integer)

    Number of channels in the DSD data

  • num_bytes_per_channel (Integer)

    Number of bytes per channel

  • offsets (Integer)

    the offsets (in bytes) where each channel plane starts in the buffer

Returns:

  • (GstAudio::DsdPlaneOffsetMeta)

    the Gst::DsdPlaneOffsetMeta that was attached on the buffer

#buffer_get_audio_downmix_meta_for_channels(buffer, to_position, to_channels) ⇒ GstAudio::AudioDownmixMeta

Find the Gst::AudioDownmixMeta on buffer for the given destination channel positions.

Parameters:

  • buffer (Gst::Buffer)

    a Gst::Buffer

  • to_position (Array<GstAudio::AudioChannelPosition>)

    the channel positions of the destination

  • to_channels (Integer)

    The number of channels of the destination

Returns:

  • (GstAudio::AudioDownmixMeta)

    the Gst::AudioDownmixMeta on buffer.

#buffer_get_audio_level_meta(buffer) ⇒ GstAudio::AudioLevelMeta

Find the Gst::AudioLevelMeta on buffer. there is no such metadata on buffer.

Parameters:

Returns:

  • (GstAudio::AudioLevelMeta)

    the Gst::AudioLevelMeta or nil when

#dsd_convert(input_data, output_data, input_format, output_format, input_layout, output_layout, input_plane_offsets, output_plane_offsets, num_dsd_bytes, num_channels, reverse_byte_bits) ⇒ nil

Converts DSD data from one layout and grouping format to another. num_bytes must be an integer multiple of the width of both input and output format. For example, if the input format is GST_DSD_FORMAT_U32LE, and the output format is GST_DSD_FORMAT_U16BE, then num_bytes must be an integer multiple of both 4 (U32LE width) and 2 (U16BE width).

reverse_byte_bits is necessary if the bit order within the DSD bytes needs to be reversed. This is rarely necessary, and is not to be confused with the endianness of formats (which determines the ordering of bytes).

input_plane_offsets must not be NULL if input_layout is set to #GST_AUDIO_LAYOUT_NON_INTERLEAVED. The same applies to output_plane_offsets. These plane offsets define the starting offset of the planes (there is exactly one plane per channel) within input_data and output_data respectively. If GST_AUDIO_LAYOUT_INTERLEAVED is used, the plane offsets are ignored.

Parameters:

  • input_data (Integer)

    the DSD format conversion's input source

  • output_data (Integer)

    the DSD format conversion's output destination

  • input_format (GstAudio::DsdFormat)

    DSD format of the input data to convert from

  • output_format (GstAudio::DsdFormat)

    DSD format of the output data to convert to

  • input_layout (GstAudio::AudioLayout)

    Input data layout

  • output_layout (GstAudio::AudioLayout)

    Output data layout

  • input_plane_offsets (Integer)

    Plane offsets for non-interleaved input data

  • output_plane_offsets (Integer)

    Plane offsets for non-interleaved output data

  • num_dsd_bytes (Integer)

    How many bytes with DSD data to convert

  • num_channels (Integer)

    Number of channels (must be at least 1)

  • reverse_byte_bits (Boolean)

    If TRUE, reverse the bits in each DSD byte

Returns:

  • (nil)

#dsd_format_from_string(str) ⇒ GstAudio::DsdFormat

Convert the DSD format string str to its Gst::DsdFormat. string is not a known format.

Parameters:

  • str (String)

    a DSD format string

Returns:

#dsd_format_get_width(format) ⇒ Integer

Returns Number of bytes in this DSD grouping format.

Parameters:

Returns:

  • (Integer)

    Number of bytes in this DSD grouping format.

#dsd_format_to_string(format) ⇒ String

Returns a string containing a descriptive name for the Gst::DsdFormat if there is one, or NULL otherwise.

Parameters:

Returns:

  • (String)

    the name corresponding to format

#dsd_info_from_caps(info, caps) ⇒ Boolean

Parse caps and update info.

Parameters:

  • info (GstAudio::DsdInfo)

    a Gst::DsdInfo

  • caps (Gst::Caps)

    a Gst::Caps

Returns:

  • (Boolean)

    TRUE if caps could be parsed

#dsd_info_init(info) ⇒ nil

Initialize info with default values.

Parameters:

  • info (GstAudio::DsdInfo)

    a Gst::DsdInfo

Returns:

  • (nil)

#dsd_plane_offset_meta_api_get_typeGLib::Type

Returns:

  • (GLib::Type)

#dsd_plane_offset_meta_get_infoGst::MetaInfo

Returns:

  • (Gst::MetaInfo)

#stream_volume_convert_volume(from, to, val) ⇒ Float

Returns the converted volume.

Parameters:

Returns:

  • (Float)

    the converted volume