Sine wave with offset#

float uz_wavegen_sine_with_offset(float amplitude, float frequency_Hz, float offset)#

Outputs one sample of a sine wave with the specified offset for the current global system time at each function call.

Parameters:
  • amplitude – Amplitude for the sine wave

  • frequency_Hz – Frequency for the sine wave in Hz. Only positive values are permitted

  • offset – Offset for the sine wave

Returns:

Returns one sample for current system time

Example#

Listing 72 Example function call to sine wave generator with offset#
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   float output = uz_wavegen_sine_with_offset(amplitude, frequency_Hz, offset);
7}

Description#

This function calculates a sine wave with \(y=sin(2 \pi f \cdot t) + x\) where \(t\) is the global system time and :math`x` is the offset.

Figure made with TikZ

Fig. 273 sine wave with offset