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.
Diff: Clipper.h
- Revision:
- 1:bfbfd6fede05
- Child:
- 2:25adc1277b3e
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Clipper.h Tue Sep 01 10:04:14 2015 +0000 @@ -0,0 +1,63 @@ +//============================================================================= +// +//============================================================================= +#pragma once + +//--------------------------------------------- +// Clipper, Base class. +//--------------------------------------------- +class Clipper +{ +public: + virtual float process( float samp ) = 0; +}; + +//--------------------------------------------- +// Simple clipper. +//--------------------------------------------- +class SimpleClipper : public Clipper +{ +private: + float clip; + +public: + SimpleClipper( float c = 0.2f ) + { + clip = c; + } + virtual float process( float samp ) + { + if( samp > clip ) { + return clip; + } else { + return samp; + } + } +}; + +//--------------------------------------------- +// Simple clipper. +//--------------------------------------------- +class SoftClipper : public Clipper +{ +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; + } + } +}; +