Triangle wave with offset

float uz_wavegen_triangle_with_offset(float amplitude, float frequency_Hz, float offset)

Returns one sample of a triangle wave with an configurable offset.

  • amplitude – Amplitude for the triangle wave

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

  • offset – Offset for the triangle wave


Returns one sample for current system time


Listing 82 Example function call to triangle 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_triangle_with_offset(amplitude, frequency_Hz, offset);


This function calculates a triangle wave with offset based on the global system time.

Figure made with TikZ

Fig. 64 triangle wave with offset