Sine wave#
-
type uz_wavegen_sine_t#
-
float uz_wavegen_sine_sample(uz_wavegen_sine_t *self, float amplitude, float frequency_Hz)#
Outputs one sample of a sine wave. Advances the internal phase accumulator by frequency_Hz * dt since the previous call.
- 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
- Returns:
Returns one sample for current system time
Example#
1#include "uz_wavegen.h"
2int main(void) {
3 float amplitude = 8.0f;
4 float frequency_Hz = 10.0f;
5 uz_wavegen_sine_t* sine = uz_wavegen_sine_init();
6 float output = uz_wavegen_sine_sample(sine, amplitude, frequency_Hz);
7}
Description#
This function calculates a sine wave with \(y=sin(2 \pi f \cdot t)\). The phase is tracked in the wavegen instance and advanced on each sample call.

Fig. 339 sine wave