Nsound  0.9.4
Macros | Functions
Generator.cc File Reference
#include <Nsound/Buffer.h>
#include <Nsound/Generator.h>
#include <Nsound/RngTausworthe.h>
#include <iostream>
#include <string.h>
#include <math.h>
Include dependency graph for Generator.cc:

Go to the source code of this file.

Macros

#define M_2PI   (2.0*M_PI)
 
#define CERR_HEADER   __FILE__ << ":" << __LINE__ << ": "
 

Functions

static void cosinewindow (Buffer &win, const float64 &a0, const float64 &a1, const float64 &a2, const float64 &a3)
 
float64 bessel_i0 (const float64 &x)
 

Macro Definition Documentation

#define M_2PI   (2.0*M_PI)

Definition at line 46 of file Generator.cc.

Referenced by Nsound::Generator::drawGaussian(), and Nsound::Generator::drawSine2().

#define CERR_HEADER   __FILE__ << ":" << __LINE__ << ": "

Definition at line 48 of file Generator.cc.

Function Documentation

static void cosinewindow ( Buffer win,
const float64 a0,
const float64 a1,
const float64 a2,
const float64 a3 
)
static

Definition at line 746 of file Generator.cc.

References Nsound::Buffer::getLength(), and M_PI.

Referenced by Nsound::Generator::drawWindowBlackman(), Nsound::Generator::drawWindowBlackmanHarris(), Nsound::Generator::drawWindowHamming(), Nsound::Generator::drawWindowHanning(), and Nsound::Generator::drawWindowNuttall().

752 {
753  int32 n = win.getLength();
754  for(int32 i = 0; i < n; ++i)
755  {
756  win[i] *= a0
757  - a1 * ::cos(2.0 * M_PI * i / n)
758  + a2 * ::cos(4.0 * M_PI * i / n)
759  - a3 * ::cos(6.0 * M_PI * i / n);
760  }
761 }
#define M_PI
Definition: Nsound.h:121
uint32 getLength() const
Returns the number of samples in the Buffer.
Definition: Buffer.h:587
signed int int32
Definition: Nsound.h:142
float64 bessel_i0 ( const float64 x)

Definition at line 837 of file Generator.cc.

Referenced by Nsound::Generator::drawWindowKaiser().

838 {
839  const float64 p1 = 1.0,
840  p2 = 3.5156229,
841  p3 = 3.0899424,
842  p4 = 1.2067492,
843  p5 = 0.2659732,
844  p6 = 3.60768e-2,
845  p7 = 4.5813e-3;
846 
847  const float64 q1 = 0.39894228,
848  q2 = 1.328592e-2,
849  q3 = 2.25319e-3,
850  q4 = -1.57565e-3,
851  q5 = 9.16281e-3,
852  q6 = -2.057706e-2,
853  q7 = 2.635537e-2,
854  q8 = -1.647633e-2,
855  q9 = 3.92377e-3;
856 
857  float64 ax = ::fabs(x);
858 
859  float64 y = 0.0,
860  result = 0.0;
861 
862  if (ax < 3.75)
863  {
864  y = ::pow(x / 3.75, 2);
865  result = p1+y*(p2+y*(p3+y*(p4+y*(p5+y*(p6+y*p7)))));
866  }
867  else
868  {
869  y = 3.75 / ax;
870  result = (::exp(ax) / ::sqrt(ax))
871  * (q1+y*(q2+y*(q3+y*(q4+y*(q5+y*(q6+y*(q7+y*(q8+y*q9))))))));
872  }
873  return result;
874 }
double float64
Definition: Nsound.h:146