Chris@0
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@0
|
2
|
Chris@0
|
3 #ifndef FLATTENDYNAMICS_LADSPA_H
|
Chris@0
|
4 #define FLATTENDYNAMICS_LADSPA_H
|
Chris@0
|
5
|
Chris@0
|
6 #include <ladspa.h>
|
Chris@0
|
7
|
Chris@0
|
8 class FlattenDynamics
|
Chris@0
|
9 {
|
Chris@0
|
10 public:
|
Chris@0
|
11 static const LADSPA_Descriptor *getDescriptor(unsigned long index);
|
Chris@0
|
12
|
Chris@15
|
13 enum Port {
|
Chris@1
|
14 AudioInputPort = 0,
|
Chris@1
|
15 AudioOutputPort = 1,
|
Chris@1
|
16 GainOutputPort = 2,
|
Chris@1
|
17 PortCount = 3,
|
Chris@0
|
18 };
|
Chris@0
|
19
|
Chris@15
|
20 // Rest of the public interface is for use when constructing the
|
Chris@15
|
21 // class directly, rather than through LADSPA
|
Chris@15
|
22
|
Chris@15
|
23 FlattenDynamics(int sampleRate);
|
Chris@15
|
24 ~FlattenDynamics();
|
Chris@15
|
25
|
Chris@15
|
26 void connectInputPort(Port p, const float *addr);
|
Chris@15
|
27 void connectOutputPort(Port p, float *addr);
|
Chris@15
|
28 void reset();
|
Chris@15
|
29 void process(int nsamples);
|
Chris@15
|
30
|
Chris@15
|
31 private:
|
Chris@0
|
32 static const char *const portNames[PortCount];
|
Chris@0
|
33 static const LADSPA_PortDescriptor ports[PortCount];
|
Chris@0
|
34 static const LADSPA_PortRangeHint hints[PortCount];
|
Chris@0
|
35 static const LADSPA_Properties properties;
|
Chris@0
|
36 static const LADSPA_Descriptor ladspaDescriptor;
|
Chris@0
|
37
|
Chris@15
|
38 static LADSPA_Handle ladspaInstantiate(const LADSPA_Descriptor *, unsigned long);
|
Chris@15
|
39 static void ladspaConnectPort(LADSPA_Handle, unsigned long, LADSPA_Data *);
|
Chris@15
|
40 static void ladspaActivate(LADSPA_Handle);
|
Chris@15
|
41 static void ladspaRun(LADSPA_Handle, unsigned long);
|
Chris@15
|
42 static void ladspaDeactivate(LADSPA_Handle);
|
Chris@15
|
43 static void ladspaCleanup(LADSPA_Handle);
|
Chris@0
|
44
|
Chris@15
|
45 float processSingle(float sample);
|
Chris@1
|
46 void updateRMS(float);
|
Chris@0
|
47 void updateParameters();
|
Chris@0
|
48
|
Chris@0
|
49 int m_sampleRate;
|
Chris@15
|
50 const float *m_input;
|
Chris@0
|
51 float *m_output;
|
Chris@1
|
52 float *m_pgain;
|
Chris@1
|
53
|
Chris@1
|
54 float *m_history;
|
Chris@1
|
55 int m_histlen;
|
Chris@1
|
56 int m_histwrite;
|
Chris@1
|
57 int m_histread;
|
Chris@1
|
58
|
Chris@17
|
59 double m_sumOfSquares;
|
Chris@17
|
60 float m_rms;
|
Chris@17
|
61 float m_maxRms;
|
Chris@1
|
62 float m_gain;
|
Chris@0
|
63 };
|
Chris@0
|
64
|
Chris@0
|
65 #endif
|