GstAudioConverter
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
Constructors
gst_audio_converter_new
GstAudioConverter * gst_audio_converter_new (GstAudioConverterFlags flags, GstAudioInfo * in_info, GstAudioInfo * out_info, GstStructure * config)
Create a new GstAudioConverter 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.
Parameters:
flags
–
extra GstAudioConverterFlags
in_info
–
a source GstAudioInfo
out_info
–
a destination GstAudioInfo
config
(
[transfer: full][nullable])
–
a GstStructure with configuration options
a GstAudioConverter or NULL if conversion is not possible.
GstAudio.AudioConverter.prototype.new
function GstAudio.AudioConverter.prototype.new(flags: GstAudio.AudioConverterFlags, in_info: GstAudio.AudioInfo, out_info: GstAudio.AudioInfo, config: Gst.Structure): {
// javascript wrapper for 'gst_audio_converter_new'
}
Create a new GstAudio.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.
Parameters:
a source GstAudio.AudioInfo
a destination GstAudio.AudioInfo
a Gst.Structure with configuration options
a GstAudio.AudioConverter or null if conversion is not possible.
GstAudio.AudioConverter.new
def GstAudio.AudioConverter.new (flags, in_info, out_info, config):
#python wrapper for 'gst_audio_converter_new'
Create a new GstAudio.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.
Parameters:
a source GstAudio.AudioInfo
a destination GstAudio.AudioInfo
a Gst.Structure with configuration options
a GstAudio.AudioConverter or None if conversion is not possible.
Methods
gst_audio_converter_convert
gboolean gst_audio_converter_convert (GstAudioConverter * convert, GstAudioConverterFlags flags, gpointer in, gsize in_size, gpointer * out, gsize * out_size)
Convenience wrapper around gst_audio_converter_samples, which will perform allocation of the output buffer based on the result from gst_audio_converter_get_out_frames.
Parameters:
convert
–
flags
–
extra GstAudioConverterFlags
in
(
[arraylength=in_size][element-typeguint8])
–
input data
in_size
–
size of in
out
(
[out][arraylength=out_size][element-typeguint8])
–
a pointer where the output data will be written
out_size
(
[out])
–
a pointer where the size of out will be written
TRUE is the conversion could be performed.
Since : 1.14
GstAudio.AudioConverter.prototype.convert
function GstAudio.AudioConverter.prototype.convert(flags: GstAudio.AudioConverterFlags, in: [ Number ], in_size: Number): {
// javascript wrapper for 'gst_audio_converter_convert'
}
Convenience wrapper around GstAudio.AudioConverter.prototype.samples, which will perform allocation of the output buffer based on the result from GstAudio.AudioConverter.prototype.get_out_frames.
Parameters:
input data
size of in
Returns a tuple made of:
Since : 1.14
GstAudio.AudioConverter.convert
def GstAudio.AudioConverter.convert (self, flags, in, in_size):
#python wrapper for 'gst_audio_converter_convert'
Convenience wrapper around GstAudio.AudioConverter.samples, which will perform allocation of the output buffer based on the result from GstAudio.AudioConverter.get_out_frames.
Parameters:
input data
size of in
Returns a tuple made of:
Since : 1.14
gst_audio_converter_free
gst_audio_converter_free (GstAudioConverter * convert)
Free a previously allocated convert instance.
Parameters:
convert
–
GstAudio.AudioConverter.prototype.free
function GstAudio.AudioConverter.prototype.free(): {
// javascript wrapper for 'gst_audio_converter_free'
}
Free a previously allocated convert instance.
Parameters:
GstAudio.AudioConverter.free
def GstAudio.AudioConverter.free (self):
#python wrapper for 'gst_audio_converter_free'
Free a previously allocated convert instance.
Parameters:
gst_audio_converter_get_config
const GstStructure * gst_audio_converter_get_config (GstAudioConverter * convert, gint * in_rate, gint * out_rate)
Get the current configuration of convert.
Parameters:
convert
–
in_rate
(
[out][optional])
–
result input rate
out_rate
(
[out][optional])
–
result output rate
(transfer none): a GstStructure that remains valid for as long as convert is valid or until gst_audio_converter_update_config is called.
GstAudio.AudioConverter.prototype.get_config
function GstAudio.AudioConverter.prototype.get_config(): {
// javascript wrapper for 'gst_audio_converter_get_config'
}
Get the current configuration of convert.
Parameters:
Returns a tuple made of:
(transfer none): a Gst.Structure that remains valid for as long as convert is valid or until GstAudio.AudioConverter.prototype.update_config is called.
(transfer none): a Gst.Structure that remains valid for as long as convert is valid or until GstAudio.AudioConverter.prototype.update_config is called.
(transfer none): a Gst.Structure that remains valid for as long as convert is valid or until GstAudio.AudioConverter.prototype.update_config is called.
GstAudio.AudioConverter.get_config
def GstAudio.AudioConverter.get_config (self):
#python wrapper for 'gst_audio_converter_get_config'
Get the current configuration of convert.
Parameters:
Returns a tuple made of:
(transfer none): a Gst.Structure that remains valid for as long as convert is valid or until GstAudio.AudioConverter.update_config is called.
(transfer none): a Gst.Structure that remains valid for as long as convert is valid or until GstAudio.AudioConverter.update_config is called.
(transfer none): a Gst.Structure that remains valid for as long as convert is valid or until GstAudio.AudioConverter.update_config is called.
gst_audio_converter_get_in_frames
gsize gst_audio_converter_get_in_frames (GstAudioConverter * convert, gsize out_frames)
Calculate how many input frames are currently needed by convert to produce out_frames of output frames.
the number of input frames
GstAudio.AudioConverter.prototype.get_in_frames
function GstAudio.AudioConverter.prototype.get_in_frames(out_frames: Number): {
// javascript wrapper for 'gst_audio_converter_get_in_frames'
}
Calculate how many input frames are currently needed by convert to produce out_frames of output frames.
Parameters:
number of output frames
the number of input frames
GstAudio.AudioConverter.get_in_frames
def GstAudio.AudioConverter.get_in_frames (self, out_frames):
#python wrapper for 'gst_audio_converter_get_in_frames'
Calculate how many input frames are currently needed by convert to produce out_frames of output frames.
Parameters:
number of output frames
the number of input frames
gst_audio_converter_get_max_latency
gsize gst_audio_converter_get_max_latency (GstAudioConverter * convert)
Get the maximum number of input frames that the converter would need before producing output.
Parameters:
convert
–
the latency of convert as expressed in the number of frames.
GstAudio.AudioConverter.prototype.get_max_latency
function GstAudio.AudioConverter.prototype.get_max_latency(): {
// javascript wrapper for 'gst_audio_converter_get_max_latency'
}
Get the maximum number of input frames that the converter would need before producing output.
Parameters:
the latency of convert as expressed in the number of frames.
GstAudio.AudioConverter.get_max_latency
def GstAudio.AudioConverter.get_max_latency (self):
#python wrapper for 'gst_audio_converter_get_max_latency'
Get the maximum number of input frames that the converter would need before producing output.
Parameters:
the latency of convert as expressed in the number of frames.
gst_audio_converter_get_out_frames
gsize gst_audio_converter_get_out_frames (GstAudioConverter * convert, gsize in_frames)
Calculate how many output frames can be produced when in_frames input frames are given to convert.
the number of output frames
GstAudio.AudioConverter.prototype.get_out_frames
function GstAudio.AudioConverter.prototype.get_out_frames(in_frames: Number): {
// javascript wrapper for 'gst_audio_converter_get_out_frames'
}
Calculate how many output frames can be produced when in_frames input frames are given to convert.
Parameters:
number of input frames
the number of output frames
GstAudio.AudioConverter.get_out_frames
def GstAudio.AudioConverter.get_out_frames (self, in_frames):
#python wrapper for 'gst_audio_converter_get_out_frames'
Calculate how many output frames can be produced when in_frames input frames are given to convert.
Parameters:
number of input frames
the number of output frames
gst_audio_converter_is_passthrough
gboolean gst_audio_converter_is_passthrough (GstAudioConverter * convert)
Returns whether the audio converter will operate in passthrough mode. The return value would be typically input to gst_base_transform_set_passthrough
Parameters:
convert
–
TRUE when no conversion will actually occur.
Since : 1.16
GstAudio.AudioConverter.prototype.is_passthrough
function GstAudio.AudioConverter.prototype.is_passthrough(): {
// javascript wrapper for 'gst_audio_converter_is_passthrough'
}
Returns whether the audio converter will operate in passthrough mode. The return value would be typically input to GstBase.BaseTransform.prototype.set_passthrough
Parameters:
Since : 1.16
GstAudio.AudioConverter.is_passthrough
def GstAudio.AudioConverter.is_passthrough (self):
#python wrapper for 'gst_audio_converter_is_passthrough'
Returns whether the audio converter will operate in passthrough mode. The return value would be typically input to GstBase.BaseTransform.set_passthrough
Parameters:
Since : 1.16
gst_audio_converter_reset
gst_audio_converter_reset (GstAudioConverter * convert)
Reset convert to the state it was when it was first created, clearing any history it might currently have.
Parameters:
convert
–
GstAudio.AudioConverter.prototype.reset
function GstAudio.AudioConverter.prototype.reset(): {
// javascript wrapper for 'gst_audio_converter_reset'
}
Reset convert to the state it was when it was first created, clearing any history it might currently have.
Parameters:
GstAudio.AudioConverter.reset
def GstAudio.AudioConverter.reset (self):
#python wrapper for 'gst_audio_converter_reset'
Reset convert to the state it was when it was first created, clearing any history it might currently have.
Parameters:
gst_audio_converter_samples
gboolean gst_audio_converter_samples (GstAudioConverter * convert, GstAudioConverterFlags flags, gpointer * in, gsize in_frames, gpointer * out, gsize out_frames)
Perform the conversion with in_frames in in to out_frames 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 NULL, in which case in_frames of silence samples are processed by the converter.
This function always produces out_frames of output and consumes in_frames of input. Use gst_audio_converter_get_out_frames and gst_audio_converter_get_in_frames to make sure in_frames and out_frames are matching and in and out point to enough memory.
Parameters:
convert
–
flags
–
extra GstAudioConverterFlags
in
–
input frames
in_frames
–
number of input frames
out
–
output frames
out_frames
–
number of output frames
TRUE is the conversion could be performed.
GstAudio.AudioConverter.prototype.samples
function GstAudio.AudioConverter.prototype.samples(flags: GstAudio.AudioConverterFlags, in: Object, in_frames: Number, out: Object, out_frames: Number): {
// javascript wrapper for 'gst_audio_converter_samples'
}
Perform the conversion with in_frames in in to out_frames 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 null, in which case in_frames of silence samples are processed by the converter.
This function always produces out_frames of output and consumes in_frames of input. Use GstAudio.AudioConverter.prototype.get_out_frames and GstAudio.AudioConverter.prototype.get_in_frames to make sure in_frames and out_frames are matching and in and out point to enough memory.
Parameters:
input frames
number of input frames
output frames
number of output frames
GstAudio.AudioConverter.samples
def GstAudio.AudioConverter.samples (self, flags, in, in_frames, out, out_frames):
#python wrapper for 'gst_audio_converter_samples'
Perform the conversion with in_frames in in to out_frames 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 None, in which case in_frames of silence samples are processed by the converter.
This function always produces out_frames of output and consumes in_frames of input. Use GstAudio.AudioConverter.get_out_frames and GstAudio.AudioConverter.get_in_frames to make sure in_frames and out_frames are matching and in and out point to enough memory.
Parameters:
input frames
number of input frames
output frames
number of output frames
gst_audio_converter_supports_inplace
gboolean gst_audio_converter_supports_inplace (GstAudioConverter * convert)
Returns whether the audio converter can perform the conversion in-place. The return value would be typically input to gst_base_transform_set_in_place
Parameters:
convert
–
TRUE when the conversion can be done in place.
Since : 1.12
GstAudio.AudioConverter.prototype.supports_inplace
function GstAudio.AudioConverter.prototype.supports_inplace(): {
// javascript wrapper for 'gst_audio_converter_supports_inplace'
}
Returns whether the audio converter can perform the conversion in-place. The return value would be typically input to GstBase.BaseTransform.prototype.set_in_place
Parameters:
Since : 1.12
GstAudio.AudioConverter.supports_inplace
def GstAudio.AudioConverter.supports_inplace (self):
#python wrapper for 'gst_audio_converter_supports_inplace'
Returns whether the audio converter can perform the conversion in-place. The return value would be typically input to GstBase.BaseTransform.set_in_place
Parameters:
Since : 1.12
gst_audio_converter_update_config
gboolean gst_audio_converter_update_config (GstAudioConverter * convert, gint in_rate, gint out_rate, GstStructure * config)
Set in_rate, out_rate and config as extra configuration for convert.
in_rate and out_rate specify the new sample rates of input and output formats. A value of 0 leaves the sample rate unchanged.
config can be NULL, 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 gst_audio_converter_get_config.
Look at the GST_AUDIO_CONVERTER_OPT_*
fields to check valid configuration
option and values.
Parameters:
convert
–
in_rate
–
input rate
out_rate
–
output rate
config
(
[transfer: full][allow-none])
–
a GstStructure or NULL
TRUE when the new parameters could be set
GstAudio.AudioConverter.prototype.update_config
function GstAudio.AudioConverter.prototype.update_config(in_rate: Number, out_rate: Number, config: Gst.Structure): {
// javascript wrapper for 'gst_audio_converter_update_config'
}
Set in_rate, out_rate and config as extra configuration for convert.
in_rate and out_rate specify the new sample rates of input and output formats. A value of 0 leaves the sample rate unchanged.
config can be null, 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 GstAudio.AudioConverter.prototype.get_config.
Look at the GST_AUDIO_CONVERTER_OPT_*
fields to check valid configuration
option and values.
GstAudio.AudioConverter.update_config
def GstAudio.AudioConverter.update_config (self, in_rate, out_rate, config):
#python wrapper for 'gst_audio_converter_update_config'
Set in_rate, out_rate and config as extra configuration for convert.
in_rate and out_rate specify the new sample rates of input and output formats. A value of 0 leaves the sample rate unchanged.
config can be None, 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 GstAudio.AudioConverter.get_config.
Look at the GST_AUDIO_CONVERTER_OPT_*
fields to check valid configuration
option and values.
Enumerations
GstAudioConverterFlags
Extra flags passed to gst_audio_converter_new and gst_audio_converter_samples.
Members
GST_AUDIO_CONVERTER_FLAG_NONE
(0)
–
no flag
GST_AUDIO_CONVERTER_FLAG_IN_WRITABLE
(1)
–
the input sample arrays are writable and can be used as temporary storage during conversion.
GST_AUDIO_CONVERTER_FLAG_VARIABLE_RATE
(2)
–
allow arbitrary rate updates with gst_audio_converter_update_config.
GstAudio.AudioConverterFlags
Extra flags passed to GstAudio.AudioConverter.prototype.new and GstAudio.AudioConverter.prototype.samples.
Members
GstAudio.AudioConverterFlags.NONE
(0)
–
no flag
GstAudio.AudioConverterFlags.IN_WRITABLE
(1)
–
the input sample arrays are writable and can be used as temporary storage during conversion.
GstAudio.AudioConverterFlags.VARIABLE_RATE
(2)
–
allow arbitrary rate updates with GstAudio.AudioConverter.prototype.update_config.
GstAudio.AudioConverterFlags
Extra flags passed to GstAudio.AudioConverter.new and GstAudio.AudioConverter.samples.
Members
GstAudio.AudioConverterFlags.NONE
(0)
–
no flag
GstAudio.AudioConverterFlags.IN_WRITABLE
(1)
–
the input sample arrays are writable and can be used as temporary storage during conversion.
GstAudio.AudioConverterFlags.VARIABLE_RATE
(2)
–
allow arbitrary rate updates with GstAudio.AudioConverter.update_config.
Constants
GST_AUDIO_CONVERTER_OPT_DITHER_METHOD
#define GST_AUDIO_CONVERTER_OPT_DITHER_METHOD "GstAudioConverter.dither-method"
GstAudioDitherMethod, The dither method to use when changing bit depth. Default is GST_AUDIO_DITHER_NONE.
GstAudio.AUDIO_CONVERTER_OPT_DITHER_METHOD
GstAudio.AudioDitherMethod, The dither method to use when changing bit depth. Default is GstAudio.AudioDitherMethod.NONE.
GstAudio.AUDIO_CONVERTER_OPT_DITHER_METHOD
GstAudio.AudioDitherMethod, The dither method to use when changing bit depth. Default is GstAudio.AudioDitherMethod.NONE.
GST_AUDIO_CONVERTER_OPT_DITHER_THRESHOLD
#define GST_AUDIO_CONVERTER_OPT_DITHER_THRESHOLD "GstAudioConverter.dither-threshold"
Threshold for the output bit depth at/below which to apply dithering.
Default is 20 bit.
Since : 1.22
GstAudio.AUDIO_CONVERTER_OPT_DITHER_THRESHOLD
Threshold for the output bit depth at/below which to apply dithering.
Default is 20 bit.
Since : 1.22
GstAudio.AUDIO_CONVERTER_OPT_DITHER_THRESHOLD
Threshold for the output bit depth at/below which to apply dithering.
Default is 20 bit.
Since : 1.22
GST_AUDIO_CONVERTER_OPT_MIX_MATRIX
#define GST_AUDIO_CONVERTER_OPT_MIX_MATRIX "GstAudioConverter.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);
GstAudio.AUDIO_CONVERTER_OPT_MIX_MATRIX
GST_TYPE_LIST (not introspectable), 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);
GstAudio.AUDIO_CONVERTER_OPT_MIX_MATRIX
GST_TYPE_LIST (not introspectable), 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);
GST_AUDIO_CONVERTER_OPT_NOISE_SHAPING_METHOD
#define GST_AUDIO_CONVERTER_OPT_NOISE_SHAPING_METHOD "GstAudioConverter.noise-shaping-method"
GstAudioNoiseShapingMethod, The noise shaping method to use to mask noise from quantization errors. Default is GST_AUDIO_NOISE_SHAPING_NONE.
GstAudio.AUDIO_CONVERTER_OPT_NOISE_SHAPING_METHOD
GstAudio.AudioNoiseShapingMethod, The noise shaping method to use to mask noise from quantization errors. Default is GstAudio.AudioNoiseShapingMethod.NONE.
GstAudio.AUDIO_CONVERTER_OPT_NOISE_SHAPING_METHOD
GstAudio.AudioNoiseShapingMethod, The noise shaping method to use to mask noise from quantization errors. Default is GstAudio.AudioNoiseShapingMethod.NONE.
GST_AUDIO_CONVERTER_OPT_QUANTIZATION
#define GST_AUDIO_CONVERTER_OPT_QUANTIZATION "GstAudioConverter.quantization"
G_TYPE_UINT, The quantization amount. Components will be quantized to multiples of this value. Default is 1
GstAudio.AUDIO_CONVERTER_OPT_QUANTIZATION
G_TYPE_UINT (not introspectable), The quantization amount. Components will be quantized to multiples of this value. Default is 1
GstAudio.AUDIO_CONVERTER_OPT_QUANTIZATION
G_TYPE_UINT (not introspectable), The quantization amount. Components will be quantized to multiples of this value. Default is 1
GST_AUDIO_CONVERTER_OPT_RESAMPLER_METHOD
#define GST_AUDIO_CONVERTER_OPT_RESAMPLER_METHOD "GstAudioConverter.resampler-method"
GstAudioResamplerMethod, The resampler method to use when changing sample rates. Default is GST_AUDIO_RESAMPLER_METHOD_BLACKMAN_NUTTALL.
GstAudio.AUDIO_CONVERTER_OPT_RESAMPLER_METHOD
GstAudio.AudioResamplerMethod, The resampler method to use when changing sample rates. Default is GstAudio.AudioResamplerMethod.BLACKMAN_NUTTALL.
GstAudio.AUDIO_CONVERTER_OPT_RESAMPLER_METHOD
GstAudio.AudioResamplerMethod, The resampler method to use when changing sample rates. Default is GstAudio.AudioResamplerMethod.BLACKMAN_NUTTALL.
The results of the search are