GstAudio.AudioResampler

Fields

None

Methods

class

new (method, flags, format, channels, in_rate, out_rate, options)

class

options_set_quality (method, quality, in_rate, out_rate, options)

free ()

get_in_frames (out_frames)

get_max_latency ()

get_out_frames (in_frames)

resample (in_, in_frames, out, out_frames)

reset ()

update (in_rate, out_rate, options)

Details

class GstAudio.AudioResampler

GstAudio.AudioResampler is a structure which holds the information required to perform various kinds of resampling filtering.

New in version 1.10.

classmethod new(method, flags, format, channels, in_rate, out_rate, options)[source]
Parameters:
Returns:

The new GstAudio.AudioResampler.

Return type:

GstAudio.AudioResampler

Make a new resampler.

classmethod options_set_quality(method, quality, in_rate, out_rate, options)[source]
Parameters:

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

free()[source]

Free a previously allocated GstAudio.AudioResampler self.

get_in_frames(out_frames)[source]
Parameters:

out_frames (int) – number of input frames

Returns:

The number of input frames needed for producing out_frames of data from self.

Return type:

int

Get the number of input frames that would currently be needed to produce out_frames from self.

get_max_latency()[source]
Returns:

the latency of self as expressed in the number of frames.

Return type:

int

Get the maximum number of input samples that the resampler would need before producing output.

get_out_frames(in_frames)[source]
Parameters:

in_frames (int) – number of input frames

Returns:

The number of frames that would be available after giving in_frames as input to self.

Return type:

int

Get the number of output frames that would be currently available when in_frames are given to self.

resample(in_, in_frames, out, out_frames)[source]
Parameters:
  • in (object or None) – input samples

  • in_frames (int) – number of input frames

  • out (object or None) – output samples

  • out_frames (int) – number of output frames

Perform resampling on in_frames frames in in and write out_frames to out.

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 pushed into the resampler.

This function always produces out_frames of output and consumes in_frames of input. Use GstAudio.AudioResampler.get_out_frames() and GstAudio.AudioResampler.get_in_frames() to make sure in_frames and out_frames are matching and in and out point to enough memory.

reset()[source]

Reset self to the state it was when it was first created, discarding all sample history.

update(in_rate, out_rate, options)[source]
Parameters:
  • in_rate (int) – new input rate

  • out_rate (int) – new output rate

  • options (Gst.Structure) – new options or None

Returns:

True if the new parameters could be set

Return type:

bool

Update the resampler parameters for self. This function should not be called concurrently with any other function on self.

When in_rate or out_rate is 0, its value is unchanged.

When options is None, the previously configured options are reused.