|
Sound Design Toolkit
078
Physically informed sound synthesis for everyday sounds
|
Macros | |
| #define | SDT_ver 078 |
| SDT version number. | |
| #define | SDT_ver_str "078" |
| SDT version string. | |
| #define | SDT_PI 3.141592653589793 |
| Value of Pi. | |
| #define | SDT_TWOPI 6.283185307179586 |
| Value of 2 * Pi. | |
| #define | SDT_EULER 2.718281828459045 |
| Euler number. | |
| #define | SDT_SQRT2 1.4142135623730951 |
| Square root of 2. | |
| #define | SDT_MACH1 340.29 |
| Mach 1, speed of sound in air under normal atmospheric conditions (m/s) | |
| #define | SDT_EARTH 9.81 |
| Earth gravity (N/Kg) | |
| #define | SDT_MICRO 0.000001 |
| One millionth, small value often used instead of 0 to avoid division errors. | |
| #define | SDT_QUIET 0.00003 |
| Gain factor roughly corresponding to a -90dB attenuation. | |
| #define | SDT_ver 078 |
| SDT version number. | |
| #define | SDT_ver_str "078" |
| SDT version string. | |
| #define | SDT_PI 3.141592653589793 |
| Value of Pi. | |
| #define | SDT_TWOPI 6.283185307179586 |
| Value of 2 * Pi. | |
| #define | SDT_EULER 2.718281828459045 |
| Euler number. | |
| #define | SDT_SQRT2 1.4142135623730951 |
| Square root of 2. | |
| #define | SDT_MACH1 340.29 |
| Mach 1, speed of sound in air under normal atmospheric conditions (m/s) | |
| #define | SDT_EARTH 9.81 |
| Earth gravity (N/Kg) | |
| #define | SDT_MICRO 0.000001 |
| One millionth, small value often used instead of 0 to avoid division errors. | |
| #define | SDT_QUIET 0.00003 |
| Gain factor roughly corresponding to a -90dB attenuation. | |
Functions | |
| void | SDT_setSampleRate (double sampleRate) |
| Sets the sample rate. More... | |
| 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. More... | |
| unsigned int | SDT_bitReverse (unsigned int u, unsigned int bits) |
| Reverses the bit order of an unsigned integer of given bit length. More... | |
| 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 bound. More... | |
| double | SDT_expRand (double lambda) |
| Exponential random number generator. Generates random numbers, following an exponential distribution. More... | |
| 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 and upper bound. More... | |
| double | SDT_frand () |
| Uniform random number generator. Generates random numbers, following a uniform distribution. More... | |
| void | SDT_gaussian1D (double *x, double sigma, int n) |
| One-dimensional Gaussian kernel. One-dimensional Gaussian kernel. The Gaussian function is computed in the [-1,1] interval with 0 mean and the given standard deviation. The output is normalized so that the sum of all samples is equal to 1. More... | |
| double | SDT_gravity (double mass) |
| Computes earth gravity force. Computes the earth gravity force acting on an object of a given mass. More... | |
| 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. More... | |
| void | SDT_haar (double *sig, long n) |
| Computes a direct Haar Wavelet Transform of the incoming signal (in place). More... | |
| void | SDT_ihaar (double *sig, long n) |
| Computes an inverse Haar Wavelet Transform of the incoming signal (in place). More... | |
| double | SDT_kinetic (double mass, double velocity) |
| Computes kinetic energy. Computes the kinetic energy of an object, given its mass and velocity. More... | |
| unsigned int | SDT_nextPow2 (unsigned int u) |
| Returns the smallest power of 2 greater or equal than u. More... | |
| 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 the [0.0, 1.0] interval. More... | |
| void | SDT_normalizeWindow (double *sig, int n) |
| Normalizes samples in a window so that their sum is equal to 1. More... | |
| void | SDT_ones (double *sig, int n) |
| Fills a buffer with ones. Fills a buffer with ones. More... | |
| 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. More... | |
| void | SDT_removeDC (double *sig, int n) |
| Removes the global average from samples in a window. More... | |
| 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 maxima and minima) in a buffer. More... | |
| double | SDT_samplesInAir (double length) |
| Time needed to travel the given distance at Mach 1. Computes the amount of time, in samples, needed by a sound wave propagating in air to travel a given distance. Particularly useful to set the delay times of comb filters and/or digital waveguides representing hollow cavities. More... | |
| 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 target range. More... | |
| int | SDT_signum (double x) |
| Computes the signum function. Computes the signum function. More... | |
| 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 chunk of samples. More... | |
| double | SDT_truePeakPos (double *sig, int peak) |
| Performs quadratic interpolation to estimate the true position of a peak. Performs quadratic interpolation to estimate the true position of a peak. More... | |
| double | SDT_truePeakValue (double *sig, int peak) |
| Performs quadratic interpolation to estimate the true amplitude value of a peak. Performs quadratic interpolation to estimate the true amplitude value of a peak. More... | |
| double | SDT_wrap (double x) |
| Wraps a phase in the range -pi/pi. Wraps a phase in the range -pi/pi. More... | |
| void | SDT_zeros (double *sig, int n) |
| Fills a buffer with zeros. Fills a buffer with zeros. More... | |
Variables | |
| double | SDT_sampleRate |
| Sampling frequency (Hz) | |
| double | SDT_timeStep |
| Sampling period (s) | |
| double | SDT_sampleRate |
| Sampling frequency (Hz) | |
| double | SDT_timeStep |
| Sampling period (s) | |
Macros, variables and functions commonly used by all the SDT objects. SDTCommon.h should always be included when using other SDT modules.
| unsigned int SDT_bitReverse | ( | unsigned int | u, |
| unsigned int | bits | ||
| ) |
Reverses the bit order of an unsigned integer of given bit length.
| [in] | u | Input value |
| [in] | bits | Number of bits to reverse |
| 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.
| [in,out] | sig | samples to window |
| [in] | n | window size |
| 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 bound.
| [in] | x | Integer value to clip |
| [in] | min | Lower limit |
| [in] | max | Upper limit |
| double SDT_expRand | ( | double | lambda | ) |
Exponential random number generator. Generates random numbers, following an exponential distribution.
| [in] | lambda | Rate of the exponential distribution. |
| 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 and upper bound.
| [in] | x | Floating point value to clip |
| [in] | min | Lower limit |
| [in] | max | Upper limit |
| double SDT_frand | ( | ) |
Uniform random number generator. Generates random numbers, following a uniform distribution.
| void SDT_gaussian1D | ( | double * | x, |
| double | sigma, | ||
| int | n | ||
| ) |
One-dimensional Gaussian kernel. One-dimensional Gaussian kernel. The Gaussian function is computed in the [-1,1] interval with 0 mean and the given standard deviation. The output is normalized so that the sum of all samples is equal to 1.
| [out] | x | pointer to the kernel samples |
| [in] | sigma | standard deviation of the Gaussian function |
| [in] | n | kernel size |
| double SDT_gravity | ( | double | mass | ) |
Computes earth gravity force. Computes the earth gravity force acting on an object of a given mass.
| [in] | mass | Mass of the object (Kg) |
| void SDT_haar | ( | double * | sig, |
| long | n | ||
| ) |
Computes a direct Haar Wavelet Transform of the incoming signal (in place).
| [in,out] | sig | incoming signals |
| [in] | n | window size |
| 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.
| [in,out] | sig | samples to window |
| [in] | n | window size |
| void SDT_ihaar | ( | double * | sig, |
| long | n | ||
| ) |
Computes an inverse Haar Wavelet Transform of the incoming signal (in place).
| [in,out] | sig | incoming signals |
| [in] | n | window size |
| double SDT_kinetic | ( | double | mass, |
| double | velocity | ||
| ) |
Computes kinetic energy. Computes the kinetic energy of an object, given its mass and velocity.
| [in] | mass | Mass of the object (Kg) |
| [in] | velocity | Velocity of the object (m/s) |
| unsigned int SDT_nextPow2 | ( | unsigned int | u | ) |
Returns the smallest power of 2 greater or equal than u.
| [in] | u | Input value |
| 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 the [0.0, 1.0] interval.
| [in] | x | Value to normalize |
| [in] | min | Lower bound |
| [in] | max | Upper bound |
| void SDT_normalizeWindow | ( | double * | sig, |
| int | n | ||
| ) |
Normalizes samples in a window so that their sum is equal to 1.
| [in,out] | sig | window to normalize |
| [in] | n | window size |
| void SDT_ones | ( | double * | sig, |
| int | n | ||
| ) |
Fills a buffer with ones. Fills a buffer with ones.
| [in,out] | sig | pointer to the buffer |
| [in] | n | buffer size |
| 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.
| [in] | x | input array |
| [in] | n | array size |
| [in] | k | item rank |
| void SDT_removeDC | ( | double * | sig, |
| int | n | ||
| ) |
Removes the global average from samples in a window.
| [in,out] | sig | window to remove the average from |
| [in] | n | window size |
| 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 maxima and minima) in a buffer.
| [in] | sig | pointer to the buffer |
| [out] | peaks | indexes of the local maxima in the buffer |
| [out] | bounds | indexes of the local minima in the buffer |
| double SDT_samplesInAir | ( | double | length | ) |
Time needed to travel the given distance at Mach 1. Computes the amount of time, in samples, needed by a sound wave propagating in air to travel a given distance. Particularly useful to set the delay times of comb filters and/or digital waveguides representing hollow cavities.
| [in] | length | Distance (m) |
| 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 target range.
| [in] | x | Value to rescale |
| [in] | srcMin | Lower bound of source value |
| [in] | srcMax | Upper bound of source value |
| [in] | dstMin | Lower bound of rescaled value |
| [in] | dstMax | Upper bound of rescaled value |
| [in] | gamma | Gamma factor |
gamma | void SDT_setSampleRate | ( | double | sampleRate | ) |
Sets the sample rate.
| [in] | sampleRate | Sample rate (Hz). |
| int SDT_signum | ( | double | x | ) |
Computes the signum function. Computes the signum function.
| [in] | x | Input value |
| 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 chunk of samples.
| [in,out] | sig | samples to window |
| [in] | w | sinc parameter |
| [in] | n | window size |
| double SDT_truePeakPos | ( | double * | sig, |
| int | peak | ||
| ) |
Performs quadratic interpolation to estimate the true position of a peak. Performs quadratic interpolation to estimate the true position of a peak.
| [in] | sig | signal buffer |
| [in] | peak | index of a local maximum |
| double SDT_truePeakValue | ( | double * | sig, |
| int | peak | ||
| ) |
Performs quadratic interpolation to estimate the true amplitude value of a peak. Performs quadratic interpolation to estimate the true amplitude value of a peak.
| [in] | sig | signal buffer |
| [in] | peak | index of a local maximum |
| double SDT_wrap | ( | double | x | ) |
Wraps a phase in the range -pi/pi. Wraps a phase in the range -pi/pi.
| void SDT_zeros | ( | double * | sig, |
| int | n | ||
| ) |
Fills a buffer with zeros. Fills a buffer with zeros.
| [in,out] | sig | pointer to the buffer |
| [in] | n | buffer size |