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 <stdbool.h>
30
31#include "ext/zita-resampler/resampler.h"
32
33typedef struct TruePeakDsp
34{
35 float m;
36 float p;
37 float z1;
38 float z2;
39 bool res;
40 float * buf;
41 ZitaResampler * src;
42
43 float w1; // attack filter coefficient
44 float w2; // attack filter coefficient
45 float w3; // release filter coefficient
46 float g; // gain factor
48
55void
56true_peak_dsp_process (TruePeakDsp * self, float * p, int n);
57
58void
59true_peak_dsp_process_max (TruePeakDsp * self, float * p, int n);
60
61float
62true_peak_dsp_read_f (TruePeakDsp * self);
63
64void
65true_peak_dsp_read (TruePeakDsp * self, float * m, float * p);
66
67void
68true_peak_dsp_reset (TruePeakDsp * self);
69
73void
74true_peak_dsp_init (TruePeakDsp * self, float samplerate);
75
77true_peak_dsp_new (void);
78
79void
80true_peak_dsp_free (TruePeakDsp * self);
81
82#endif