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
33#include <stdbool.h>
34
35typedef struct KMeterDsp
36{
37 float z1; // filter state
38 float z2; // filter state
39 float rms; // max rms value since last read()
40 float peak; // max peak value since last read()
41 int cnt; // digital peak hold counter
42 int fpp; // frames per period
43 float fall; // peak fallback
44 bool flag; // flag set by read(), resets _rms
45
46 float omega; // ballistics filter constant.
47 int hold; // peak hold timeoute
48 float fsamp; // sample-rate
49} KMeterDsp;
50
57void
58kmeter_dsp_process (KMeterDsp * self, float * p, int n);
59
60float
61kmeter_dsp_read_f (KMeterDsp * self);
62
63void
64kmeter_dsp_read (KMeterDsp * self, float * rms, float * peak);
65
66void
67kmeter_dsp_reset (KMeterDsp * self);
68
72void
73kmeter_dsp_init (KMeterDsp * self, float samplerate);
74
75MALLOC
77kmeter_dsp_new (void);
78
79void
80kmeter_dsp_free (KMeterDsp * self);
81
82#endif