00001 #ifndef INCLUDE_BREAKPOINTUTILS_H
00002 #define INCLUDE_BREAKPOINTUTILS_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include "Breakpoint.h"
00037 #include <algorithm>
00038 #include <functional>
00039
00040
00041 namespace Loris {
00042
00043 namespace BreakpointUtils {
00044
00045
00046
00047
00048
00049
00057
00058 inline void addNoiseEnergy( Breakpoint & bp, double enoise )
00059 {
00060 bp.addNoiseEnergy(enoise);
00061 }
00062
00063
00064
00065
00074
00075 Breakpoint makeNullBefore( const Breakpoint & bp, double fadeTime );
00076
00077
00078
00079
00080
00089
00090 Breakpoint makeNullAfter( const Breakpoint & bp, double fadeTime );
00091
00092
00093
00094
00095
00096
00099
00100 class isFrequencyBetween :
00101 public std::unary_function< const Breakpoint, bool >
00102 {
00103 public:
00106 bool operator()( const Breakpoint & b ) const
00107 {
00108 return (b.frequency() > _fmin) &&
00109 (b.frequency() < _fmax);
00110 }
00111
00112
00113
00115 isFrequencyBetween( double x, double y ) :
00116 _fmin( x ), _fmax( y )
00117 {
00118 if (x>y) std::swap(x,y);
00119 }
00120
00121
00122 private:
00123 double _fmin, _fmax;
00124 };
00125
00128 typedef isFrequencyBetween frequency_between;
00129
00130
00131
00132
00135
00136 static bool isNonNull( const Breakpoint & bp )
00137 {
00138 return bp.amplitude() != 0.;
00139 }
00140
00141
00142
00143
00146
00147 static bool isNull( const Breakpoint & bp )
00148 {
00149 return ! isNonNull( bp );
00150 }
00151
00152
00153
00154
00155
00156
00160
00161 class compareFrequencyLess :
00162 public std::binary_function< const Breakpoint, const Breakpoint, bool >
00163 {
00164 public:
00167 bool operator()( const Breakpoint & lhs, const Breakpoint & rhs ) const
00168 { return lhs.frequency() < rhs.frequency(); }
00169 };
00170
00173 typedef compareFrequencyLess less_frequency;
00174
00175
00176
00177
00181
00182 class compareAmplitudeGreater :
00183 public std::binary_function< const Breakpoint, const Breakpoint, bool >
00184 {
00185 public:
00188 bool operator()( const Breakpoint & lhs, const Breakpoint & rhs ) const
00189 { return lhs.amplitude() > rhs.amplitude(); }
00190 };
00191
00194 typedef compareAmplitudeGreater greater_amplitude;
00195
00196
00197
00198
00202
00203 class compareAmplitudeLess :
00204 public std::binary_function< const Breakpoint, const Breakpoint, bool >
00205 {
00206 public:
00209 bool operator()( const Breakpoint & lhs, const Breakpoint & rhs ) const
00210 { return lhs.amplitude() < rhs.amplitude(); }
00211 };
00212
00213 }
00214
00215 }
00216
00217 #endif