Sine wave

float uz_wavegen_sine(float amplitude, float frequency_Hz)

Outputs one sample of a sine wave 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

Returns

Returns one sample for current system time

Example

Listing 78 Example function call to sine wave generator
1#include "uz_wavegen.h"
2int main(void) {
3   float amplitude = 8.0f;
4   float frequency_Hz = 10.0f;
5   float output = uz_wavegen_sine(amplitude, frequency_Hz);
6}

Description

This function calculates a sine wave with \(y=sin(2 \pi f \cdot t)\) where \(t\) is the global system time.

Figure made with TikZ

Fig. 59 sine wave