gavl
Typedefs | Functions
Peak detector

Detect peaks in the volume for steering normalizers and dynamic range compressors While normalizers and dynamic range controls are out of the scope of gavl, some low-level functionality can be provided. More...

Typedefs

typedef struct gavl_peak_detector_s gavl_peak_detector_t
 Opaque structure for peak detector. More...
 
typedef void(* gavl_update_peak_callback) (void *priv, int samples, double min, double max, double abs)
 Callback for getting the peaks across all channels. More...
 
typedef void(* gavl_update_peaks_callback) (void *priv, int samples, const double *min, const double *max, const double *abs)
 Callback for getting the peaks for all channels separately. More...
 

Functions

GAVL_PUBLIC gavl_peak_detector_tgavl_peak_detector_create ()
 Create peak detector. More...
 
GAVL_PUBLIC void gavl_peak_detector_set_callbacks (gavl_peak_detector_t *pd, gavl_update_peak_callback peak_callback, gavl_update_peaks_callback peaks_callback, void *priv)
 Set callbacks. More...
 
GAVL_PUBLIC void gavl_peak_detector_destroy (gavl_peak_detector_t *pd)
 Destroys a peak detector and frees all associated memory. More...
 
GAVL_PUBLIC void gavl_peak_detector_set_format (gavl_peak_detector_t *pd, const gavl_audio_format_t *format)
 Set format for a peak detector. More...
 
GAVL_PUBLIC const gavl_audio_format_tgavl_peak_detector_get_format (gavl_peak_detector_t *pd)
 Get format. More...
 
GAVL_PUBLIC void gavl_peak_detector_update (gavl_peak_detector_t *pd, gavl_audio_frame_t *frame)
 Feed the peak detector with a new frame. More...
 
GAVL_PUBLIC gavl_audio_sink_tgavl_peak_detector_get_sink (gavl_peak_detector_t *pd)
 Get the audio sink. More...
 
GAVL_PUBLIC void gavl_peak_detector_get_peak (gavl_peak_detector_t *pd, double *min, double *max, double *abs)
 Get the peak volume across all channels. More...
 
GAVL_PUBLIC void gavl_peak_detector_get_peaks (gavl_peak_detector_t *pd, double *min, double *max, double *abs)
 Get the peak volume for all channels separate. More...
 
GAVL_PUBLIC void gavl_peak_detector_reset (gavl_peak_detector_t *pd)
 Reset a peak detector. More...
 

Detailed Description

Detect peaks in the volume for steering normalizers and dynamic range compressors While normalizers and dynamic range controls are out of the scope of gavl, some low-level functionality can be provided.

Typedef Documentation

◆ gavl_peak_detector_t

typedef struct gavl_peak_detector_s gavl_peak_detector_t

Opaque structure for peak detector.

You don't want to know what's inside.

◆ gavl_update_peak_callback

typedef void(* gavl_update_peak_callback) (void *priv, int samples, double min, double max, double abs)

Callback for getting the peaks across all channels.

Parameters
privClient data
samplesNumber of samples of last update call
minMinimum value (scaled betwen -1.0 and 1.0)
minMaximum value (scaled betwen -1.0 and 1.0)
absAbsolute value (scaled betwen 0.0 and 1.0)

Since 1.5.0

◆ gavl_update_peaks_callback

typedef void(* gavl_update_peaks_callback) (void *priv, int samples, const double *min, const double *max, const double *abs)

Callback for getting the peaks for all channels separately.

Parameters
privClient data
samplesNumber of samples of last update call
minMinimum value (scaled betwen -1.0 and 1.0)
minMaximum value (scaled betwen -1.0 and 1.0)
absAbsolute value (scaled betwen 0.0 and 1.0)

Since 1.5.0

Function Documentation

◆ gavl_peak_detector_create()

GAVL_PUBLIC gavl_peak_detector_t* gavl_peak_detector_create ( )

Create peak detector.

Returns
A newly allocated peak detector

◆ gavl_peak_detector_set_callbacks()

GAVL_PUBLIC void gavl_peak_detector_set_callbacks ( gavl_peak_detector_t pd,
gavl_update_peak_callback  peak_callback,
gavl_update_peaks_callback  peaks_callback,
void *  priv 
)

Set callbacks.

Parameters
pdA peak detector
peak_callbackCallback for overall peaks or NULL
peaks_callbackCallback for per channel peaks or NULL
privClient data passed to the callbacks

Since 1.5.0

◆ gavl_peak_detector_destroy()

GAVL_PUBLIC void gavl_peak_detector_destroy ( gavl_peak_detector_t pd)

Destroys a peak detector and frees all associated memory.

Parameters
pdA peak detector

◆ gavl_peak_detector_set_format()

GAVL_PUBLIC void gavl_peak_detector_set_format ( gavl_peak_detector_t pd,
const gavl_audio_format_t format 
)

Set format for a peak detector.

Parameters
pdA peak detector
formatThe format subsequent frames will be passed with

This function can be called multiple times with one instance. It also calls gavl_peak_detector_reset.

◆ gavl_peak_detector_get_format()

GAVL_PUBLIC const gavl_audio_format_t* gavl_peak_detector_get_format ( gavl_peak_detector_t pd)

Get format.

Parameters
pdA peak detector
Returns
The internal format

Since 1.5.0

◆ gavl_peak_detector_update()

GAVL_PUBLIC void gavl_peak_detector_update ( gavl_peak_detector_t pd,
gavl_audio_frame_t frame 
)

Feed the peak detector with a new frame.

Parameters
pdA peak detector
frameAn audio frame

◆ gavl_peak_detector_get_sink()

GAVL_PUBLIC gavl_audio_sink_t* gavl_peak_detector_get_sink ( gavl_peak_detector_t pd)

Get the audio sink.

Parameters
pdA peak detector
Returns
An audio sink

Use the returned sink for passing audio frames as an alternative to gavl_peak_detector_update

Since 1.5.0

◆ gavl_peak_detector_get_peak()

GAVL_PUBLIC void gavl_peak_detector_get_peak ( gavl_peak_detector_t pd,
double *  min,
double *  max,
double *  abs 
)

Get the peak volume across all channels.

Parameters
pdA peak detector
minReturns minimum amplitude
maxReturns maximum amplitude
absReturns maximum absolute amplitude

The returned amplitudes are normalized such that the minimum amplitude corresponds to -1.0, the maximum amplitude corresponds to 1.0.

◆ gavl_peak_detector_get_peaks()

GAVL_PUBLIC void gavl_peak_detector_get_peaks ( gavl_peak_detector_t pd,
double *  min,
double *  max,
double *  abs 
)

Get the peak volume for all channels separate.

Parameters
pdA peak detector
minReturns minimum amplitude
maxReturns maximum amplitude
absReturns maximum absolute amplitude

The returned amplitudes are normalized such that the minimum amplitude corresponds to -1.0, the maximum amplitude corresponds to 1.0.

◆ gavl_peak_detector_reset()

GAVL_PUBLIC void gavl_peak_detector_reset ( gavl_peak_detector_t pd)

Reset a peak detector.

Parameters
pdA peak detector