r8brain-free-src
High-quality pro audio sample rate converter library
 
Loading...
Searching...
No Matches
r8bbase.h File Reference

The "base" header file with basic classes and functions. More...

#include <stdint.h>
#include <string.h>
#include <math.h>
#include <pthread.h>
#include "r8bconf.h"

Go to the source code of this file.

Classes

class  r8b::CFixedBuffer< T >
 Templated memory buffer class for element buffers of fixed capacity. More...
 
class  r8b::CPtrKeeper< T >
 Pointer-to-object "keeper" class with automatic deletion. More...
 
class  r8b::CSineGen
 Sine signal generator class. More...
 
class  r8b::CStdClassAllocator
 The default base class for objects created on heap. More...
 
class  r8b::CStdMemAllocator
 The default base class for objects that allocate blocks of memory. More...
 
class  r8b::CSyncKeeper
 A "keeper" class for CSyncObject-based synchronization. More...
 
class  r8b::CSyncObject
 Multi-threaded synchronization object class. More...
 

Namespaces

namespace  r8b
 The "r8brain-free-src" library namespace.
 

Macros

#define R8B_CONST   static const
 The prefix for constant definitions, portable between C++11 and earlier C++ versions.
 
#define R8B_EXITDTOR
 Macro that defines the attribute specifying that the exit-time destructor should be called for a static variable (suppresses a compiler warning).
 
#define R8B_NULL   NULL
 The "null pointer" value, portable between C++11 and earlier C++ versions.
 
#define R8B_VERSION   "7.0"
 Macro defines r8brain-free-src version string.
 
#define R8BNOCTOR(ClassName)
 Macro that defines empty copy-constructor and copy operator with the "private:" prefix.
 
#define R8BSYNC(SyncObject)
 Thread synchronization macro.
 
#define R8BSYNC1(SyncObject, id)
 Aux macro.
 
#define R8BSYNC2(SyncObject, id)
 Aux macro.
 

Functions

template<typename T>
T * r8b::alignptr (T *const ptr, const uintptr_t align)
 Forces the provided ptr pointer to be aligned to align bytes.
 
double r8b::asinh (const double v)
 Hyperbolic sine of a value.
 
double r8b::besselI0 (const double x)
 1st kind, 0th order modified Bessel function of a value.
 
double r8b::calcFIRFilterGroupDelay (const double *const flt, const int fltlen, const double th)
 FIR filter's group delay calculation function.
 
void r8b::calcFIRFilterResponse (const double *flt, int fltlen, const double th, double &re0, double &im0, const int fltlat=0)
 FIR filter's frequency response calculation.
 
void r8b::calcSpline2p8Coeffs (double *const 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)
 Calculates 2nd order spline coefficients, using 8 points.
 
void r8b::calcSpline3p4Coeffs (double *const c, const double *const y)
 Calculates 3rd order spline coefficients, using 4 points.
 
void r8b::calcSpline3p6Coeffs (double *const c, const double *const y)
 Calculates 3rd order spline coefficients, using 6 points.
 
void r8b::calcSpline3p8Coeffs (double *const 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)
 Calculates 3rd order spline coefficients, using 8 points.
 
double r8b::clampr (const double Value, const double minv, const double maxv)
 Clamps a value to be within the specified min-max range.
 
double r8b::gauss (const double v)
 Single-argument Gaussian function of a value.
 
int r8b::getBitOccupancy (const int v)
 Calculate the exact number of bits a value needs for representation.
 
template<typename T>
r8b::max (const T &v1, const T &v2)
 Returns maximum of two values.
 
template<typename T>
r8b::min (const T &v1, const T &v2)
 Returns minimum of two values.
 
void r8b::normalizeFIRFilter (double *const p, const int l, const double DCGain, const int pstep=1)
 FIR filter's gain normalization.
 
double r8b::pow_a (const double v, const double p)
 Power of an absolute value.
 
double r8b::sqr (const double x)
 Returns square ot a value.
 

Variables

R8B_CONST double r8b::R8B_2PI = 6.28318530717958648
 Equals 2*pi.
 
R8B_CONST double r8b::R8B_3PI = 9.42477796076937972
 Equals 3*pi.
 
R8B_CONST double r8b::R8B_PI = 3.14159265358979324
 Equals pi.
 
R8B_CONST double r8b::R8B_PId2 = 1.57079632679489662
 Equals 0.5*pi.
 

Detailed Description

The "base" header file with basic classes and functions.

Version
7.0

This is the "base" header file for the "r8brain-free-src" sample rate converter. This file contains implementations of several small utility classes and functions used by the library.

Macro Definition Documentation

◆ R8BNOCTOR

#define R8BNOCTOR ( ClassName)
Value:
private: \
ClassName( const ClassName& ) { } \
ClassName& operator = ( const ClassName& ) { return( *this ); }

Macro that defines empty copy-constructor and copy operator with the "private:" prefix.

This macro should be used in classes that cannot be copied in a standard C++ way. It is also assumed that objects of such classes are non-relocatable.

This macro does not need to be defined in classes derived from a class where such macro was already used.

Parameters
ClassNameThe name of the class which uses this macro.

◆ R8BSYNC

#define R8BSYNC ( SyncObject)
Value:
R8BSYNC1( SyncObject, __LINE__ )
#define R8BSYNC1(SyncObject, id)
Aux macro.
Definition r8bbase.h:656

Thread synchronization macro.

The R8BSYNC() macro, which creates and object of the r8b::CSyncKeeper class on stack, should be put before sections of the code that may potentially change data asynchronously with other threads at the same time. The R8BSYNC() macro "acquires" the synchronization object thus blocking execution of other threads that also use the same R8BSYNC() macro. The blocked section begins with the R8BSYNC() macro and finishes at the end of the current C++ code block. R8BSYNC() is re-enterant within the same thread.

Parameters
SyncObjectAn object of the CSyncObject type that is used for synchronization.

◆ R8BSYNC1

#define R8BSYNC1 ( SyncObject,
id )
Value:
R8BSYNC2( SyncObject, id )
#define R8BSYNC2(SyncObject, id)
Aux macro.
Definition r8bbase.h:657

Aux macro.

◆ R8BSYNC2

#define R8BSYNC2 ( SyncObject,
id )
Value:
const CSyncKeeper SyncKeeper##id( SyncObject )

Aux macro.