swift
SimpleComp.cpp
1 /*
2  * Simple Compressor (source)
3  *
4  * File : SimpleComp.cpp
5  * Library : SimpleSource
6  * Version : 1.12
7  * Implements : SimpleComp, SimpleCompRms
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 #include "SimpleComp.h"
32 
33 namespace chunkware_simple
34 {
35  //-------------------------------------------------------------
36  // simple compressor
37  //-------------------------------------------------------------
39  : AttRelEnvelope(10.0, 100.0)
40  , threshdB_(0.0)
41  , ratio_(1.0)
42  , envdB_(DC_OFFSET)
43  , makeUpGain_(1.0)
44  {
45  }
46 
47  //-------------------------------------------------------------
48  void SimpleComp::setThresh(double dB)
49  {
50  threshdB_ = dB;
51  }
52 
53  //-------------------------------------------------------------
54  void SimpleComp::setRatio(double ratio)
55  {
56  assert(ratio > 0.0);
57  ratio_ = ratio;
58  }
59 
60  //-------------------------------------------------------------
61  void SimpleComp::setMakeUpGain(double gain)
62  {
63  makeUpGain_ = gain;
64  }
65 
66  //-------------------------------------------------------------
68  {
69  envdB_ = DC_OFFSET;
70  }
71 
72  //-------------------------------------------------------------
73  // simple compressor with RMS detection
74  //-------------------------------------------------------------
76  : ave_(5.0)
77  , aveOfSqrs_(DC_OFFSET)
78  {
79  }
80 
81  //-------------------------------------------------------------
82  void SimpleCompRms::setSampleRate(double sampleRate)
83  {
84  SimpleComp::setSampleRate(sampleRate);
85  ave_.setSampleRate(sampleRate);
86  }
87 
88  //-------------------------------------------------------------
89  void SimpleCompRms::setWindow(double ms)
90  {
91  ave_.setTc(ms);
92  }
93 
94  //-------------------------------------------------------------
96  {
98  aveOfSqrs_ = DC_OFFSET;
99  }
100 
101 } // 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 setThresh(double dB)
set parameters
Definition: SimpleComp.cpp:48
void setMakeUpGain(double gain)
set parameters
Definition: SimpleComp.cpp:61
virtual void initRuntime(void)
Init runtime.
Definition: SimpleComp.cpp:67
virtual void setRatio(double dB)
set parameters
Definition: SimpleComp.cpp:54
virtual void setSampleRate(double sampleRate)
Sample rate.
Definition: SimpleComp.cpp:82
virtual void setWindow(double ms)
RMS window.
Definition: SimpleComp.cpp:89
virtual void initRuntime(void)
Runtime process.
Definition: SimpleComp.cpp:95