# SineWave

Advanced Analysis Library Only

AnalysisLibErrType SineWave (int numberOfElements, double amplitude, double frequency, double *phase, double sineWave[]);

## Purpose

Generates an array that contains a sine wave. SineWave generates the element of the output array x according to the following formula:

xi = amplitude × sin(phi)

where

where the normalized frequency is the ratio of the actual frequency to the sampling frequency.

For example, if the actual frequency desired is 100 Hz and the sampling frequency is 500 Hz, the normalized frequency is 0.2. You can use SineWave to simulate a continuous acquisition from a sine wave function generator. The unit of the input phase is in degrees, and SineWave sets phase to (phase + f x 360.0 x n) mod 360.0 before it returns.

## Parameters

Input
Name | Type | Description
numberOfElements | integer | Number of samples to generate in the sine wave signal.
amplitude | double-precision | Amplitude of the resulting sine wave signal. Default Value: 1.0.
frequency | double-precision | Frequency of the resulting sine wave signal in normalized units of cycles/sample. Default Value: 7.8125E-3 (1 cycle/128 samples).
Output
Name | Type | Description
phase | double-precision | Pointer to the initial phase, in degrees, of the sine wave signal SineWave generates. Upon completion of SineWave, phase points to the phase of the next portion of the signal. Use this parameter in the next call to SineWave to simulate a continuous acquisition. You must pre-initialize this value to a valid value.
sineWave | double-precision array | The generated sine wave signal.

## Return Value

Name | Type | Description
status | AnalysisLibErrType | A value that specifies the type of error that occurred. Refer to analysis.h for definitions of these constants.