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

◆ tone_gen_size()

int tone_gen_size ( void * tone,
size_t * tone_size,
uint16_t tone_freq_hz,
uint32_t sample_freq_hz,
uint8_t sample_bits,
uint8_t carrier_bits,
float amplitude )

#include <include/tone.h>

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

Note
The returned frequency of the tone is the quotient of the sample_freq_hz divided by the tone_freq_hz.
The routine returns the tone samples left aligned in the carrier.
Parameters
toneUser provided buffer. Must be large enough to hold the generated PCM tone, depending on settings.
tone_sizeResulting tone size in bytes.
tone_freq_hzThe desired tone frequency in the range [100..10000] Hz.
sample_freq_hzSampling frequency.
sample_bitsNumber of bits to represent a sample (i.e. 8, 16, 24 or 32 bits).
carrier_bitsNumber of bits to carry a sample (i.e. 8, 16 or 32 bit).
amplitudeAmplitude in the range [0..1].
Returns
0 if successful, error otherwise.