Sine wave with offset#
-
float uz_wavegen_sine_sample_with_offset(uz_wavegen_sine_t *self, float amplitude, float frequency_Hz, float offset)#
Outputs one sample of a sine wave with the specified DC offset.
- Parameters:
self – Pointer to uz_wavegen_sine instance
amplitude – Amplitude for the sine wave
frequency_Hz – Frequency for the sine wave in Hz. Only positive values are permitted
offset – DC offset added to the sample
- Returns:
Returns one sample for current system time
Example#
1#include "uz_wavegen.h"
2int main(void) {
3 float amplitude = 6.0f;
4 float frequency_Hz = 5.0f;
5 float offset = -5.0f;
6 uz_wavegen_sine_t* sine = uz_wavegen_sine_init();
7 float output = uz_wavegen_sine_sample_with_offset(sine, amplitude, frequency_Hz, offset);
8}
Description#
This function calculates a sine wave with \(y=sin(2 \pi f \cdot t) + x\) where \(x\) is the offset. The phase is tracked in the wavegen instance and advanced on each sample call.

Fig. 340 sine wave with offset