2 * Copyright (C) 2013-2016 Robin Gareus <robin@gareus.org>
3 * Copyright (C) 2006-2012 Fons Adriaensen <fons@linuxaudio.org>
4 * Copyright (C) 2006 Chris Cannam
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef _TruePeak_PLUGIN_H_
21 #define _TruePeak_PLUGIN_H_
23 #include <vamp-sdk/Plugin.h>
27 namespace TruePeakMeter {
33 friend class Resampler_table;
35 Resampler_mutex (void) { pthread_mutex_init (&_mutex, 0); }
36 ~Resampler_mutex (void) { pthread_mutex_destroy (&_mutex); }
37 void lock (void) { pthread_mutex_lock (&_mutex); }
38 void unlock (void) { pthread_mutex_unlock (&_mutex); }
40 pthread_mutex_t _mutex;
47 Resampler_table (double fr, unsigned int hl, unsigned int np);
48 ~Resampler_table (void);
50 friend class Resampler;
51 friend class VResampler;
53 Resampler_table *_next;
60 static Resampler_table *create (double fr, unsigned int hl, unsigned int np);
61 static void destroy (Resampler_table *T);
63 static Resampler_table *_list;
64 static Resampler_mutex _mutex;
74 int setup (unsigned int fs_inp,
79 int setup (unsigned int fs_inp,
87 int nchan (void) const { return _nchan; }
88 int filtlen (void) const { return inpsize (); } // Deprecated
89 int inpsize (void) const;
90 double inpdist (void) const;
93 unsigned int inp_count;
94 unsigned int out_count;
95 float const *inp_data;
102 Resampler_table *_table;
121 void process (float const *, int n);
123 void read (float &m, float &p);
126 bool init (float fsamp);
138 }; // namespace TruePeakMeter
140 class VampTruePeak : public Vamp::Plugin
143 VampTruePeak(float inputSampleRate);
144 virtual ~VampTruePeak();
146 size_t getMinChannelCount() const { return 1; }
147 size_t getMaxChannelCount() const { return 1; }
148 size_t getPreferredBlockSize () const { return 1024; }
149 bool initialise(size_t channels, size_t stepSize, size_t blockSize);
152 InputDomain getInputDomain() const { return TimeDomain; }
154 std::string getIdentifier() const;
155 std::string getName() const;
156 std::string getDescription() const;
157 std::string getMaker() const;
158 int getPluginVersion() const;
159 std::string getCopyright() const;
161 OutputList getOutputDescriptors() const;
163 FeatureSet process(const float *const *inputBuffers,
164 Vamp::RealTime timestamp);
166 FeatureSet getRemainingFeatures();
172 TruePeakMeter::TruePeakdsp _meter;