Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Clipper.h
- Committer:
- vaifreak
- Date:
- 2015-09-18
- Revision:
- 3:1666e2d5bd46
- Parent:
- 2:25adc1277b3e
File content as of revision 3:1666e2d5bd46:
//=============================================================================
// @author vaifreak
// @brief clipper sub unit ( for Drive )
//=============================================================================
#pragma once
//---------------------------------------------
// Clipper, Base class.
//---------------------------------------------
class ClipperBase
{
public:
virtual float Process( float samp ) = 0;
};
//---------------------------------------------
// Simple clipper.
//---------------------------------------------
class SimpleClipper : public ClipperBase
{
private:
float clip;
public:
SimpleClipper( float c = 0.1f )
{
clip = c;
}
virtual float Process( float samp )
{
if( samp > clip ) {
return clip;
} else {
return samp;
}
}
};
//---------------------------------------------
// Simple clipper.
//---------------------------------------------
class SoftClipper : public ClipperBase
{
private:
float clip;
float comp_k;
public:
SoftClipper( float c = 0.05f, float k = 0.01f )
{
clip = c;
comp_k = k;
}
virtual float Process( float samp )
{
if( samp > clip ) {
return clip + (samp-clip)*comp_k;
} else {
return samp;
}
}
};