Zrythm
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
peak_dsp.h
1// SPDX-FileCopyrightText: © 2020-2021 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3/*
4 * This file incorporates work covered by the following copyright and
5 * permission notice:
6 *
7 * ---
8 *
9 * Copyright (C) 2013 Robin Gareus <robin@gareus.org>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3, or (at your option)
14 * any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software Foundation,
23 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 *
25 * ---
26 */
27
28#ifndef __AUDIO_PEAK_DSP__
29#define __AUDIO_PEAK_DSP__
30
31#include <stdbool.h>
32
33typedef struct PeakDsp
34{
35 float rms; // max rms value since last read()
36 float peak; // max peak value since last read()
37 int cnt; // digital peak hold counter
38 int fpp; // frames per period
39 float fall; // peak fallback
40 bool flag; // flag set by read(), resets _rms
41
42 int hold; // peak hold timeoute
43 float fsamp; // sample-rate
44} PeakDsp;
45
52HOT void
53peak_dsp_process (PeakDsp * self, float * p, int n);
54
55float
56peak_dsp_read_f (PeakDsp * self);
57
58void
59peak_dsp_read (PeakDsp * self, float * rms, float * peak);
60
61void
62peak_dsp_reset (PeakDsp * self);
63
67void
68peak_dsp_init (PeakDsp * self, float samplerate);
69
70MALLOC
71PeakDsp *
72peak_dsp_new (void);
73
74void
75peak_dsp_free (PeakDsp * self);
76
77#endif