[DEV] One class one file

This commit is contained in:
Edouard DUPIN 2015-04-03 21:25:15 +02:00
parent 4cd6d4e0bf
commit 942a9cf67b
19 changed files with 619 additions and 514 deletions

View File

@ -0,0 +1,50 @@
/**
* @author Bojan MARKOVIC
* @author Edouard DUPIN
* @copyright 2006, ChunkWare Music Software, OPEN-SOURCE
* @license BSD-1 (see license file)
*
* 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 "AttRelEnvelope.h"
audio::algo::chunkware::AttRelEnvelope::AttRelEnvelope(double att_ms, double rel_ms, double sampleRate) :
att_(att_ms, sampleRate),
rel_(rel_ms, sampleRate) {
}
//-------------------------------------------------------------
void audio::algo::chunkware::AttRelEnvelope::setAttack(double ms) {
att_.setTc(ms);
}
//-------------------------------------------------------------
void audio::algo::chunkware::AttRelEnvelope::setRelease(double ms) {
rel_.setTc(ms);
}
//-------------------------------------------------------------
void audio::algo::chunkware::AttRelEnvelope::setSampleRate(double sampleRate) {
att_.setSampleRate(sampleRate);
rel_.setSampleRate(sampleRate);
}

View File

@ -0,0 +1,82 @@
/**
* @author Bojan MARKOVIC
* @author Edouard DUPIN
* @copyright 2006, ChunkWare Music Software, OPEN-SOURCE
* @license BSD-1 (see license file)
*
* 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.
*/
#ifndef __AUDIO_ALGO_CHUNKWARE_ATT_REL_ENVELOPE_H__
#define __AUDIO_ALGO_CHUNKWARE_ATT_REL_ENVELOPE_H__
#include "EnvelopeDetector.h"
namespace audio {
namespace algo {
namespace chunkware {
//-------------------------------------------------------------
// attack/release envelope
//-------------------------------------------------------------
class AttRelEnvelope {
public:
AttRelEnvelope(double att_ms = 10.0,
double rel_ms = 100.0,
double sampleRate = 44100.0);
virtual ~AttRelEnvelope() {}
// attack time constant
virtual void setAttack(double ms);
virtual double getAttack() const {
return att_.getTc();
}
// release time constant
virtual void setRelease(double ms);
virtual double getRelease() const {
return rel_.getTc();
}
// sample rate dependencies
virtual void setSampleRate(double sampleRate);
virtual double getSampleRate() const {
return att_.getSampleRate();
}
// runtime function
void run(double in, double &state) {
/* assumes that:
* positive delta = attack
* negative delta = release
* good for linear & log values
*/
if (in > state) {
// attack
att_.run(in, state);
} else {
// release
rel_.run(in, state);
}
}
private:
EnvelopeDetector att_;
EnvelopeDetector rel_;
};
}
}
}
#endif

View File

@ -1,38 +1,30 @@
/* /**
* Simple Compressor (source) * @author Bojan MARKOVIC
* @author Edouard DUPIN
* @copyright 2006, ChunkWare Music Software, OPEN-SOURCE
* @license BSD-1 (see license file)
* *
* File : SimpleComp.cpp * Permission is hereby granted, free of charge, to any person obtaining a
* Library : SimpleSource * copy of this software and associated documentation files (the "Software"),
* Version : 1.12 * to deal in the Software without restriction, including without limitation
* Implements : SimpleComp, SimpleCompRms * 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:
* *
* © 2006, ChunkWare Music Software, OPEN-SOURCE * * The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* *
* Permission is hereby granted, free of charge, to any person obtaining a * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* copy of this software and associated documentation files (the "Software"), * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* to deal in the Software without restriction, including without limitation * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* and/or sell copies of the Software, and to permit persons to whom the * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* Software is furnished to do so, subject to the following conditions: * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* * DEALINGS IN THE SOFTWARE.
* 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 "Compressor.h" #include "Compressor.h"
//-------------------------------------------------------------
// simple compressor
//-------------------------------------------------------------
audio::algo::chunkware::Compresssor::Compresssor() : audio::algo::chunkware::Compresssor::Compresssor() :
AttRelEnvelope(10.0, 100.0), AttRelEnvelope(10.0, 100.0),
threshdB_(0.0), threshdB_(0.0),
@ -41,18 +33,15 @@ audio::algo::chunkware::Compresssor::Compresssor() :
} }
//-------------------------------------------------------------
void audio::algo::chunkware::Compresssor::setThresh(double dB) { void audio::algo::chunkware::Compresssor::setThresh(double dB) {
threshdB_ = dB; threshdB_ = dB;
} }
//-------------------------------------------------------------
void audio::algo::chunkware::Compresssor::setRatio(double ratio) { void audio::algo::chunkware::Compresssor::setRatio(double ratio) {
assert(ratio > 0.0); assert(ratio > 0.0);
ratio_ = ratio; ratio_ = ratio;
} }
//-------------------------------------------------------------
void audio::algo::chunkware::Compresssor::initRuntime() { void audio::algo::chunkware::Compresssor::initRuntime() {
envdB_ = DC_OFFSET; envdB_ = DC_OFFSET;
} }
@ -95,46 +84,3 @@ void audio::algo::chunkware::Compresssor::process(double &in1, double &in2, doub
in2 *= gr; in2 *= gr;
} }
//-------------------------------------------------------------
// simple compressor with RMS detection
//-------------------------------------------------------------
audio::algo::chunkware::CompresssorRms::CompresssorRms() :
ave_(5.0),
aveOfSqrs_(DC_OFFSET) {
}
//-------------------------------------------------------------
void audio::algo::chunkware::CompresssorRms::setSampleRate(double sampleRate) {
audio::algo::chunkware::Compresssor::setSampleRate(sampleRate);
ave_.setSampleRate(sampleRate);
}
//-------------------------------------------------------------
void audio::algo::chunkware::CompresssorRms::setWindow(double ms) {
ave_.setTc(ms);
}
//-------------------------------------------------------------
void audio::algo::chunkware::CompresssorRms::initRuntime() {
audio::algo::chunkware::Compresssor::initRuntime();
aveOfSqrs_ = DC_OFFSET;
}
void audio::algo::chunkware::CompresssorRms::process(double &in1, double &in2) {
// create sidechain
double inSq1 = in1 * in1; // square input
double inSq2 = in2 * in2;
double sum = inSq1 + inSq2; // power summing
sum += DC_OFFSET; // DC offset, to prevent denormal
ave_.run(sum, aveOfSqrs_); // average of squares
double rms = sqrt(aveOfSqrs_); // rms (sort of ...)
/* REGARDING THE RMS AVERAGER: Ok, so this isn't a REAL RMS
* calculation. A true RMS is an FIR moving average. This
* approximation is a 1-pole IIR. Nonetheless, in practice,
* and in the interest of simplicity, this method will suffice,
* giving comparable results.
*/
// rest of process
Compresssor::process(in1, in2, rms);
}

View File

@ -1,46 +1,39 @@
/* /**
* Simple Compressor (header) * @author Bojan MARKOVIC
* @author Edouard DUPIN
* @copyright 2006, ChunkWare Music Software, OPEN-SOURCE
* @license BSD-1 (see license file)
* *
* File : SimpleComp.h * Permission is hereby granted, free of charge, to any person obtaining a
* Library : SimpleSource * copy of this software and associated documentation files (the "Software"),
* Version : 1.12 * to deal in the Software without restriction, including without limitation
* Class : SimpleComp, SimpleCompRms * 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:
* *
* © 2006, ChunkWare Music Software, OPEN-SOURCE * * The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* *
* Permission is hereby granted, free of charge, to any person obtaining a * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* copy of this software and associated documentation files (the "Software"), * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* to deal in the Software without restriction, including without limitation * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* and/or sell copies of the Software, and to permit persons to whom the * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* Software is furnished to do so, subject to the following conditions: * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* * DEALINGS IN THE SOFTWARE.
* 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.
*/ */
#ifndef __SIMPLE_COMP_H__ #ifndef __AUDIO_ALGO_CHUNKWARE_COMPRESSOR_H__
#define __SIMPLE_COMP_H__ #define __AUDIO_ALGO_CHUNKWARE_COMPRESSOR_H__
#include "header.h" #include "header.h"
#include "Envelope.h" #include "AttRelEnvelope.h"
#include "Gain.h" #include "Gain.h"
namespace audio { namespace audio {
namespace algo { namespace algo {
namespace chunkware { namespace chunkware {
//-------------------------------------------------------------
// compressor
//-------------------------------------------------------------
class Compresssor : public AttRelEnvelope { class Compresssor : public AttRelEnvelope {
public: public:
Compresssor(); Compresssor();
@ -68,25 +61,6 @@ namespace audio {
// runtime variables // runtime variables
double envdB_; //!< over-threshold envelope (dB) double envdB_; //!< over-threshold envelope (dB)
}; };
//-------------------------------------------------------------
// compressor with RMS detection
//-------------------------------------------------------------
class CompresssorRms : public Compresssor {
public:
CompresssorRms();
virtual ~CompresssorRms() {}
// sample rate
virtual void setSampleRate(double sampleRate);
// RMS window
virtual void setWindow(double ms);
virtual double getWindow() const { return ave_.getTc(); }
// runtime process
virtual void initRuntime(); // call before runtime (in resume())
void process(double &in1, double &in2); // compressor runtime process
protected:
EnvelopeDetector ave_; //!< averager
double aveOfSqrs_; //!< average of squares
};
} }
} }
} }

View File

@ -0,0 +1,66 @@
/**
* @author Bojan MARKOVIC
* @author Edouard DUPIN
* @copyright 2006, ChunkWare Music Software, OPEN-SOURCE
* @license BSD-1 (see license file)
*
* 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 "CompressorRms.h"
audio::algo::chunkware::CompresssorRms::CompresssorRms() :
ave_(5.0),
aveOfSqrs_(DC_OFFSET) {
}
void audio::algo::chunkware::CompresssorRms::setSampleRate(double sampleRate) {
audio::algo::chunkware::Compresssor::setSampleRate(sampleRate);
ave_.setSampleRate(sampleRate);
}
void audio::algo::chunkware::CompresssorRms::setWindow(double ms) {
ave_.setTc(ms);
}
void audio::algo::chunkware::CompresssorRms::initRuntime() {
audio::algo::chunkware::Compresssor::initRuntime();
aveOfSqrs_ = DC_OFFSET;
}
void audio::algo::chunkware::CompresssorRms::process(double &in1, double &in2) {
// create sidechain
double inSq1 = in1 * in1; // square input
double inSq2 = in2 * in2;
double sum = inSq1 + inSq2; // power summing
sum += DC_OFFSET; // DC offset, to prevent denormal
ave_.run(sum, aveOfSqrs_); // average of squares
double rms = sqrt(aveOfSqrs_); // rms (sort of ...)
/* REGARDING THE RMS AVERAGER: Ok, so this isn't a REAL RMS
* calculation. A true RMS is an FIR moving average. This
* approximation is a 1-pole IIR. Nonetheless, in practice,
* and in the interest of simplicity, this method will suffice,
* giving comparable results.
*/
// rest of process
Compresssor::process(in1, in2, rms);
}

View File

@ -0,0 +1,55 @@
/**
* @author Bojan MARKOVIC
* @author Edouard DUPIN
* @copyright 2006, ChunkWare Music Software, OPEN-SOURCE
* @license BSD-1 (see license file)
*
* 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.
*/
#ifndef __AUDIO_ALGO_CHUNKWARE_COMPRESSOR_RMS_H__
#define __AUDIO_ALGO_CHUNKWARE_COMPRESSOR_RMS_H__
#include "Compressor.h"
namespace audio {
namespace algo {
namespace chunkware {
class CompresssorRms : public Compresssor {
public:
CompresssorRms();
virtual ~CompresssorRms() {}
// sample rate
virtual void setSampleRate(double sampleRate);
// RMS window
virtual void setWindow(double ms);
virtual double getWindow() const { return ave_.getTc(); }
// runtime process
virtual void initRuntime(); // call before runtime (in resume())
void process(double &in1, double &in2); // compressor runtime process
protected:
EnvelopeDetector ave_; //!< averager
double aveOfSqrs_; //!< average of squares
};
}
}
}
#endif

View File

@ -1,81 +0,0 @@
/*
* Simple Envelope Detectors (source)
*
* File : SimpleEnvelope.cpp
* Library : SimpleSource
* Version : 1.12
* Implements : EnvelopeDetector, AttRelEnvelope
*
* © 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 "Envelope.h"
audio::algo::chunkware::EnvelopeDetector::EnvelopeDetector(double ms, double sampleRate) {
assert(sampleRate > 0.0);
assert(ms > 0.0);
sampleRate_ = sampleRate;
ms_ = ms;
setCoef();
}
void audio::algo::chunkware::EnvelopeDetector::setTc(double ms) {
assert(ms > 0.0);
ms_ = ms;
setCoef();
}
void audio::algo::chunkware::EnvelopeDetector::setSampleRate(double sampleRate) {
assert(sampleRate > 0.0);
sampleRate_ = sampleRate;
setCoef();
}
void audio::algo::chunkware::EnvelopeDetector::setCoef() {
coef_ = exp(-1000.0 / (ms_ * sampleRate_));
}
audio::algo::chunkware::AttRelEnvelope::AttRelEnvelope(double att_ms, double rel_ms, double sampleRate) :
att_(att_ms, sampleRate),
rel_(rel_ms, sampleRate) {
}
//-------------------------------------------------------------
void audio::algo::chunkware::AttRelEnvelope::setAttack(double ms) {
att_.setTc(ms);
}
//-------------------------------------------------------------
void audio::algo::chunkware::AttRelEnvelope::setRelease(double ms) {
rel_.setTc(ms);
}
//-------------------------------------------------------------
void audio::algo::chunkware::AttRelEnvelope::setSampleRate(double sampleRate) {
att_.setSampleRate(sampleRate);
rel_.setSampleRate(sampleRate);
}

View File

@ -1,121 +0,0 @@
/*
* Simple Envelope Detectors (header)
*
* File : SimpleEnvelope.h
* Library : SimpleSource
* Version : 1.12
* Class : EnvelopeDetector, AttRelEnvelope
*
* © 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.
*/
#ifndef __SIMPLE_ENVELOPE_H__
#define __SIMPLE_ENVELOPE_H__
#include "header.h"
namespace audio {
namespace algo {
namespace chunkware {
//-------------------------------------------------------------
// DC offset (to prevent denormal)
//-------------------------------------------------------------
// USE:
// 1. init envelope state to DC_OFFSET before processing
// 2. add to input before envelope runtime function
static const double DC_OFFSET = 1.0E-25;
//-------------------------------------------------------------
// envelope detector
//-------------------------------------------------------------
class EnvelopeDetector {
public:
EnvelopeDetector(double ms = 1.0,
double sampleRate = 44100.0);
virtual ~EnvelopeDetector() {}
// time constant
virtual void setTc(double ms);
virtual double getTc() const {
return ms_;
}
// sample rate
virtual void setSampleRate(double sampleRate);
virtual double getSampleRate() const {
return sampleRate_;
}
// runtime function
void run(double in, double &state) {
state = in + coef_ * (state - in);
}
protected:
double sampleRate_; //!< sample rate
double ms_; //!< time constant in ms
double coef_; //!< runtime coefficient
virtual void setCoef(); //!< coef calculation
};
//-------------------------------------------------------------
// attack/release envelope
//-------------------------------------------------------------
class AttRelEnvelope {
public:
AttRelEnvelope(double att_ms = 10.0,
double rel_ms = 100.0,
double sampleRate = 44100.0);
virtual ~AttRelEnvelope() {}
// attack time constant
virtual void setAttack(double ms);
virtual double getAttack() const {
return att_.getTc();
}
// release time constant
virtual void setRelease(double ms);
virtual double getRelease() const {
return rel_.getTc();
}
// sample rate dependencies
virtual void setSampleRate(double sampleRate);
virtual double getSampleRate() const {
return att_.getSampleRate();
}
// runtime function
void run(double in, double &state) {
/* assumes that:
* positive delta = attack
* negative delta = release
* good for linear & log values
*/
if (in > state) {
// attack
att_.run(in, state);
} else {
// release
rel_.run(in, state);
}
}
private:
EnvelopeDetector att_;
EnvelopeDetector rel_;
};
}
}
}
#endif

View File

@ -0,0 +1,51 @@
/**
* @author Bojan MARKOVIC
* @author Edouard DUPIN
* @copyright 2006, ChunkWare Music Software, OPEN-SOURCE
* @license BSD-1 (see license file)
*
* 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 "EnvelopeDetector.h"
audio::algo::chunkware::EnvelopeDetector::EnvelopeDetector(double ms, double sampleRate) {
assert(sampleRate > 0.0);
assert(ms > 0.0);
sampleRate_ = sampleRate;
ms_ = ms;
setCoef();
}
void audio::algo::chunkware::EnvelopeDetector::setTc(double ms) {
assert(ms > 0.0);
ms_ = ms;
setCoef();
}
void audio::algo::chunkware::EnvelopeDetector::setSampleRate(double sampleRate) {
assert(sampleRate > 0.0);
sampleRate_ = sampleRate;
setCoef();
}
void audio::algo::chunkware::EnvelopeDetector::setCoef() {
coef_ = exp(-1000.0 / (ms_ * sampleRate_));
}

View File

@ -0,0 +1,74 @@
/**
* @author Bojan MARKOVIC
* @author Edouard DUPIN
* @copyright 2006, ChunkWare Music Software, OPEN-SOURCE
* @license BSD-1 (see license file)
*
* 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.
*/
#ifndef __AUDIO_ALGO_CHUNKWARE_ENVELOPE_DETECTOR_H__
#define __AUDIO_ALGO_CHUNKWARE_ENVELOPE_DETECTOR_H__
#include "header.h"
namespace audio {
namespace algo {
namespace chunkware {
//-------------------------------------------------------------
// DC offset (to prevent denormal)
//-------------------------------------------------------------
// USE:
// 1. init envelope state to DC_OFFSET before processing
// 2. add to input before envelope runtime function
static const double DC_OFFSET = 1.0E-25;
//-------------------------------------------------------------
// envelope detector
//-------------------------------------------------------------
class EnvelopeDetector {
public:
EnvelopeDetector(double ms = 1.0,
double sampleRate = 44100.0);
virtual ~EnvelopeDetector() {}
// time constant
virtual void setTc(double ms);
virtual double getTc() const {
return ms_;
}
// sample rate
virtual void setSampleRate(double sampleRate);
virtual double getSampleRate() const {
return sampleRate_;
}
// runtime function
void run(double in, double &state) {
state = in + coef_ * (state - in);
}
protected:
double sampleRate_; //!< sample rate
double ms_; //!< time constant in ms
double coef_; //!< runtime coefficient
virtual void setCoef(); //!< coef calculation
};
}
}
}
#endif

View File

@ -1,35 +1,31 @@
/* /**
* Gain Functions (header) * @author Bojan MARKOVIC
* @author Edouard DUPIN
* @copyright 2006, ChunkWare Music Software, OPEN-SOURCE
* @license BSD-1 (see license file)
* *
* File : SimpleGain.h * Permission is hereby granted, free of charge, to any person obtaining a
* Library : SimpleSource * copy of this software and associated documentation files (the "Software"),
* Version : 1.12 * to deal in the Software without restriction, including without limitation
* Class : * 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:
* *
* © 2006, ChunkWare Music Software, OPEN-SOURCE * * The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* *
* Permission is hereby granted, free of charge, to any person obtaining a * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* copy of this software and associated documentation files (the "Software"), * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* to deal in the Software without restriction, including without limitation * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* and/or sell copies of the Software, and to permit persons to whom the * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* Software is furnished to do so, subject to the following conditions: * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* * DEALINGS IN THE SOFTWARE.
* 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.
*/ */
#ifndef __SIMPLE_GAIN_H__ #ifndef __AUDIO_ALGO_CHUNKWARE_GAIN_H__
#define __SIMPLE_GAIN_H__ #define __AUDIO_ALGO_CHUNKWARE_GAIN_H__
#include "header.h" #include "header.h"

View File

@ -1,30 +1,26 @@
/* /**
* Simple Gate (source) * @author Bojan MARKOVIC
* @author Edouard DUPIN
* @copyright 2006, ChunkWare Music Software, OPEN-SOURCE
* @license BSD-1 (see license file)
* *
* File : SimpleGate.cpp * Permission is hereby granted, free of charge, to any person obtaining a
* Library : SimpleSource * copy of this software and associated documentation files (the "Software"),
* Version : 1.12 * to deal in the Software without restriction, including without limitation
* Implements : SimpleGate, SimpleGateRms * 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:
* *
* © 2006, ChunkWare Music Software, OPEN-SOURCE * * The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* *
* Permission is hereby granted, free of charge, to any person obtaining a * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* copy of this software and associated documentation files (the "Software"), * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* to deal in the Software without restriction, including without limitation * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* and/or sell copies of the Software, and to permit persons to whom the * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* Software is furnished to do so, subject to the following conditions: * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* * DEALINGS IN THE SOFTWARE.
* 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.
*/ */

View File

@ -1,38 +1,34 @@
/* /**
* Simple Gate (header) * @author Bojan MARKOVIC
* @author Edouard DUPIN
* @copyright 2006, ChunkWare Music Software, OPEN-SOURCE
* @license BSD-1 (see license file)
* *
* File : SimpleGate.h * Permission is hereby granted, free of charge, to any person obtaining a
* Library : SimpleSource * copy of this software and associated documentation files (the "Software"),
* Version : 1.12 * to deal in the Software without restriction, including without limitation
* Class : SimpleGate, SimpleGateRms * 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:
* *
* © 2006, ChunkWare Music Software, OPEN-SOURCE * * The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* *
* Permission is hereby granted, free of charge, to any person obtaining a * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* copy of this software and associated documentation files (the "Software"), * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* to deal in the Software without restriction, including without limitation * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* and/or sell copies of the Software, and to permit persons to whom the * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* Software is furnished to do so, subject to the following conditions: * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* * DEALINGS IN THE SOFTWARE.
* 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.
*/ */
#ifndef __SIMPLE_GATE_H__ #ifndef __AUDIO_ALGO_CHUNKWARE_GATE_H__
#define __SIMPLE_GATE_H__ #define __AUDIO_ALGO_CHUNKWARE_GATE_H__
#include "header.h" #include "header.h"
#include "Envelope.h" #include "AttRelEnvelope.h"
#include "Gain.h" #include "Gain.h"
namespace audio { namespace audio {

View File

@ -1,30 +1,26 @@
/* /**
* Simple Limiter (source) * @author Bojan MARKOVIC
* @author Edouard DUPIN
* @copyright 2006, ChunkWare Music Software, OPEN-SOURCE
* @license BSD-1 (see license file)
* *
* File : SimpleLimit.cpp * Permission is hereby granted, free of charge, to any person obtaining a
* Library : SimpleSource * copy of this software and associated documentation files (the "Software"),
* Version : 1.12 * to deal in the Software without restriction, including without limitation
* Implements : SimpleLimit * 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:
* *
* © 2006, ChunkWare Music Software, OPEN-SOURCE * * The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* *
* Permission is hereby granted, free of charge, to any person obtaining a * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* copy of this software and associated documentation files (the "Software"), * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* to deal in the Software without restriction, including without limitation * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* and/or sell copies of the Software, and to permit persons to whom the * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* Software is furnished to do so, subject to the following conditions: * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* * DEALINGS IN THE SOFTWARE.
* 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.
*/ */

View File

@ -1,38 +1,34 @@
/* /**
* Simple Limiter (header) * @author Bojan MARKOVIC
* @author Edouard DUPIN
* @copyright 2006, ChunkWare Music Software, OPEN-SOURCE
* @license BSD-1 (see license file)
* *
* File : SimpleLimit.h * Permission is hereby granted, free of charge, to any person obtaining a
* Library : SimpleSource * copy of this software and associated documentation files (the "Software"),
* Version : 1.12 * to deal in the Software without restriction, including without limitation
* Class : SimpleLimit * 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:
* *
* © 2006, ChunkWare Music Software, OPEN-SOURCE * * The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* *
* Permission is hereby granted, free of charge, to any person obtaining a * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* copy of this software and associated documentation files (the "Software"), * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* to deal in the Software without restriction, including without limitation * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* and/or sell copies of the Software, and to permit persons to whom the * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* Software is furnished to do so, subject to the following conditions: * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* * DEALINGS IN THE SOFTWARE.
* 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.
*/ */
#ifndef __SIMPLE_LIMIT_H__ #ifndef __AUDIO_ALGO_CHUNKWARE_LIMITER_H__
#define __SIMPLE_LIMIT_H__ #define __AUDIO_ALGO_CHUNKWARE_LIMITER_H__
#include "header.h" #include "header.h"
#include "Envelope.h" #include "AttRelEnvelope.h"
#include "Gain.h" #include "Gain.h"
#include <vector> #include <vector>
@ -77,9 +73,10 @@ namespace audio {
// class for faster attack/release // class for faster attack/release
class FastEnvelope : public EnvelopeDetector { class FastEnvelope : public EnvelopeDetector {
public: public:
FastEnvelope(double ms = 1.0, double sampleRate = 44100.0) FastEnvelope(double ms = 1.0, double sampleRate = 44100.0) :
: EnvelopeDetector(ms, sampleRate) EnvelopeDetector(ms, sampleRate) {
{}
}
virtual ~FastEnvelope() {} virtual ~FastEnvelope() {}
protected: protected:
// override setCoef() - coefficient calculation // override setCoef() - coefficient calculation

View File

@ -1,14 +1,33 @@
/** @file /**
* @author Edouard DUPIN * @author Bojan MARKOVIC
* @copyright 2011, Edouard DUPIN, all right reserved * @author Edouard DUPIN
* @license APACHE v2.0 (see license file) * @copyright 2006, ChunkWare Music Software, OPEN-SOURCE
* @license BSD-1 (see license file)
*
* 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 "debug.h" #include "debug.h"
int32_t audio::algo::aec::getLogId() { int32_t audio::algo::chunkware::getLogId() {
static int32_t g_val = etk::log::registerInstance("audio-algo-aec"); static int32_t g_val = etk::log::registerInstance("audio-algo-chunkware");
return g_val; return g_val;
} }

View File

@ -1,40 +1,59 @@
/** @file /**
* @author Edouard DUPIN * @author Bojan MARKOVIC
* @copyright 2011, Edouard DUPIN, all right reserved * @author Edouard DUPIN
* @license APACHE v2.0 (see license file) * @copyright 2006, ChunkWare Music Software, OPEN-SOURCE
* @license BSD-1 (see license file)
*
* 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.
*/ */
#ifndef __APPL_DEBUG_H__ #ifndef __AUDIO_ALGO_CHUNKWARE_DEBUG_H__
#define __APPL_DEBUG_H__ #define __AUDIO_ALGO_CHUNKWARE_DEBUG_H__
#include <etk/log.h> #include <etk/log.h>
namespace audio { namespace audio {
namespace algo { namespace algo {
namespace aec { namespace chunkware {
int32_t getLogId(); int32_t getLogId();
} }
} }
} }
#define AA_AEC_BASE(info,data) TK_LOG_BASE(audio::algo::aec::getLogId(),info,data) #define AA_CHUNK_BASE(info,data) TK_LOG_BASE(audio::algo::chunkware::getLogId(),info,data)
#define AA_AEC_CRITICAL(data) AA_AEC_BASE(1, data) #define AA_CHUNK_CRITICAL(data) AA_CHUNK_BASE(1, data)
#define AA_AEC_ERROR(data) AA_AEC_BASE(2, data) #define AA_CHUNK_ERROR(data) AA_CHUNK_BASE(2, data)
#define AA_AEC_WARNING(data) AA_AEC_BASE(3, data) #define AA_CHUNK_WARNING(data) AA_CHUNK_BASE(3, data)
#ifdef DEBUG #ifdef DEBUG
#define AA_AEC_INFO(data) AA_AEC_BASE(4, data) #define AA_CHUNK_INFO(data) AA_CHUNK_BASE(4, data)
#define AA_AEC_DEBUG(data) AA_AEC_BASE(5, data) #define AA_CHUNK_DEBUG(data) AA_CHUNK_BASE(5, data)
#define AA_AEC_VERBOSE(data) AA_AEC_BASE(6, data) #define AA_CHUNK_VERBOSE(data) AA_CHUNK_BASE(6, data)
#define AA_AEC_TODO(data) AA_AEC_BASE(4, "TODO : " << data) #define AA_CHUNK_TODO(data) AA_CHUNK_BASE(4, "TODO : " << data)
#else #else
#define AA_AEC_INFO(data) do { } while(false) #define AA_CHUNK_INFO(data) do { } while(false)
#define AA_AEC_DEBUG(data) do { } while(false) #define AA_CHUNK_DEBUG(data) do { } while(false)
#define AA_AEC_VERBOSE(data) do { } while(false) #define AA_CHUNK_VERBOSE(data) do { } while(false)
#define AA_AEC_TODO(data) do { } while(false) #define AA_CHUNK_TODO(data) do { } while(false)
#endif #endif
#define AA_AEC_ASSERT(cond,data) \ #define AA_CHUNK_ASSERT(cond,data) \
do { \ do { \
if (!(cond)) { \ if (!(cond)) { \
APPL_CRITICAL(data); \ APPL_CRITICAL(data); \

View File

@ -1,43 +1,32 @@
/* /**
* Simple Source Common Header (header) * @author Bojan MARKOVIC
* @author Edouard DUPIN
* @copyright 2006, ChunkWare Music Software, OPEN-SOURCE
* @license BSD-1 (see license file)
* *
* File : SimpleHeader.h * Permission is hereby granted, free of charge, to any person obtaining a
* Library : SimpleSource * copy of this software and associated documentation files (the "Software"),
* Version : 1.12 * 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:
* *
* © 2006, ChunkWare Music Software, OPEN-SOURCE * * The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
* *
* Permission is hereby granted, free of charge, to any person obtaining a * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* copy of this software and associated documentation files (the "Software"), * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* to deal in the Software without restriction, including without limitation * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* and/or sell copies of the Software, and to permit persons to whom the * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* Software is furnished to do so, subject to the following conditions: * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* * DEALINGS IN THE SOFTWARE.
* 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.
*/ */
#ifndef __SIMPLE_HEADER_H__ #ifndef __SIMPLE_HEADER_H__
#define __SIMPLE_HEADER_H__ #define __SIMPLE_HEADER_H__
#if _MSC_VER > 1000
// MS Visual Studio
// for standard library min(), max()
#define NOMINMAX
// for math constants
#define _USE_MATH_DEFINES
#endif
#include <algorithm> #include <algorithm>
#include <cassert> #include <cassert>
#include <cmath> #include <cmath>

View File

@ -13,7 +13,8 @@ def create(target):
'audio/algo/chunkware/debug.cpp', 'audio/algo/chunkware/debug.cpp',
'audio/algo/chunkware/Compressor.cpp', 'audio/algo/chunkware/Compressor.cpp',
'audio/algo/chunkware/debug.cpp', 'audio/algo/chunkware/debug.cpp',
'audio/algo/chunkware/Envelope.cpp', 'audio/algo/chunkware/EnvelopeDetector.cpp',
'audio/algo/chunkware/AttRelEnvelope.cpp',
'audio/algo/chunkware/Gate.cpp', 'audio/algo/chunkware/Gate.cpp',
'audio/algo/chunkware/Limiter.cpp' 'audio/algo/chunkware/Limiter.cpp'
]) ])