Zrythm
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
kmeter_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 2, 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 * SPDX-License-Identifier: GPL-2.0-or-later
26 *
27 * ---
28 */
29
30#ifndef __AUDIO_KMETER_DSP__
31#define __AUDIO_KMETER_DSP__
32
33typedef struct KMeterDsp
34{
35 float z1; // filter state
36 float z2; // filter state
37 float rms; // max rms value since last read()
38 float peak; // max peak value since last read()
39 int cnt; // digital peak hold counter
40 int fpp; // frames per period
41 float fall; // peak fallback
42 bool flag; // flag set by read(), resets _rms
43
44 float omega; // ballistics filter constant.
45 int hold; // peak hold timeoute
46 float fsamp; // sample-rate
47} KMeterDsp;
48
55void
56kmeter_dsp_process (KMeterDsp * self, float * p, int n);
57
58float
59kmeter_dsp_read_f (KMeterDsp * self);
60
61void
62kmeter_dsp_read (KMeterDsp * self, float * rms, float * peak);
63
64void
65kmeter_dsp_reset (KMeterDsp * self);
66
70void
71kmeter_dsp_init (KMeterDsp * self, float samplerate);
72
73MALLOC
75kmeter_dsp_new (void);
76
77void
78kmeter_dsp_free (KMeterDsp * self);
79
80#endif