swift
SimpleGate.cpp
1 /*
2  * Simple Gate (source)
3  *
4  * File : SimpleGate.cpp
5  * Library : SimpleSource
6  * Version : 1.12
7  * Implements : 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 #include "SimpleGate.h"
31 
32 namespace chunkware_simple
33 {
34  //-------------------------------------------------------------
36  : AttRelEnvelope( 1.0, 100.0 )
37  , threshdB_( 0.0 )
38  , thresh_( 1.0 )
39  , env_( DC_OFFSET )
40  {
41  }
42 
43  //-------------------------------------------------------------
44  void SimpleGate::setThresh( double dB )
45  {
46  threshdB_ = dB;
47  thresh_ = dB2lin( dB );
48  }
49 
50  //-------------------------------------------------------------
52  {
53  env_ = DC_OFFSET;
54  }
55 
56  //-------------------------------------------------------------
57  // simple gate with RMS detection
58  //-------------------------------------------------------------
60  : ave_( 5.0 )
61  , aveOfSqrs_( DC_OFFSET )
62  {
63  }
64 
65  //-------------------------------------------------------------
66  void SimpleGateRms::setSampleRate( double sampleRate )
67  {
68  SimpleGate::setSampleRate( sampleRate );
69  ave_.setSampleRate( sampleRate );
70  }
71 
72  //-------------------------------------------------------------
73  void SimpleGateRms::setWindow( double ms )
74  {
75  ave_.setTc( ms );
76  }
77 
78  //-------------------------------------------------------------
80  {
82  aveOfSqrs_ = DC_OFFSET;
83  }
84 
85 } // end namespace chunkware_simple
attack/release envelope
virtual void setSampleRate(double sampleRate)
Sample rate dependencies.
virtual void setSampleRate(double sampleRate)
set sample rate
virtual void setTc(double ms)
set time constant
virtual void initRuntime(void)
Init runtime.
Definition: SimpleGate.cpp:51
virtual void setThresh(double dB)
set threshold
Definition: SimpleGate.cpp:44
virtual void setWindow(double ms)
set RMS window
Definition: SimpleGate.cpp:73
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