gavl

peakdetector.h
Go to the documentation of this file.
1/*****************************************************************
2 * gavl - a general purpose audio/video processing library
3 *
4 * Copyright (c) 2001 - 2024 Members of the Gmerlin project
5 * http://github.com/bplaum
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 * *****************************************************************/
20
21
22
27
28#ifndef GAVL_PEAKDETECTORS_H_INCLUDED
29#define GAVL_PEAKDETECTORS_H_INCLUDED
30
31#include <gavl/connectors.h>
32
33#ifdef __cplusplus
34 extern "C" {
35#endif
36
46
51
52 typedef struct gavl_peak_detector_s gavl_peak_detector_t;
53
54/* Create / destroy */
55
65
66 typedef void (*gavl_update_peak_callback)(void * priv,
67 int samples,
68 double min, double max, double abs);
69
79
80 typedef void (*gavl_update_peaks_callback)(void * priv,
81 int samples,
82 const double * min,
83 const double * max,
84 const double * abs);
85
89
90GAVL_PUBLIC
91 gavl_peak_detector_t * gavl_peak_detector_create(void);
92
101
102GAVL_PUBLIC
103 void gavl_peak_detector_set_callbacks(gavl_peak_detector_t * pd,
104 gavl_update_peak_callback peak_callback,
105 gavl_update_peaks_callback peaks_callback,
106 void * priv);
107
108
112
113GAVL_PUBLIC
114 void gavl_peak_detector_destroy(gavl_peak_detector_t *pd);
115
123
124GAVL_PUBLIC
125 void gavl_peak_detector_set_format(gavl_peak_detector_t *pd,
126 const gavl_audio_format_t * format);
127
134
135GAVL_PUBLIC const gavl_audio_format_t *
136 gavl_peak_detector_get_format(gavl_peak_detector_t * pd);
137
138
143
144GAVL_PUBLIC
145 void gavl_peak_detector_update(gavl_peak_detector_t *pd,
146 gavl_audio_frame_t * frame);
147
157
158GAVL_PUBLIC
159 gavl_audio_sink_t * gavl_peak_detector_get_sink(gavl_peak_detector_t *pd);
160
171
172GAVL_PUBLIC
173 void gavl_peak_detector_get_peak(gavl_peak_detector_t * pd,
174 double * min, double * max,
175 double * abs);
176
187
188GAVL_PUBLIC
189 void gavl_peak_detector_get_peaks(gavl_peak_detector_t * pd,
190 double * min, double * max,
191 double * abs);
192
196
197GAVL_PUBLIC
198 void gavl_peak_detector_reset(gavl_peak_detector_t * pd);
199
203
204
205
206#ifdef __cplusplus
207}
208#endif
209
210#endif // GAVL_PEAKDETECTORS_H_INCLUDED
gavl_peak_detector_t
struct gavl_peak_detector_s gavl_peak_detector_t
Opaque structure for peak detector.
Definition peakdetector.h:52
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.
gavl_update_peak_callback
void(* gavl_update_peak_callback)(void *priv, int samples, double min, double max, double abs)
Callback for getting the peaks across all channels.
Definition peakdetector.h:66
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.
gavl_peak_detector_create
GAVL_PUBLIC gavl_peak_detector_t * gavl_peak_detector_create(void)
Create peak detector.
gavl_peak_detector_reset
GAVL_PUBLIC void gavl_peak_detector_reset(gavl_peak_detector_t *pd)
Reset a 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.
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.
gavl_update_peaks_callback
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.
Definition peakdetector.h:80
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.
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.
gavl_peak_detector_get_format
GAVL_PUBLIC const gavl_audio_format_t * gavl_peak_detector_get_format(gavl_peak_detector_t *pd)
Get format.
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.
gavl_audio_sink_t
struct gavl_audio_sink_s gavl_audio_sink_t
Audio sink.
Definition gavl.h:74
gavl_audio_format_t
Audio Format.
Definition gavl.h:273
gavl_audio_frame_t
Generic container for audio samples.
Definition gavl.h:624