(8.D.2.1) SineSmoothedGenFract32
Overview
Smoothly varying sine wave generator
Discussion
Sine wave generator, with parameters for controling frequency and start phase. This is a source module and requires that you specify the properties of the output pin (number of channels, blockSize, and sample rate) at construction time. The smoothing coefficient allows for changes to the frequency parameter to be exponentially smoothed (first order IIR) at the sample rate.
Internally, this modules uses the sin() function from the C math library . The instantaneous frequency (which is the phase increment between samples) is smoothed on a sample by sample basis. If you do not need smoothed behavior, use the more efficient sine_gen_module.m instead.
Type Definition
typedef struct _ModuleSineSmoothedGenFract32
{
ModuleInstanceDescriptor instance; // Common Audio Weaver module instance structure
FLOAT32 freq; // Frequency of the sine wave, in Hz.
FLOAT32 smoothingTime; // Time constant of the frequency adjustment operation, in msec.
FLOAT32 startPhase; // Starting phase of the sine wave, in degrees.
fract32 smoothingCoeff; // Smoothing coefficient
fract32 phase; // Instantanteous phase and also starting phase
fract32 phaseIncTarget; // Target for the sample to sample phase increment. Essentially the target frequency
fract32 phaseInc; // Instantaneous sample to sample phase increment
} ModuleSineSmoothedGenFract32Class;
Variables
Properties
Name | Type | Usage | isHidden | Default value | Range | Units |
freq | float | parameter | 0 | 1000 | 0.01:24000 | Hz |
smoothingTime | float | parameter | 0 | 10 | 0:1000 | msec |
startPhase | float | parameter | 0 | 0 | 0:360 | degrees |
smoothingCoeff | fract32 | derived | 1 | 0.002081 | Unrestricted | Â |
phase | fract32 | derived | 1 | 0 | Unrestricted | radians |
phaseIncTarget | fract32 | derived | 1 | 0.01636 | Unrestricted | radians/sample |
phaseInc | fract32 | derived | 1 | 0.01636 | Unrestricted | radians/sample |
Pins
Output Pins
Name: out
Description: audio output
Data type: float
MATLAB Usage
File Name: sine_smoothed_gen_fract32_module.m
M=sine_smoothed_gen_fract32_module(NAME, SR, BLOCKSIZE)
Creates a sine wave generator for use in the Audio Weaver. This
module has a single 1 channel output pin with controllable frequency
and built in frequency smoothing. Arguments:
NAME - name of the module.
SR - sample rate
BLOCKSIZE - number of samples per output channel.
Â