nRF Connect SDK API 0.1.0
Loading...
Searching...
No Matches

◆ tone_gen()

int tone_gen ( int16_t *  tone,
size_t *  tone_size,
uint16_t  tone_freq_hz,
uint32_t  smpl_freq_hz,
float  amplitude 
)

#include <include/tone.h>

Generates one full pulse-code modulation (PCM) period of a tone with the given parameters.

Parameters
toneUser provided buffer. Must be large enough to hold the generated PCM tone, depending on settings.
tone_sizeResulting tone size.
tone_freq_hzThe desired tone frequency in the range [100..10000] Hz.
smpl_freq_hzSampling frequency.
amplitudeAmplitude in the range [0..1].
Return values
0Tone generated.
-ENXIOIf tone or tone_size is NULL.
-EINVALIf smpl_freq_hz == 0 or tone_freq_hz is out of range.
-EPERMIf amplitude is out of range.