View Raw SPL
/*****************************************************************************
* *
* GDAMPSIN.SPL Copyright (C) 2024 DSP Development Corporation *
* All Rights Reserved *
* *
* Author: Randy Race *
* *
* Synopsis: Generates a damped sinewave *
* *
* Revisions: 5 Sep 2024 RRR Creation *
* *
*****************************************************************************/
#if @HELP_GDAMPSIN
GDAMPSIN
Purpose:
Generates a damped sinewave.
Syntax:
GDAMPSIN(length, spacing, frequency, phase, dampfac)
length - An integer, the number of points to generate.
spacing - A real, the spacing (deltax) between points.
frequency - Optional. A real, the frequency in Hertz.
Defaults to 10 Hz.
phase - Optional. A real, the phase specified in radians.
Defaults to 0.
dampfac - Optional. A real, the exponential damping factor.
Defaults to -5.0.
Returns:
A series, an exponentially damped sinewave.
Example:
W1: gdampsin(1000, 0.001)
Creates a 1000 point 10 Hz damped sinewave with points spaced at
an interval of 0.001 seconds (a sample rate of 1000 Hz) with a
phase of 0 and a damping factor of -5.0.
Example:
W2: gdampsin(1000, 0.001, 10, 0, -5)
Same as above.
Example:
W3: 100*gdampsin(10000, 1/1000, 5, 0, -0.5) + 50
Generates 10000 samples of a 5 Hz damped sinewave sampled at
1 kHz with a damping factor of -0.5. The amplitude is 100 and
the result is offset by 50.0.
Remarks:
GDAMPSIN returns an exponentially damped sinewave.
If DAMPFAC is positive, the series amplitude grows with time.
See Also:
Gsin
Gsweep
#endif
/* generate an exponentially damped sinewave */
gdampsin(n=1000, dx=1/n, f=10, phi=0, b=-5)
{
local s;
s = gsin(n, dx, f, phi) * gexp(n, dx, b);
return(s);
}