Zrythm
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
true_peak_dsp.h
1/*
2 * SPDX-FileCopyrightText: © 2020 Alexandros Theodotou <alex@zrythm.org>
3 *
4 * SPDX-License-Identifier: LicenseRef-ZrythmLicense
5 *
6 * This file incorporates work covered by the following copyright and
7 * permission notice:
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
26#ifndef __AUDIO_TRUE_PEAK_DSP__
27#define __AUDIO_TRUE_PEAK_DSP__
28
29#include "ext/zita-resampler/resampler.h"
30
31typedef struct TruePeakDsp
32{
33 float m;
34 float p;
35 float z1;
36 float z2;
37 bool res;
38 float * buf;
39 ZitaResampler * src;
40
41 float w1; // attack filter coefficient
42 float w2; // attack filter coefficient
43 float w3; // release filter coefficient
44 float g; // gain factor
46
53void
54true_peak_dsp_process (TruePeakDsp * self, float * p, int n);
55
56void
57true_peak_dsp_process_max (TruePeakDsp * self, float * p, int n);
58
59float
60true_peak_dsp_read_f (TruePeakDsp * self);
61
62void
63true_peak_dsp_read (TruePeakDsp * self, float * m, float * p);
64
65void
66true_peak_dsp_reset (TruePeakDsp * self);
67
71void
72true_peak_dsp_init (TruePeakDsp * self, float samplerate);
73
75true_peak_dsp_new (void);
76
77void
78true_peak_dsp_free (TruePeakDsp * self);
79
80#endif