Sound Design Toolkit  078
Physically informed sound synthesis for everyday sounds
SDTCommon.h
1 
56 #ifndef SDT_COMMON_H
57 #define SDT_COMMON_H
58 
60 #define SDT_ver 078
61 
62 #define SDT_ver_str "078"
63 
64 #define SDT_PI 3.141592653589793
65 
66 #define SDT_TWOPI 6.283185307179586
67 
68 #define SDT_EULER 2.718281828459045
69 
70 #define SDT_SQRT2 1.4142135623730951
71 
72 #define SDT_MACH1 340.29
73 
74 #define SDT_EARTH 9.81
75 
76 #define SDT_MICRO 0.000001
77 
78 #define SDT_QUIET 0.00003
79 
80 #ifdef __cplusplus
81 extern "C" {
82 #endif
83 
85 extern double SDT_sampleRate;
86 
88 extern double SDT_timeStep;
89 
92 extern void SDT_setSampleRate(double sampleRate);
93 
98 extern void SDT_blackman(double *sig, int n);
99 
104 extern unsigned int SDT_bitReverse(unsigned int u, unsigned int bits);
105 
112 extern long SDT_clip(long x, long min, long max);
113 
118 extern double SDT_expRand(double lambda);
119 
126 extern double SDT_fclip(double x, double min, double max);
127 
131 extern double SDT_frand();
132 
140 extern void SDT_gaussian1D(double *x, double sigma, int n);
141 
146 extern double SDT_gravity(double mass);
147 
152 extern void SDT_hanning(double *sig, int n);
153 
157 extern void SDT_haar(double *sig, long n);
158 
162 extern void SDT_ihaar(double *sig, long n);
163 
169 extern double SDT_kinetic(double mass, double velocity);
170 
174 extern unsigned int SDT_nextPow2(unsigned int u);
175 
182 extern double SDT_normalize(double x, double min, double max);
183 
187 extern void SDT_normalizeWindow(double *sig, int n);
188 
193 extern void SDT_ones(double *sig, int n);
194 
201 extern double SDT_rank(double *x, int n, int k);
202 
206 extern void SDT_removeDC(double *sig, int n);
207 
215 extern int SDT_roi(double *sig, int *peaks, int *bounds, int d, int n);
216 
223 extern double SDT_samplesInAir(double length);
224 
234 extern double SDT_scale(double x, double srcMin, double srcMax,
235  double dstMin, double dstMax, double gamma);
236 
241 extern int SDT_signum(double x);
242 
248 extern void SDT_sinc(double *sig, double w, int n);
249 
255 extern double SDT_truePeakPos(double *sig, int peak);
256 
262 extern double SDT_truePeakValue(double *sig, int peak);
263 
268 extern double SDT_wrap(double x);
269 
274 extern void SDT_zeros(double *sig, int n);
275 
276 #ifdef __cplusplus
277 };
278 #endif
279 
280 #endif
281 
double SDT_truePeakValue(double *sig, int peak)
Performs quadratic interpolation to estimate the true amplitude value of a peak. Performs quadratic i...
double SDT_fclip(double x, double min, double max)
Clips a floating point value. Limits the range of a floating point value between a given lower bound ...
void SDT_hanning(double *sig, int n)
Applies a Hanning window to a chunk of samples. Applies a Hanning window to a chunk of samples...
void SDT_zeros(double *sig, int n)
Fills a buffer with zeros. Fills a buffer with zeros.
void SDT_haar(double *sig, long n)
Computes a direct Haar Wavelet Transform of the incoming signal (in place).
unsigned int SDT_bitReverse(unsigned int u, unsigned int bits)
Reverses the bit order of an unsigned integer of given bit length.
void SDT_blackman(double *sig, int n)
Applies a Blackman window to a chunk of samples. Applies a Blackman window to a chunk of samples...
double SDT_truePeakPos(double *sig, int peak)
Performs quadratic interpolation to estimate the true position of a peak. Performs quadratic interpol...
double SDT_rank(double *x, int n, int k)
Finds the kth smallest value in the input array. Finds the kth smallest value in the input array...
double SDT_samplesInAir(double length)
Time needed to travel the given distance at Mach 1. Computes the amount of time, in samples...
void SDT_normalizeWindow(double *sig, int n)
Normalizes samples in a window so that their sum is equal to 1.
double SDT_gravity(double mass)
Computes earth gravity force. Computes the earth gravity force acting on an object of a given mass...
double SDT_frand()
Uniform random number generator. Generates random numbers, following a uniform distribution.
int SDT_signum(double x)
Computes the signum function. Computes the signum function.
double SDT_kinetic(double mass, double velocity)
Computes kinetic energy. Computes the kinetic energy of an object, given its mass and velocity...
double SDT_timeStep
Sampling period (s)
void SDT_setSampleRate(double sampleRate)
Sets the sample rate.
void SDT_ones(double *sig, int n)
Fills a buffer with ones. Fills a buffer with ones.
void SDT_gaussian1D(double *x, double sigma, int n)
One-dimensional Gaussian kernel. One-dimensional Gaussian kernel. The Gaussian function is computed i...
void SDT_ihaar(double *sig, long n)
Computes an inverse Haar Wavelet Transform of the incoming signal (in place).
double SDT_scale(double x, double srcMin, double srcMax, double dstMin, double dstMax, double gamma)
Rescales a value from a source range to a target range. Rescales a value from a source range to a tar...
void SDT_removeDC(double *sig, int n)
Removes the global average from samples in a window.
double SDT_wrap(double x)
Wraps a phase in the range -pi/pi. Wraps a phase in the range -pi/pi.
void SDT_sinc(double *sig, double w, int n)
Applies a sinc window (sin(wt)/(wt)) to a chunk of samples. Applies a sinc window (sin(wt)/(wt)) to a...
unsigned int SDT_nextPow2(unsigned int u)
Returns the smallest power of 2 greater or equal than u.
double SDT_sampleRate
Sampling frequency (Hz)
double SDT_normalize(double x, double min, double max)
Rescales a value of known range into the [0.0, 1.0] interval. Rescales a value of known range into th...
int SDT_roi(double *sig, int *peaks, int *bounds, int d, int n)
Finds regions of influence (local maxima and minima) in a buffer. Finds regions of influence (local m...
long SDT_clip(long x, long min, long max)
Clips an integer value. Limits the range of an integer value between a given lower bound and upper bo...
double SDT_expRand(double lambda)
Exponential random number generator. Generates random numbers, following an exponential distribution...