mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-08-05 08:55:59 +08:00
refactor: Move chunkware to third_party
This commit is contained in:
101
third_party/chunkware_dsp/SimpleComp.cpp
vendored
Normal file
101
third_party/chunkware_dsp/SimpleComp.cpp
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Simple Compressor (source)
|
||||
*
|
||||
* File : SimpleComp.cpp
|
||||
* Library : SimpleSource
|
||||
* Version : 1.12
|
||||
* Implements : SimpleComp, SimpleCompRms
|
||||
*
|
||||
* © 2006, ChunkWare Music Software, OPEN-SOURCE
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#include "SimpleComp.h"
|
||||
|
||||
namespace chunkware_simple
|
||||
{
|
||||
//-------------------------------------------------------------
|
||||
// simple compressor
|
||||
//-------------------------------------------------------------
|
||||
SimpleComp::SimpleComp()
|
||||
: AttRelEnvelope(10.0, 100.0)
|
||||
, threshdB_(0.0)
|
||||
, ratio_(1.0)
|
||||
, envdB_(DC_OFFSET)
|
||||
, makeUpGain_(1.0)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------
|
||||
void SimpleComp::setThresh(double dB)
|
||||
{
|
||||
threshdB_ = dB;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------
|
||||
void SimpleComp::setRatio(double ratio)
|
||||
{
|
||||
assert(ratio > 0.0);
|
||||
ratio_ = ratio;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------
|
||||
void SimpleComp::setMakeUpGain(double gain)
|
||||
{
|
||||
makeUpGain_ = gain;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------
|
||||
void SimpleComp::initRuntime(void)
|
||||
{
|
||||
envdB_ = DC_OFFSET;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// simple compressor with RMS detection
|
||||
//-------------------------------------------------------------
|
||||
SimpleCompRms::SimpleCompRms()
|
||||
: ave_(5.0)
|
||||
, aveOfSqrs_(DC_OFFSET)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------
|
||||
void SimpleCompRms::setSampleRate(double sampleRate)
|
||||
{
|
||||
SimpleComp::setSampleRate(sampleRate);
|
||||
ave_.setSampleRate(sampleRate);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------
|
||||
void SimpleCompRms::setWindow(double ms)
|
||||
{
|
||||
ave_.setTc(ms);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------
|
||||
void SimpleCompRms::initRuntime(void)
|
||||
{
|
||||
SimpleComp::initRuntime();
|
||||
aveOfSqrs_ = DC_OFFSET;
|
||||
}
|
||||
|
||||
} // end namespace chunkware_simple
|
||||
Reference in New Issue
Block a user