swift
SimpleGate.h
1 /*
2  * Simple Gate (header)
3  *
4  * File : SimpleGate.h
5  * Library : SimpleSource
6  * Version : 1.12
7  * Class : SimpleGate, SimpleGateRms
8  *
9  * 2006, ChunkWare Music Software, OPEN-SOURCE
10  *
11  * Permission is hereby granted, free of charge, to any person obtaining a
12  * copy of this software and associated documentation files (the "Software"),
13  * to deal in the Software without restriction, including without limitation
14  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15  * and/or sell copies of the Software, and to permit persons to whom the
16  * Software is furnished to do so, subject to the following conditions:
17  *
18  * The above copyright notice and this permission notice shall be included in
19  * all copies or substantial portions of the Software.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27  * DEALINGS IN THE SOFTWARE.
28  */
29 
30 
31 #ifndef chunkware__SIMPLE_GATE_H
32 #define chunkware__SIMPLE_GATE_H
33 
34 #include "SimpleHeader.h" // common header
35 #include "SimpleEnvelope.h" // for base class
36 #include "SimpleGain.h" // for gain functions
37 
38 namespace chunkware_simple
39 {
41  class SimpleGate : public AttRelEnvelope
42  {
43  public:
45  SimpleGate();
46 
48  virtual ~SimpleGate() {}
49 
51  virtual void setThresh(double dB);
52 
54  virtual double getThresh(void) const { return threshdB_; }
55 
58  virtual void initRuntime(void);
59 
62  void process(double &in1, double &in2);
63 
65  void process(double &in1, double &in2, double keyLinked); // with stereo-linked key in
66 
67  private:
68  // transfer function
69  double threshdB_;
70  double thresh_;
71 
72  // runtime variables
73  double env_;
74  };
75 
77  class SimpleGateRms : public SimpleGate
78  {
79  public:
81  SimpleGateRms();
82 
84  virtual ~SimpleGateRms() override {}
85 
87  virtual void setSampleRate(double sampleRate) override;
88 
90  virtual void setWindow(double ms);
91 
93  virtual double getWindow(void) const { return ave_.getTc(); }
94 
96  virtual void initRuntime(void) override;
97 
99  void process(double &in1, double &in2);
100 
101  private:
102  EnvelopeDetector ave_;
103  double aveOfSqrs_;
104 
105  }; // end SimpleGateRms class
106 
107 } // end namespace chunkware_simple
108 
109 // include inlined process function
110 #include "SimpleGateProcess.inl"
111 
112 #endif // end __SIMPLE_GATE_H__
attack/release envelope
virtual double getTc(void) const
get time constant
virtual void initRuntime(void)
Init runtime.
Definition: SimpleGate.cpp:51
void process(double &in1, double &in2)
Process audio.
virtual ~SimpleGate()
Destructor.
Definition: SimpleGate.h:48
virtual double getThresh(void) const
get threshold
Definition: SimpleGate.h:54
virtual void setThresh(double dB)
set threshold
Definition: SimpleGate.cpp:44
Simple gate with RMS detection.
Definition: SimpleGate.h:78
virtual void setWindow(double ms)
set RMS window
Definition: SimpleGate.cpp:73
virtual ~SimpleGateRms()
Destructor.
Definition: SimpleGate.h:84
void process(double &in1, double &in2)
gate runtime process
virtual void initRuntime(void)
call before runtime (in resume())
Definition: SimpleGate.cpp:79
virtual void setSampleRate(double sampleRate)
set sample rate
Definition: SimpleGate.cpp:66
virtual double getWindow(void) const
get RMS window
Definition: SimpleGate.h:93