Rate This Document
Findability
Accuracy
Completeness
Readability

Tone

Generates a tone that has a given frequency, phase, and magnitude.

The function interface is declared as follows:

  • Operations on integers:

    HmppResult HMPPS_Tone_16s(int16_t *dst, int32_t len, int16_t magn, float freq, float *phase);

    HmppResult HMPPS_Tone_16sc(Hmpp16sc *dst, int32_t len, int16_t magn, float freq, float *phase);

  • Operations on floating-point numbers:

    HmppResult HMPPS_Tone_32f(float *dst, int32_t len, float magn, float freq, float *phase);

    HmppResult HMPPS_Tone_64f(double *dst, int32_t len, double magn, double freq, double *phase);

    HmppResult HMPPS_Tone_32fc(Hmpp32fc *dst, int32_t len, float magn, float freq, float *phase);

    HmppResult HMPPS_Tone_64fc(Hmpp64fc *dst, int32_t len, double magn, double freq, double *phase);

Parameters

Parameter

Description

Value Range

Input/Output

dst

Pointer to the destination vector

The value cannot be NULL.

Output

len

Vector length

(0, INT_MAX]

Input

phase

Pointer to the phase

[0.0, 2π)

Input

magn

Amplitude

Depending on the type

Input

freq

Frequency

Real number: [0.0, 0.5)

Complex number: [0.0, 1.0)

Input

Return Value

  • Success: HMPP_STS_NO_ERR
  • Failure: An error code is returned.

Error Codes

Error Code

Description

HMPP_STS_NULL_PTR_ERR

The value of dst is NULL.

HMPP_STS_SIZE_ERR

The value of len is less than or equal to 0.

HMPP_STS_PARAMETER_ERR

The magnitude is less than 0, and the frequency or phase is out of range.

Example

#define BUFFER_SIZE_T 10

int main()
{
    int16_t dst[BUFFER_SIZE_T];
    int32_t i;
    int16_t magn = 25;
    float freq = 0.4;
    float phase = 5.1415901;

    HmppResult result = HMPPS_Tone_16s(dst, BUFFER_SIZE_T, magn, freq, &phase);
    printf("result = %d \ndst =", result);
    for (i = 0; i < BUFFER_SIZE_T; i++) {
        printf(" %d    ", dst[i]);
    }

    return 0;
}

Output:

result = 0
dst = 10    4    -18    24    -21    10    4    -18    24    -21