Flan
r8bbase.h
Go to the documentation of this file.
1 //$ nobt
2 
60 #ifndef R8BBASE_INCLUDED
61 #define R8BBASE_INCLUDED
62 
63 #include <stdlib.h>
64 #include <stdint.h>
65 #include <string.h>
66 #include <math.h>
67 #include "r8bconf.h"
68 
69 #if defined( R8B_WIN )
70  #include <windows.h>
71 #else // R8B_WIN
72  #include <pthread.h>
73 #endif // R8B_WIN
74 
81 namespace r8b {
82 
87 #define R8B_VERSION "4.6"
88 
89 #if !defined( M_PI )
90 
94  #define M_PI 3.14159265358979324
95 #endif // M_PI
96 
97 #if !defined( M_2PI )
98 
103  #define M_2PI 6.28318530717958648
104 #endif // M_2PI
105 
106 #if !defined( M_3PI )
107 
112  #define M_3PI 9.42477796076937972
113 #endif // M_3PI
114 
115 #if !defined( M_4PI )
116 
121  #define M_4PI 12.56637061435917295
122 #endif // M_4PI
123 
124 #if !defined( M_PId2 )
125 
130  #define M_PId2 1.57079632679489662
131 #endif // M_PId2
132 
144 #define R8BNOCTOR( ClassName ) \
145  private: \
146  ClassName( const ClassName& ) { } \
147  ClassName& operator = ( const ClassName& ) { return( *this ); }
148 
157 {
158 public:
165  void* operator new( size_t, void* p )
166  {
167  return( p );
168  }
169 
175  void* operator new( size_t n )
176  {
177  return( :: malloc( n ));
178  }
179 
185  void* operator new[]( size_t n )
186  {
187  return( :: malloc( n ));
188  }
189 
196  void operator delete( void* p )
197  {
198  :: free( p );
199  }
200 
207  void operator delete[]( void* p )
208  {
209  :: free( p );
210  }
211 };
212 
220 {
221 public:
229  static void* allocmem( const size_t Size )
230  {
231  return( :: malloc( Size ));
232  }
233 
242  static void* reallocmem( void* p, const size_t Size )
243  {
244  return( :: realloc( p, Size ));
245  }
246 
253  static void freemem( void* p )
254  {
255  :: free( p );
256  }
257 };
258 
277 template< class T >
279 {
281 
282 public:
283  CFixedBuffer()
284  : Data0( NULL )
285  , Data( NULL )
286  {
287  }
288 
296  CFixedBuffer( const int Capacity )
297  {
298  R8BASSERT( Capacity > 0 || Capacity == 0 );
299 
300  Data0 = allocmem( Capacity * sizeof( T ) + Alignment );
301  Data = (T*) alignptr( Data0, Alignment );
302 
303  R8BASSERT( Data0 != NULL || Capacity == 0 );
304  }
305 
306  ~CFixedBuffer()
307  {
308  freemem( Data0 );
309  }
310 
318  void alloc( const int Capacity )
319  {
320  R8BASSERT( Capacity > 0 || Capacity == 0 );
321 
322  freemem( Data0 );
323  Data0 = allocmem( Capacity * sizeof( T ) + Alignment );
324  Data = (T*) alignptr( Data0, Alignment );
325 
326  R8BASSERT( Data0 != NULL || Capacity == 0 );
327  }
328 
338  void realloc( const int PrevCapacity, const int NewCapacity )
339  {
340  R8BASSERT( PrevCapacity >= 0 );
341  R8BASSERT( NewCapacity >= 0 );
342 
343  void* const NewData0 = allocmem( NewCapacity * sizeof( T ) +
344  Alignment );
345 
346  T* const NewData = (T*) alignptr( NewData0, Alignment );
347  const size_t CopySize = ( PrevCapacity > NewCapacity ?
348  NewCapacity : PrevCapacity ) * sizeof( T );
349 
350  if( CopySize > 0 )
351  {
352  memcpy( NewData, Data, CopySize );
353  }
354 
355  freemem( Data0 );
356  Data0 = NewData0;
357  Data = NewData;
358 
359  R8BASSERT( Data0 != NULL || NewCapacity == 0 );
360  }
361 
366  void free()
367  {
368  freemem( Data0 );
369  Data0 = NULL;
370  Data = NULL;
371  }
372 
378  T* getPtr() const
379  {
380  return( Data );
381  }
382 
388  operator T* () const
389  {
390  return( Data );
391  }
392 
393 private:
394  static const size_t Alignment = 32;
395  void* Data0;
397  T* Data;
399 
409  template< class Tp >
410  inline Tp alignptr( const Tp ptr, const uintptr_t align )
411  {
412  return( (Tp) ( (uintptr_t) ptr + align -
413  ( (uintptr_t) ptr & ( align - 1 ))) );
414  }
415 };
416 
428 template< class T >
430 {
432 
433 public:
434  CPtrKeeper()
435  : Object( NULL )
436  {
437  }
438 
445  template< class T2 >
446  CPtrKeeper( T2 const aObject )
447  : Object( aObject )
448  {
449  }
450 
451  ~CPtrKeeper()
452  {
453  delete Object;
454  }
455 
463  template< class T2 >
464  void operator = ( T2 const aObject )
465  {
466  reset();
467  Object = aObject;
468  }
469 
474  T operator -> () const
475  {
476  return( Object );
477  }
478 
483  operator T () const
484  {
485  return( Object );
486  }
487 
492  void reset()
493  {
494  T DelObj = Object;
495  Object = NULL;
496  delete DelObj;
497  }
498 
504  T unkeep()
505  {
506  T ResObject = Object;
507  Object = NULL;
508  return( ResObject );
509  }
510 
511 private:
512  T Object;
513 };
515 
527 {
529 
530 public:
531  CSyncObject()
532  {
533  #if defined( R8B_WIN )
534  InitializeCriticalSectionAndSpinCount( &CritSec, 4000 );
535  #else // R8B_WIN
536  pthread_mutexattr_t MutexAttrs;
537  pthread_mutexattr_init( &MutexAttrs );
538  pthread_mutexattr_settype( &MutexAttrs, PTHREAD_MUTEX_RECURSIVE );
539  pthread_mutex_init( &Mutex, &MutexAttrs );
540  pthread_mutexattr_destroy( &MutexAttrs );
541  #endif // R8B_WIN
542  }
543 
544  ~CSyncObject()
545  {
546  #if defined( R8B_WIN )
547  DeleteCriticalSection( &CritSec );
548  #else // R8B_WIN
549  pthread_mutex_destroy( &Mutex );
550  #endif // R8B_WIN
551  }
552 
558  void acquire()
559  {
560  #if defined( R8B_WIN )
561  EnterCriticalSection( &CritSec );
562  #else // R8B_WIN
563  pthread_mutex_lock( &Mutex );
564  #endif // R8B_WIN
565  }
566 
572  void release()
573  {
574  #if defined( R8B_WIN )
575  LeaveCriticalSection( &CritSec );
576  #else // R8B_WIN
577  pthread_mutex_unlock( &Mutex );
578  #endif // R8B_WIN
579  }
580 
581 private:
582  #if defined( R8B_WIN )
583  CRITICAL_SECTION CritSec;
584  #else // R8B_WIN
587  pthread_mutex_t Mutex;
588  #endif // R8B_WIN
590 };
591 
603 {
605 
606 public:
607  CSyncKeeper()
608  : SyncObj( NULL )
609  {
610  }
611 
617  CSyncKeeper( CSyncObject* const aSyncObj )
618  : SyncObj( aSyncObj )
619  {
620  if( SyncObj != NULL )
621  {
622  SyncObj -> acquire();
623  }
624  }
625 
632  : SyncObj( &aSyncObj )
633  {
634  SyncObj -> acquire();
635  }
636 
637  ~CSyncKeeper()
638  {
639  if( SyncObj != NULL )
640  {
641  SyncObj -> release();
642  }
643  }
644 
645 protected:
647 };
649 
664 #define R8BSYNC( SyncObject ) R8BSYNC_( SyncObject, __LINE__ )
665 #define R8BSYNC_( SyncObject, id ) R8BSYNC__( SyncObject, id )
666 #define R8BSYNC__( SyncObject, id ) CSyncKeeper SyncKeeper##id( SyncObject )
667 
674 class CSineGen
675 {
676 public:
677  CSineGen()
678  {
679  }
680 
689  CSineGen( const double si, const double ph )
690  : svalue1( sin( ph ))
691  , svalue2( sin( ph - si ))
692  , sincr( 2.0 * cos( si ))
693  {
694  }
695 
706  CSineGen( const double si, const double ph, const double g )
707  : svalue1( sin( ph ) * g )
708  , svalue2( sin( ph - si ) * g )
709  , sincr( 2.0 * cos( si ))
710  {
711  }
712 
721  void init( const double si, const double ph )
722  {
723  svalue1 = sin( ph );
724  svalue2 = sin( ph - si );
725  sincr = 2.0 * cos( si );
726  }
727 
738  void init( const double si, const double ph, const double g )
739  {
740  svalue1 = sin( ph ) * g;
741  svalue2 = sin( ph - si ) * g;
742  sincr = 2.0 * cos( si );
743  }
744 
749  double generate()
750  {
751  const double res = svalue1;
752 
753  svalue1 = sincr * res - svalue2;
754  svalue2 = res;
755 
756  return( res );
757  }
758 
759 private:
760  double svalue1;
761  double svalue2;
763  double sincr;
765 };
767 
775 inline int getBitOccupancy( const int v )
776 {
777  static const char OccupancyTable[] =
778  {
779  1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4,
780  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
781  6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
782  6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
783  7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
784  7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
785  7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
786  7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
787  8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
788  8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
789  8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
790  8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
791  8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
792  8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
793  8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
794  8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8
795  };
796 
797  const int tt = v >> 16;
798 
799  if( tt != 0 )
800  {
801  const int t = v >> 24;
802  return( t != 0 ? 24 + OccupancyTable[ t & 0xFF ] :
803  16 + OccupancyTable[ tt ]);
804  }
805  else
806  {
807  const int t = v >> 8;
808  return( t != 0 ? 8 + OccupancyTable[ t ] : OccupancyTable[ v ]);
809  }
810 }
811 
824 inline void calcFIRFilterResponse( const double* flt, int fltlen,
825  const double th, double& re0, double& im0, const int fltlat = 0 )
826 {
827  const double sincr = 2.0 * cos( th );
828  double cvalue1;
829  double svalue1;
830 
831  if( fltlat == 0 )
832  {
833  cvalue1 = 1.0;
834  svalue1 = 0.0;
835  }
836  else
837  {
838  cvalue1 = cos( -fltlat * th );
839  svalue1 = sin( -fltlat * th );
840  }
841 
842  double cvalue2 = cos( -( fltlat + 1 ) * th );
843  double svalue2 = sin( -( fltlat + 1 ) * th );
844 
845  double re = 0.0;
846  double im = 0.0;
847 
848  while( fltlen > 0 )
849  {
850  re += cvalue1 * flt[ 0 ];
851  im += svalue1 * flt[ 0 ];
852  flt++;
853  fltlen--;
854 
855  double tmp = cvalue1;
856  cvalue1 = sincr * cvalue1 - cvalue2;
857  cvalue2 = tmp;
858 
859  tmp = svalue1;
860  svalue1 = sincr * svalue1 - svalue2;
861  svalue2 = tmp;
862  }
863 
864  re0 = re;
865  im0 = im;
866 }
867 
882 inline void calcFIRFilterResponseAndGroupDelay( const double* const flt,
883  const int fltlen, const double th, double& re, double& im, double& gd )
884 {
885  // Calculate response at "th".
886 
887  calcFIRFilterResponse( flt, fltlen, th, re, im );
888 
889  // Calculate response at close sideband frequencies.
890 
891  const int Count = 2;
892  const double thd2 = 1e-9;
893  double ths[ Count ] = { th - thd2, th + thd2 };
894 
895  if( ths[ 0 ] < 0.0 )
896  {
897  ths[ 0 ] = 0.0;
898  }
899 
900  if( ths[ 1 ] > M_PI )
901  {
902  ths[ 1 ] = M_PI;
903  }
904 
905  double ph1[ Count ];
906  int i;
907 
908  for( i = 0; i < Count; i++ )
909  {
910  double re1;
911  double im1;
912 
913  calcFIRFilterResponse( flt, fltlen, ths[ i ], re1, im1 );
914  ph1[ i ] = atan2( im1, re1 );
915  }
916 
917  if( fabs( ph1[ 1 ] - ph1[ 0 ]) > M_PI )
918  {
919  if( ph1[ 1 ] > ph1[ 0 ])
920  {
921  ph1[ 1 ] -= M_2PI;
922  }
923  else
924  {
925  ph1[ 1 ] += M_2PI;
926  }
927  }
928 
929  const double thd = ths[ 1 ] - ths[ 0 ];
930  gd = ( ph1[ 1 ] - ph1[ 0 ]) / thd;
931 }
932 
943 inline void normalizeFIRFilter( double* const p, const int l,
944  const double DCGain, const int pstep = 1 )
945 {
946  R8BASSERT( l > 0 );
947  R8BASSERT( pstep != 0 );
948 
949  double s = 0.0;
950  double* pp = p;
951  int i = l;
952 
953  while( i > 0 )
954  {
955  s += *pp;
956  pp += pstep;
957  i--;
958  }
959 
960  s = DCGain / s;
961  pp = p;
962  i = l;
963 
964  while( i > 0 )
965  {
966  *pp *= s;
967  pp += pstep;
968  i--;
969  }
970 }
971 
987 inline void calcSpline3p8Coeffs( double* c, const double xm3,
988  const double xm2, const double xm1, const double x0, const double x1,
989  const double x2, const double x3, const double x4 )
990 {
991  c[ 0 ] = x0;
992  c[ 1 ] = ( 61.0 * ( x1 - xm1 ) + 16.0 * ( xm2 - x2 ) +
993  3.0 * ( x3 - xm3 )) / 76.0;
994 
995  c[ 2 ] = ( 106.0 * ( xm1 + x1 ) + 10.0 * x3 + 6.0 * xm3 - 3.0 * x4 -
996  29.0 * ( xm2 + x2 ) - 167.0 * x0 ) / 76.0;
997 
998  c[ 3 ] = ( 91.0 * ( x0 - x1 ) + 45.0 * ( x2 - xm1 ) +
999  13.0 * ( xm2 - x3 ) + 3.0 * ( x4 - xm3 )) / 76.0;
1000 }
1001 
1019 inline void calcSpline2p8Coeffs( double* c, const double xm3,
1020  const double xm2, const double xm1, const double x0, const double x1,
1021  const double x2, const double x3, const double x4 )
1022 {
1023  c[ 0 ] = x0;
1024  c[ 1 ] = ( 61.0 * ( x1 - xm1 ) + 16.0 * ( xm2 - x2 ) +
1025  3.0 * ( x3 - xm3 )) / 76.0;
1026 
1027  c[ 2 ] = ( 106.0 * ( xm1 + x1 ) + 10.0 * x3 + 6.0 * xm3 - 3.0 * x4 -
1028  29.0 * ( xm2 + x2 ) - 167.0 * x0 ) / 76.0;
1029 }
1030 
1040 inline void calcInterpCoeffs3p4( double* const c, const double* const y )
1041 {
1042  c[ 0 ] = y[ 1 ];
1043  c[ 1 ] = 0.5 * ( y[ 2 ] - y[ 0 ]);
1044  c[ 2 ] = y[ 0 ] - 2.5 * y[ 1 ] + y[ 2 ] + y[ 2 ] - 0.5 * y[ 3 ];
1045  c[ 3 ] = 0.5 * ( y[ 3 ] - y[ 0 ] ) + 1.5 * ( y[ 1 ] - y[ 2 ]);
1046 }
1047 
1057 inline void calcInterpCoeffs3p6( double* const c, const double* const y )
1058 {
1059  c[ 0 ] = y[ 2 ];
1060  c[ 1 ] = ( 11.0 * ( y[ 3 ] - y[ 1 ]) + 2.0 * ( y[ 0 ] - y[ 4 ])) / 14.0;
1061  c[ 2 ] = ( 20.0 * ( y[ 1 ] + y[ 3 ]) + 2.0 * y[ 5 ] - 4.0 * y[ 0 ] -
1062  7.0 * y[ 4 ] - 31.0 * y[ 2 ]) / 14.0;
1063 
1064  c[ 3 ] = ( 17.0 * ( y[ 2 ] - y[ 3 ]) + 9.0 * ( y[ 4 ] - y[ 1 ]) +
1065  2.0 * ( y[ 0 ] - y[ 5 ])) / 14.0;
1066 }
1067 
1077 inline void calcInterpCoeffs3p8( double* const c, const double* const y )
1078 {
1079  c[ 0 ] = y[ 3 ];
1080  c[ 1 ] = ( 61.0 * ( y[ 4 ] - y[ 2 ]) + 16.0 * ( y[ 1 ] - y[ 5 ]) +
1081  3.0 * ( y[ 6 ] - y[ 0 ])) / 76.0;
1082 
1083  c[ 2 ] = ( 106.0 * ( y[ 2 ] + y[ 4 ]) + 10.0 * y[ 6 ] + 6.0 * y[ 0 ] -
1084  3.0 * y[ 7 ] - 29.0 * ( y[ 1 ] + y[ 5 ]) - 167.0 * y[ 3 ]) / 76.0;
1085 
1086  c[ 3 ] = ( 91.0 * ( y[ 3 ] - y[ 4 ]) + 45.0 * ( y[ 5 ] - y[ 2 ]) +
1087  13.0 * ( y[ 1 ] - y[ 6 ]) + 3.0 * ( y[ 7 ] - y[ 0 ])) / 76.0;
1088 }
1089 
1099 inline void calcInterpCoeffs2p8( double* const c, const double* const y )
1100 {
1101  c[ 0 ] = y[ 3 ];
1102  c[ 1 ] = ( 61.0 * ( y[ 4 ] - y[ 2 ]) + 16.0 * ( y[ 1 ] - y[ 5 ]) +
1103  3.0 * ( y[ 6 ] - y[ 0 ])) / 76.0;
1104 
1105  c[ 2 ] = ( 106.0 * ( y[ 2 ] + y[ 4 ]) + 10.0 * y[ 6 ] + 6.0 * y[ 0 ] -
1106  3.0 * y[ 7 ] - 29.0 * ( y[ 1 ] + y[ 5 ]) - 167.0 * y[ 3 ]) / 76.0;
1107 }
1108 
1109 #if !defined( min )
1110 
1117 template< class T >
1118 inline T min( const T& v1, const T& v2 )
1119 {
1120  return( v1 < v2 ? v1 : v2 );
1121 }
1122 
1123 #endif // min
1124 
1125 #if !defined( max )
1126 
1133 template< class T >
1134 inline T max( const T& v1, const T& v2 )
1135 {
1136  return( v1 > v2 ? v1 : v2 );
1137 }
1138 
1139 #endif // max
1140 
1151 inline double clampr( const double Value, const double minv,
1152  const double maxv )
1153 {
1154  if( Value < minv )
1155  {
1156  return( minv );
1157  }
1158  else
1159  if( Value > maxv )
1160  {
1161  return( maxv );
1162  }
1163  else
1164  {
1165  return( Value );
1166  }
1167 }
1168 
1174 inline double sqr( const double x )
1175 {
1176  return( x * x );
1177 }
1178 
1185 inline double pows( const double v, const double p )
1186 {
1187  return( v < 0.0 ? -pow( -v, p ) : pow( v, p ));
1188 }
1189 
1195 inline double gauss( const double v )
1196 {
1197  return( exp( -( v * v )));
1198 }
1199 
1205 inline double asinh( const double v )
1206 {
1207  return( log( v + sqrt( v * v + 1.0 )));
1208 }
1209 
1216 inline double besselI0( const double x )
1217 {
1218  const double ax = fabs( x );
1219  double y;
1220 
1221  if( ax < 3.75 )
1222  {
1223  y = x / 3.75;
1224  y *= y;
1225 
1226  return( 1.0 + y * ( 3.5156229 + y * ( 3.0899424 + y * ( 1.2067492 +
1227  y * ( 0.2659732 + y * ( 0.360768e-1 + y * 0.45813e-2 ))))));
1228  }
1229 
1230  y = 3.75 / ax;
1231 
1232  return( exp( ax ) / sqrt( ax ) * ( 0.39894228 + y * ( 0.1328592e-1 +
1233  y * ( 0.225319e-2 + y * ( -0.157565e-2 + y * ( 0.916281e-2 +
1234  y * ( -0.2057706e-1 + y * ( 0.2635537e-1 + y * ( -0.1647633e-1 +
1235  y * 0.392377e-2 )))))))));
1236 }
1237 
1238 } // namespace r8b
1239 
1240 #endif // R8BBASE_INCLUDED
Sine signal generator class.
Definition: r8bbase.h:674
double asinh(const double v)
Definition: r8bbase.h:1205
double clampr(const double Value, const double minv, const double maxv)
Function "clamps" (clips) the specified value so that it is not lesser than "minv", and not greater than "maxv".
Definition: r8bbase.h:1151
int getBitOccupancy(const int v)
Definition: r8bbase.h:775
#define M_2PI
The M_2PI macro equals to "2 * pi" constant, fits 53-bit floating point mantissa. ...
Definition: r8bbase.h:103
CFixedBuffer(const int Capacity)
Constructor allocates memory so that the specified number of elements of type T can be stored in *thi...
Definition: r8bbase.h:296
void calcInterpCoeffs3p8(double *const c, const double *const y)
Function calculates coefficients used to calculate 3rd order segment interpolation polynomial on the ...
Definition: r8bbase.h:1077
void calcSpline2p8Coeffs(double *c, const double xm3, const double xm2, const double xm1, const double x0, const double x1, const double x2, const double x3, const double x4)
Function calculates coefficients used to calculate 2rd order spline (polynomial) on the equidistant l...
Definition: r8bbase.h:1019
#define R8BASSERT(e)
Assertion macro used to check for certain run-time conditions.
Definition: r8bconf.h:72
static void freemem(void *p)
Function frees a previously allocated memory block.
Definition: r8bbase.h:253
CPtrKeeper(T2 const aObject)
Constructor assigns a pointer to object to *this keeper.
Definition: r8bbase.h:446
void normalizeFIRFilter(double *const p, const int l, const double DCGain, const int pstep=1)
Function normalizes FIR filter so that its frequency response at DC is equal to DCGain.
Definition: r8bbase.h:943
void reset()
Function resets the keeped pointer and deletes the keeped object.
Definition: r8bbase.h:492
A "keeper" class for CSyncObject-based synchronization.
Definition: r8bbase.h:602
Pointer-to-object "keeper" class with automatic deletion.
Definition: r8bbase.h:429
void acquire()
Function "acquires" *this thread synchronizer object immediately or waits until another thread releas...
Definition: r8bbase.h:558
T unkeep()
Definition: r8bbase.h:504
The "configuration" inclusion file you can modify.
CSyncKeeper(CSyncObject *const aSyncObj)
Definition: r8bbase.h:617
void calcFIRFilterResponseAndGroupDelay(const double *const flt, const int fltlen, const double th, double &re, double &im, double &gd)
Function calculates frequency response and group delay of the specified FIR filter at the specified c...
Definition: r8bbase.h:882
#define R8B_MEMALLOCCLASS
Macro defines the name of the class that implements raw memory allocation functions, see the r8b::CStdMemAllocator class for details.
Definition: r8bconf.h:108
#define R8BNOCTOR(ClassName)
A special macro that defines empty copy-constructor and copy operator with the "private:" prefix...
Definition: r8bbase.h:144
void calcInterpCoeffs3p6(double *const c, const double *const y)
Function calculates coefficients used to calculate 3rd order segment interpolation polynomial on the ...
Definition: r8bbase.h:1057
Multi-threaded synchronization object class.
Definition: r8bbase.h:526
void calcFIRFilterResponse(const double *flt, int fltlen, const double th, double &re0, double &im0, const int fltlat=0)
Function calculates frequency response of the specified FIR filter at the specified circular frequenc...
Definition: r8bbase.h:824
CSyncObject * SyncObj
Sync object in use (can be NULL).
Definition: r8bbase.h:646
T max(const T &v1, const T &v2)
Definition: r8bbase.h:1134
T min(const T &v1, const T &v2)
Definition: r8bbase.h:1118
void calcInterpCoeffs2p8(double *const c, const double *const y)
Function calculates coefficients used to calculate 3rd order segment interpolation polynomial on the ...
Definition: r8bbase.h:1099
double gauss(const double v)
Definition: r8bbase.h:1195
double pows(const double v, const double p)
Definition: r8bbase.h:1185
void init(const double si, const double ph, const double g)
Function initializes *this sine signal generator.
Definition: r8bbase.h:738
double sqr(const double x)
Definition: r8bbase.h:1174
#define M_PI
The macro equals to "pi" constant, fits 53-bit floating point mantissa.
Definition: r8bbase.h:94
void calcInterpCoeffs3p4(double *const c, const double *const y)
Function calculates coefficients used to calculate 3rd order segment interpolation polynomial on the ...
Definition: r8bbase.h:1040
static void * allocmem(const size_t Size)
Function allocates memory block.
Definition: r8bbase.h:229
CSineGen(const double si, const double ph)
Constructor initializes *this sine signal generator.
Definition: r8bbase.h:689
CSyncKeeper(CSyncObject &aSyncObj)
Definition: r8bbase.h:631
void realloc(const int PrevCapacity, const int NewCapacity)
Function reallocates memory so that the specified number of elements of type T can be stored in *this...
Definition: r8bbase.h:338
double generate()
Definition: r8bbase.h:749
CSineGen(const double si, const double ph, const double g)
Constructor initializes *this sine signal generator.
Definition: r8bbase.h:706
double besselI0(const double x)
Definition: r8bbase.h:1216
void free()
Function deallocates a previously allocated buffer.
Definition: r8bbase.h:366
Templated memory buffer class for element buffers of fixed capacity.
Definition: r8bbase.h:278
void calcSpline3p8Coeffs(double *c, const double xm3, const double xm2, const double xm1, const double x0, const double x1, const double x2, const double x3, const double x4)
Function calculates coefficients used to calculate 3rd order spline (polynomial) on the equidistant l...
Definition: r8bbase.h:987
The default base class for objects that allocate blocks of memory.
Definition: r8bbase.h:219
T * getPtr() const
Definition: r8bbase.h:378
void release()
Function "releases" *this previously acquired thread synchronizer object.
Definition: r8bbase.h:572
The "r8brain-free-src" library namespace.
Definition: CDSPBlockConvolver.h:21
void init(const double si, const double ph)
Function initializes *this sine signal generator.
Definition: r8bbase.h:721
void alloc(const int Capacity)
Function allocates memory so that the specified number of elements of type T can be stored in *this b...
Definition: r8bbase.h:318
The default base class for objects created on heap.
Definition: r8bbase.h:156
static void * reallocmem(void *p, const size_t Size)
Function reallocates a previously allocated memory block.
Definition: r8bbase.h:242