C API Reference

API reference for the Genalyzer C library bindings.

Table of Contents

Enumerations

group Enumerations

Typedefs

typedef enum GnAnalysisType GnAnalysisType

GnAnalysisType enumerates analysis types.

typedef enum GnCodeFormat GnCodeFormat

GnCodeFormat enumerates binary code formats.

typedef enum GnDnlSignal GnDnlSignal

GnDnlSignal enumerates signal types for which DNL can be computed.

typedef enum GnFACompTag GnFACompTag

GnFACompTag enumerates Fourier analysis component tags.

typedef enum GnFASsb GnFASsb

GnFASsb enumerates the component categories for which the number of single side bins (SSB) can be set.

typedef enum GnFreqAxisFormat GnFreqAxisFormat

GnFreqAxisFormat enumerates frequency axis formats.

typedef enum GnFreqAxisType GnFreqAxisType

GnFreqAxisType enumerates frequency axis types.

typedef enum GnInlLineFit GnInlLineFit

GnInlLineFit enumerates INL line fitting options.

typedef enum GnRfftScale GnRfftScale

GnRfftScale enumerates real FFT scaling options.

typedef enum GnWindow GnWindow

GnWindow enumerates window functions.

Enums

enum GnAnalysisType

GnAnalysisType enumerates analysis types.

Values:

enumerator GnAnalysisTypeDNL

DNL (differential nonlinearity)

enumerator GnAnalysisTypeFourier

Fourier (FFT)

enumerator GnAnalysisTypeHistogram

Histogram.

enumerator GnAnalysisTypeINL

INL (integral nonlinearity)

enumerator GnAnalysisTypeWaveform

Waveform.

enum GnCodeFormat

GnCodeFormat enumerates binary code formats.

Values:

enumerator GnCodeFormatOffsetBinary

Offset Binary.

enumerator GnCodeFormatTwosComplement

Two’s Complement.

enum GnDnlSignal

GnDnlSignal enumerates signal types for which DNL can be computed.

Values:

enumerator GnDnlSignalRamp

Ramp.

enumerator GnDnlSignalTone

Tone (Sinusoid)

enum GnFACompTag

GnFACompTag enumerates Fourier analysis component tags.

Values:

enumerator GnFACompTagDC

DC component (always Bin 0)

enumerator GnFACompTagSignal

Signal component.

enumerator GnFACompTagHD

Harmonic distortion.

enumerator GnFACompTagIMD

Intermodulation distortion.

enumerator GnFACompTagILOS

Interleaving offset component.

enumerator GnFACompTagILGT

Interleaving gain/timing/BW component.

enumerator GnFACompTagCLK

Clock component.

enumerator GnFACompTagUserDist

User-designated distortion.

enumerator GnFACompTagNoise

Noise component (e.g. WorstOther)

enum GnFASsb

GnFASsb enumerates the component categories for which the number of single side bins (SSB) can be set.

Values:

enumerator GnFASsbDefault

Default SSB (applies to auto-generated components)

enumerator GnFASsbDC

SSB for DC component.

enumerator GnFASsbSignal

SSB for Signal components.

enumerator GnFASsbWO

SSB for WorstOther components.

enum GnFreqAxisFormat

GnFreqAxisFormat enumerates frequency axis formats.

Values:

enumerator GnFreqAxisFormatBins

Bins.

enumerator GnFreqAxisFormatFreq

Frequency.

enumerator GnFreqAxisFormatNorm

Normalized.

enum GnFreqAxisType

GnFreqAxisType enumerates frequency axis types.

Values:

enumerator GnFreqAxisTypeDcCenter

only)

DC centered, e.g. [-fs/2, fs/2) (complex FFT

enumerator GnFreqAxisTypeDcLeft

DC on left, e.g. [0, fs) (complex FFT only)

enumerator GnFreqAxisTypeReal

Real axis, e.g. [0, fs/2] (real FFT only)

enum GnInlLineFit

GnInlLineFit enumerates INL line fitting options.

Values:

enumerator GnInlLineFitBestFit

Best fit.

enumerator GnInlLineFitEndFit

End fit.

enumerator GnInlLineFitNoFit

No fit.

enum GnRfftScale

GnRfftScale enumerates real FFT scaling options.

Values:

enumerator GnRfftScaleDbfsDc

Full-scale sinusoid measures -3 dBFS.

enumerator GnRfftScaleDbfsSin

Full-scale sinusoid measures 0 dBFS.

enumerator GnRfftScaleNative

Full-scale sinusoid measures -6 dBFS.

enum GnWindow

GnWindow enumerates window functions.

Values:

enumerator GnWindowBlackmanHarris

Blackman-Harris.

enumerator GnWindowHann

Hann (“Hanning”)

enumerator GnWindowNoWindow

No window (Rectangular)

API Utilities

group API Utilities

Functions

int gn_analysis_results_key_sizes(size_t *key_sizes, size_t key_sizes_size, GnAnalysisType type)

Get the size of each key string in an analysis results array.

The library string termination setting determines whether or not a null terminator is included in the key sizes. See gn_set_string_termination.

Parameters:
  • key_sizes – [out] Key size array pointer

  • key_sizes_size – [in] Key size array size

  • type – [in] Analysis type

Returns:

0 on success, non-zero otherwise

int gn_analysis_results_size(size_t *size, GnAnalysisType type)

Get the number of key-value result pairs for a given analysis type.

Parameters:
  • size – [out] Number of key-value result pairs

  • type – [in] Analysis type

Returns:

0 on success, non-zero otherwise

int gn_enum_value(int *value, const char *enumeration, const char *enumerator)

Get the integer value of a named enumerator within a named enumeration.

Parameters:
  • value – [out] Underlying value of enumeration::enumerator

  • enumeration – [in] Enumeration name

  • enumerator – [in] Enumerator name

Returns:

0 on success, non-zero otherwise

int gn_error_check(bool *error)

Check whether an error has occurred.

Parameters:

error – [out] true if an error has occurred; false otherwise

Returns:

Always returns 0

int gn_error_clear()

Clear the current error state.

Returns:

Always returns 0

int gn_error_string(char *buf, size_t size)

Get the error message string.

Parameters:
  • buf – [out] Pointer to character array

  • size – [in] Size of character array

Returns:

0 on success, non-zero otherwise

int gn_set_string_termination(bool null_terminated)

Set whether library-returned strings include a null terminator.

Some functions in this library return strings by filling character buffers (arrays) provided by the caller. This function sets a global library setting that determines whether or not strings should be null-terminated. If set to true, functions that return strings will write a ‘\0’ as the last character. In addition, functions that return the size of a string will include the null terminator in the size.

Parameters:

null_terminated – [in] If true, strings are terminated with ‘\0’

Returns:

Always returns 0

int gn_version_string(char *buf, size_t size)

Get the library version string.

Parameters:
  • buf – [in,out] Pointer to character array

  • size – [in] Size of character array

Returns:

0 on success, non-zero otherwise

Array Operations

group Array Operations

Functions

int gn_abs(double *out, size_t out_size, const double *in, size_t in_size)

Compute the magnitude of each element in an interleaved complex array.

Parameters:
  • out – [out] Output array pointer

  • out_size – [in] Output array size

  • in – [in] Input array pointer

  • in_size – [in] Input array size

Returns:

0 on success, non-zero otherwise

int gn_angle(double *out, size_t out_size, const double *in, size_t in_size)

Compute the phase angle (radians) of each element in an interleaved complex array.

Parameters:
  • out – [out] Output array pointer

  • out_size – [in] Output array size

  • in – [in] Input array pointer

  • in_size – [in] Input array size

Returns:

0 on success, non-zero otherwise

int gn_db(double *out, size_t out_size, const double *in, size_t in_size)

Convert interleaved complex values to decibels (10*log10(re^2 + im^2))

Parameters:
  • out – [out] Output array pointer

  • out_size – [in] Output array size

  • in – [in] Input array pointer

  • in_size – [in] Input array size

Returns:

0 on success, non-zero otherwise

int gn_db10(double *out, size_t out_size, const double *in, size_t in_size)

Convert real values to decibels using 10*log10(x)

Parameters:
  • out – [out] Output array pointer

  • out_size – [in] Output array size

  • in – [in] Input array pointer

  • in_size – [in] Input array size

Returns:

0 on success, non-zero otherwise

int gn_db20(double *out, size_t out_size, const double *in, size_t in_size)

Convert real values to decibels using 20*log10(x)

Parameters:
  • out – [out] Output array pointer

  • out_size – [in] Output array size

  • in – [in] Input array pointer

  • in_size – [in] Input array size

Returns:

0 on success, non-zero otherwise

int gn_norm(double *out, size_t out_size, const double *in, size_t in_size)

Compute the squared magnitude of each element in an interleaved complex array.

Parameters:
  • out – [out] Output array pointer

  • out_size – [in] Output array size

  • in – [in] Input array pointer

  • in_size – [in] Input array size

Returns:

0 on success, non-zero otherwise

Code Density

group Code Density

Functions

int gn_code_axis(double *out, size_t size, int n, GnCodeFormat format)

Generate a code axis array for a given ADC resolution and code format.

Parameters:
  • out – [out] Array pointer

  • size – [in] Array size

  • n – [in] Resolution

  • format – [in] Code format

Returns:

0 on success, non-zero otherwise

int gn_code_axisx(double *out, size_t size, int64_t min, int64_t max)

Generate a code axis array for an explicit code range.

Parameters:
  • out – [out] Array pointer

  • size – [in] Array size

  • min – [in] Min code

  • max – [in] Max code

Returns:

0 on success, non-zero otherwise

int gn_dnl(double *dnl, size_t dnl_size, const uint64_t *hist, size_t hist_size, GnDnlSignal type)

Compute Differential Nonlinearity (DNL) from histogram data.

Parameters:
  • dnl – [out] Output array pointer

  • dnl_size – [in] Output array size

  • hist – [in] Input array pointer

  • hist_size – [in] Input array size

  • type – [in] Signal type

Returns:

0 on success, non-zero otherwise

int gn_dnl_analysis(char **rkeys, size_t rkeys_size, double *rvalues, size_t rvalues_size, const double *dnl, size_t dnl_size)

Compute summary statistics of DNL data.

The results contain the following key-value pairs (see general description of Analysis Routines).

Key

Description

min

Minumum value

max

Maximum value

avg

Average value

rms

RMS value

min_index

Index of first occurence of minimum value

max_index

Index of first occurence of maximum value

first_nm_index

Index of first non-missing code

last_nm_index

Index of last non-missing code

nm_range

Non-missing code range (1 + (last_nm_index - first_nm_index))

Parameters:
  • rkeys – [out] Result keys array pointer

  • rkeys_size – [in] Result keys array size

  • rvalues – [out] Result values array pointer

  • rvalues_size – [in] Result values array size

  • dnl – [in] Input array pointer

  • dnl_size – [in] Input array size

Returns:

0 on success, non-zero otherwise

int gn_hist16(uint64_t *hist, size_t hist_size, const int16_t *in, size_t in_size, int n, GnCodeFormat format, bool preserve)

Compute a code density histogram from 16-bit quantized waveform data.

Parameters:
  • hist – [out] Histogram array pointer

  • hist_size – [in] Histogram array size

  • in – [in] Input array pointer

  • in_size – [in] Input array size

  • n – [in] Code width (i.e. ADC resolution)

  • format – [in] Code format

  • preserve – [in] If true, hist is not cleared before computing the histogram

Returns:

0 on success, non-zero otherwise

int gn_hist32(uint64_t *hist, size_t hist_size, const int32_t *in, size_t in_size, int n, GnCodeFormat format, bool preserve)

Compute a code density histogram from 32-bit quantized waveform data.

Parameters:
  • hist – [out] Histogram array pointer

  • hist_size – [in] Histogram array size

  • in – [in] Input array pointer

  • in_size – [in] Input array size

  • n – [in] Code width (i.e. ADC resolution)

  • format – [in] Code format

  • preserve – [in] If true, hist is not cleared before computing the histogram

Returns:

0 on success, non-zero otherwise

int gn_hist64(uint64_t *hist, size_t hist_size, const int64_t *in, size_t in_size, int n, GnCodeFormat format, bool preserve)

Compute a code density histogram from 64-bit quantized waveform data.

Parameters:
  • hist – [out] Histogram array pointer

  • hist_size – [in] Histogram array size

  • in – [in] Input array pointer

  • in_size – [in] Input array size

  • n – [in] Code width (i.e. ADC resolution)

  • format – [in] Code format

  • preserve – [in] If true, hist is not cleared before computing the histogram

Returns:

0 on success, non-zero otherwise

int gn_histx16(uint64_t *hist, size_t hist_size, const int16_t *in, size_t in_size, int64_t min, int64_t max, bool preserve)

Compute a code density histogram from 16-bit data using explicit code bounds.

Parameters:
  • hist – [out] Histogram array pointer

  • hist_size – [in] Histogram array size

  • in – [in] Input array pointer

  • in_size – [in] Input array size

  • min – [in] Min code

  • max – [in] Max code

  • preserve – [in] If true, hist is not cleared before computing the histogram

Returns:

0 on success, non-zero otherwise

int gn_histx32(uint64_t *hist, size_t hist_size, const int32_t *in, size_t in_size, int64_t min, int64_t max, bool preserve)

Compute a code density histogram from 32-bit data using explicit code bounds.

Parameters:
  • hist – [out] Histogram array pointer

  • hist_size – [in] Histogram array size

  • in – [in] Input array pointer

  • in_size – [in] Input array size

  • min – [in] Min code

  • max – [in] Max code

  • preserve – [in] If true, hist is not cleared before computing the histogram

Returns:

0 on success, non-zero otherwise

int gn_histx64(uint64_t *hist, size_t hist_size, const int64_t *in, size_t in_size, int64_t min, int64_t max, bool preserve)

Compute a code density histogram from 64-bit data using explicit code bounds.

Parameters:
  • hist – [out] Histogram array pointer

  • hist_size – [in] Histogram array size

  • in – [in] Input array pointer

  • in_size – [in] Input array size

  • min – [in] Min code

  • max – [in] Max code

  • preserve – [in] If true, hist is not cleared before computing the histogram

Returns:

0 on success, non-zero otherwise

int gn_hist_analysis(char **rkeys, size_t rkeys_size, double *rvalues, size_t rvalues_size, const uint64_t *hist, size_t hist_size)

Compute summary statistics of histogram data.

The results contain the following key-value pairs (see general description of Analysis Routines).

Key

Description

sum

Sum of all histogram bins

first_nz_index

First non-zero bin

last_nz_index

Last non-zero bin

nz_range

Non-zero bin range (1 + (last_nz_index - first_nz_index))

Parameters:
  • rkeys – [out] Result keys array pointer

  • rkeys_size – [in] Result keys array size

  • rvalues – [out] Result values array pointer

  • rvalues_size – [in] Result values array size

  • hist – [in] Input array pointer

  • hist_size – [in] Input array size

Returns:

0 on success, non-zero otherwise

int gn_inl(double *inl, size_t inl_size, const double *dnl, size_t dnl_size, GnInlLineFit fit)

Compute Integral Nonlinearity (INL) from DNL data.

Parameters:
  • inl – [out] Output array pointer

  • inl_size – [in] Output array size

  • dnl – [in] Input array pointer

  • dnl_size – [in] Input array size

  • fit – [in] Line fit type

Returns:

0 on success, non-zero otherwise

int gn_inl_analysis(char **rkeys, size_t rkeys_size, double *rvalues, size_t rvalues_size, const double *inl, size_t inl_size)

Compute summary statistics of INL data.

The results contain the following key-value pairs (see general description of Analysis Routines).

Key

Description

min

Minumum value

max

Maximum value

min_index

Index of first occurence of minimum value

max_index

Index of first occurence of maximum value

Parameters:
  • rkeys – [out] Result keys array pointer

  • rkeys_size – [in] Result keys array size

  • rvalues – [out] Result values array pointer

  • rvalues_size – [in] Result values array size

  • inl – [in] Input array pointer

  • inl_size – [in] Input array size

Returns:

0 on success, non-zero otherwise

Code Density Helpers

group Helpers

Functions

int gn_code_density_size(size_t *size, int n, GnCodeFormat format)

Get the histogram array size for a given resolution and code format.

Parameters:
  • size – [out] Output array size

  • n – [in] Code width (i.e. ADC resolution)

  • format – [in] Code format

Returns:

0 on success, non-zero otherwise

int gn_code_densityx_size(size_t *size, int64_t min, int64_t max)

Get the histogram array size for an explicit code range.

Parameters:
  • size – [out] Output array size

  • min – [in] Min code

  • max – [in] Max code

Returns:

0 on success, non-zero otherwise

Fourier Analysis

group Fourier Analysis

Functions

int gn_fft_analysis(char **rkeys, size_t rkeys_size, double *rvalues, size_t rvalues_size, const char *cfg_id, const double *in, size_t in_size, size_t nfft, GnFreqAxisType axis_type)

Run Fourier analysis and return all results.

The results contain the following key-value pairs (see general description of Analysis Routines).

Key

Description

Units

signaltype

Signal type: 0=Real, 1=Complex

nfft

FFT size

datasize

Data size

fbin

Frequency bin size

Hz

fdata

Data rate

S/s

fsample

Sample rate

S/s

fshift

Shift frequency

Hz

fsnr

Full-scale-to-noise ratio (a.k.a. “SNRFS”)

dB

snr

Signal-to-noise ratio

dB

sinad

Signal-to-noise-and-distortion ratio

dB

sfdr

Spurious-free dynamic range

dB

abn

Average bin noise

dBFS

nsd

Noise spectral density

dBFS/Hz

carrierindex

Order index of the Carrier tone

maxspurindex

Order index of the MaxSpur tone

ab_width

Analysis band width

Hz

ab_i1

Analysis band first index

ab_i2

Analysis band last index

{PREFIX}_nbins

Number of bins associated with PREFIX

{PREFIX}_rss

Root-sum-square associated with PREFIX

{TONEKEY}:orderindex

Tone order index

{TONEKEY}:freq

Tone frequency

Hz

{TONEKEY}:ffinal

Tone final frequency

Hz

{TONEKEY}:fwavg

Tone weighted-average frequency

Hz

{TONEKEY}:i1

Tone first index

{TONEKEY}:i2

Tone last index

{TONEKEY}:nbins

Tone number of bins

{TONEKEY}:inband

0: tone is in-band; 1: tone is out-of-band

{TONEKEY}:mag

Tone magnitude

{TONEKEY}:mag_dbfs

Tone magnitude relative to full-scale

dBFS

{TONEKEY}:mag_dbc

Tone magnitude relative to carrier

dBc

{TONEKEY}:phase

Tone phase

rad

{TONEKEY}:phase_c

Tone phase relative to carrier

rad

Parameters:
  • rkeys – [out] Result keys array pointer

  • rkeys_size – [in] Result keys array size

  • rvalues – [out] Result values array pointer

  • rvalues_size – [in] Result values array size

  • cfg_id – [in] Configuration identifier (filename or object key)

  • in – [in] Interleaved Re/Im input array pointer

  • in_size – [in] Input array size

  • nfft – [in] FFT size

  • axis_type – [in] Frequency axis type

Returns:

0 on success, non-zero otherwise

int gn_fft_analysis_select(double *rvalues, size_t rvalues_size, const char *cfg_id, const char **rkeys, size_t rkeys_size, const double *in, size_t in_size, size_t nfft, GnFreqAxisType axis_type)

Run Fourier analysis and return only the requested result keys.

Parameters:
  • rvalues – [out] Result values array pointer

  • rvalues_size – [in] Result values array size

  • cfg_id – [in] Configuration identifier (filename or object key)

  • rkeys – [in] Result keys array pointer

  • rkeys_size – [in] Result keys array size

  • in – [in] Interleaved Re/Im input array pointer

  • in_size – [in] Input array size

  • nfft – [in] FFT size

  • axis_type – [in] Frequency axis type

Returns:

0 on success, non-zero otherwise

int gn_fft_analysis_single(double *rvalue, const char *cfg_id, const char *rkey, const double *in, size_t in_size, size_t nfft, GnFreqAxisType axis_type)

Run Fourier analysis and return a single result by key.

Parameters:
  • rvalue – [out] Result value

  • cfg_id – [in] Configuration identifier (filename or object key)

  • rkey – [in] Result key

  • in – [in] Interleaved Re/Im input array pointer

  • in_size – [in] Input array size

  • nfft – [in] FFT size

  • axis_type – [in] Frequency axis type

Returns:

0 on success, non-zero otherwise

Fourier Analysis Configuration

group Configuration

Functions

int gn_fa_analysis_band(const char *obj_key, double center, double width)

Set the analysis band center and width in Hz.

Parameters:
  • obj_key – [in] Object key

  • center – [in] Analysis band center

  • width – [in] Analysis band width

Returns:

0 on success, non-zero otherwise

int gn_fa_analysis_band_e(const char *obj_key, const char *center, const char *width)

Set the analysis band center and width as expressions.

Parameters:
  • obj_key – [in] Object key

  • center – [in] Analysis band center expression

  • width – [in] Analysis band width expression

Returns:

0 on success, non-zero otherwise

int gn_fa_clk(const char *obj_key, const int *clk, size_t clk_size, bool as_noise)

Configure clock sub-harmonic divisors for clock spur identification.

Parameters:
  • obj_key – [in] Object key

  • clk – [in] Pointer to array of clock divisors

  • clk_size – [in] Size of array of clock divisors

  • as_noise – [in] If true, CLK components will be treated as noise

Returns:

0 on success, non-zero otherwise

int gn_fa_conv_offset(const char *obj_key, bool enable)

Enable or disable the converter offset component.

Parameters:
  • obj_key – [in] Object key

  • enable – [in] If true, enable converter offset

Returns:

0 on success, non-zero otherwise

int gn_fa_create(const char *obj_key)

Create a new Fourier analysis configuration object.

Parameters:

obj_key – [in] Object key

Returns:

0 on success, non-zero otherwise

int gn_fa_dc(const char *obj_key, bool as_dist)

Set whether DC is classified as distortion or noise.

Parameters:
  • obj_key – [in] Object key

  • as_dist – [in] If true, treat DC as distortion

Returns:

0 on success, non-zero otherwise

int gn_fa_fdata(const char *obj_key, double f)

Set the data rate in Hz.

Parameters:
  • obj_key – [in] Object key

  • f – [in] fdata

Returns:

0 on success, non-zero otherwise

int gn_fa_fdata_e(const char *obj_key, const char *f)

Set the data rate as an expression.

Parameters:
  • obj_key – [in] Object key

  • f – [in] fdata expression

Returns:

0 on success, non-zero otherwise

int gn_fa_fixed_tone(const char *obj_key, const char *comp_key, GnFACompTag tag, double freq, int ssb)

Add a tone component at a fixed frequency in Hz.

Parameters:
  • obj_key – [in] Object key

  • comp_key – [in] Component key

  • tag – [in] Tag

  • freq – [in] Frequency

  • ssb – [in] Number of single-side bins

Returns:

0 on success, non-zero otherwise

int gn_fa_fixed_tone_e(const char *obj_key, const char *comp_key, GnFACompTag tag, const char *freq, int ssb)

Add a tone component at a fixed frequency specified as an expression.

Parameters:
  • obj_key – [in] Object key

  • comp_key – [in] Component key

  • tag – [in] Tag

  • freq – [in] Frequency expression

  • ssb – [in] Number of single-side bins

Returns:

0 on success, non-zero otherwise

int gn_fa_fsample(const char *obj_key, double f)

Set the sample rate in Hz.

Parameters:
  • obj_key – [in] Object key

  • f – [in] fsample

Returns:

0 on success, non-zero otherwise

int gn_fa_fsample_e(const char *obj_key, const char *f)

Set the sample rate as an expression.

Parameters:
  • obj_key – [in] Object key

  • f – [in] fsample expression

Returns:

0 on success, non-zero otherwise

int gn_fa_fshift(const char *obj_key, double f)

Set the shift frequency in Hz.

Parameters:
  • obj_key – [in] Object key

  • f – [in] fshift

Returns:

0 on success, non-zero otherwise

int gn_fa_fshift_e(const char *obj_key, const char *f)

Set the shift frequency as an expression.

Parameters:
  • obj_key – [in] Object key

  • f – [in] fshift expression

Returns:

0 on success, non-zero otherwise

int gn_fa_fund_images(const char *obj_key, bool enable)

Enable or disable fundamental image components.

Parameters:
  • obj_key – [in] Object key

  • enable – [in] If true, enable fundamental images

Returns:

0 on success, non-zero otherwise

int gn_fa_hd(const char *obj_key, int n)

Set the maximum harmonic distortion order.

Parameters:
  • obj_key – [in] Object key

  • n – [in] Order of harmonic distortion, i.e., the maximum harmonic

Returns:

0 on success, non-zero otherwise

int gn_fa_ilv(const char *obj_key, const int *ilv, size_t ilv_size, bool as_noise)

Configure interleaving factors for interleaving spur identification.

Parameters:
  • obj_key – [in] Object key

  • ilv – [in] Pointer to array of interleaving factors

  • ilv_size – [in] Size of array of interleaving factors

  • as_noise – [in] If true, ILV components will be treated as noise

Returns:

0 on success, non-zero otherwise

int gn_fa_imd(const char *obj_key, int n)

Set the maximum intermodulation distortion order.

Parameters:
  • obj_key – [in] Object key

  • n – [in] Order of intermodulation distortion

Returns:

0 on success, non-zero otherwise

int gn_fa_load(char *buf, size_t size, const char *filename, const char *obj_key)

Load a Fourier analysis configuration from a JSON file.

If obj_key is empty, the object key is derived from filename.

Parameters:
  • buf – [out] Pointer to character array

  • size – [in] Size of character array

  • filename – [in] Filename

  • obj_key – [in] Object key

Returns:

0 on success, non-zero otherwise

int gn_fa_max_tone(const char *obj_key, const char *comp_key, GnFACompTag tag, int ssb)

Add a tone component at the spectral maximum.

Parameters:
  • obj_key – [in] Object key

  • comp_key – [in] Component key

  • tag – [in] Tag

  • ssb – [in] Number of single-side bins

Returns:

0 on success, non-zero otherwise

int gn_fa_preview(char *buf, size_t size, const char *cfg_id, bool cplx)

Get a string preview of the analysis configuration.

Parameters:
  • buf – [out] Pointer to character array

  • size – [in] Size of character array

  • cfg_id – [in] Configuration identifier (filename or object key)

  • cplx – [in] If true, preview will include complex components

Returns:

0 on success, non-zero otherwise

int gn_fa_quad_errors(const char *obj_key, bool enable)

Enable or disable quadrature error components.

Parameters:
  • obj_key – [in] Object key

  • enable – [in] If true, enable quadrature errors

Returns:

0 on success, non-zero otherwise

int gn_fa_remove_comp(const char *obj_key, const char *comp_key)

Remove a user-defined component from the analysis.

Parameters:
  • obj_key – [in] Object key

  • comp_key – [in] Component key

Returns:

0 on success, non-zero otherwise

int gn_fa_reset(const char *obj_key)

Reset a Fourier analysis object to default configuration.

Parameters:

obj_key – [in] Object key

Returns:

0 on success, non-zero otherwise

int gn_fa_ssb(const char *obj_key, GnFASsb group, int ssb)

Set the number of single-side bins for a component group.

Parameters:
  • obj_key – [in] Object key

  • group – [in] SSB group

  • ssb – [in] Number of single-side bins

Returns:

0 on success, non-zero otherwise

int gn_fa_var(const char *obj_key, const char *name, double value)

Set the value of an expression variable.

Parameters:
  • obj_key – [in] Object key

  • name – [in] Variable name

  • value – [in] Variable value

Returns:

0 on success, non-zero otherwise

int gn_fa_wo(const char *obj_key, int n)

Set the number of worst-other tones to identify.

Parameters:
  • obj_key – [in] Object key

  • n – [in] Number of worst others

Returns:

0 on success, non-zero otherwise

Fourier Analysis Results

group Results

Functions

int gn_fa_result(double *result, const char **rkeys, size_t rkeys_size, const double *rvalues, size_t rvalues_size, const char *rkey)

Look up a single numeric result by key from analysis results.

Parameters:
  • result – [out] Result associated with rkey

  • rkeys – [in] Result keys array pointer

  • rkeys_size – [in] Result keys array size

  • rvalues – [in] Result values array pointer

  • rvalues_size – [in] Result values array size

  • rkey – [in] Key of desired result

Returns:

0 on success, non-zero otherwise

int gn_fa_result_string(char *result, size_t result_size, const char **rkeys, size_t rkeys_size, const double *rvalues, size_t rvalues_size, const char *rkey)

Format a single analysis result as a human-readable string.

Parameters:
  • result – [out] Result string associated with rkey

  • result_size – [in] Size of result string

  • rkeys – [in] Result keys array pointer

  • rkeys_size – [in] Result keys array size

  • rvalues – [in] Result values array pointer

  • rvalues_size – [in] Result values array size

  • rkey – [in] Key of desired result

Returns:

0 on success, non-zero otherwise

Fourier Analysis Helpers

group Helpers

Functions

int gn_fa_load_key_size(size_t *size, const char *filename, const char *obj_key)

Get the size of the object key string returned by gn_fa_load.

The library string termination setting determines whether or not a null terminator is included in the size. See gn_set_string_termination.

Parameters:
  • size – [out] Number of characters in key

  • filename – [in] Filename

  • obj_key – [in] Object key

Returns:

0 on success, non-zero otherwise

int gn_fa_preview_size(size_t *size, const char *cfg_id, bool cplx)

Get the size of the preview string returned by gn_fa_preview.

The library string termination setting determines whether or not a null terminator is included in the size. See gn_set_string_termination.

Parameters:
  • size – [out] Number of characters in compenent list string

  • cfg_id – [in] Configuration identifier (filename or object key)

  • cplx – [in] If true, list will include complex components

Returns:

0 on success, non-zero otherwise

int gn_fa_result_string_size(size_t *size, const char **rkeys, size_t rkeys_size, const double *rvalues, size_t rvalues_size, const char *rkey)

Get the size of the string returned by gn_fa_result_string.

The library string termination setting determines whether or not a null terminator is included in the size. See gn_set_string_termination.

Parameters:
  • size – [out] Number of characters result string

  • rkeys – [in] Result keys array pointer

  • rkeys_size – [in] Result keys array size

  • rvalues – [in] Result values array pointer

  • rvalues_size – [in] Result values array size

  • rkey – [in] Key of desired result

Returns:

0 on success, non-zero otherwise

int gn_fft_analysis_results_key_sizes(size_t *key_sizes, size_t key_sizes_size, const char *cfg_id, size_t in_size, size_t nfft)

Get the size of each key string in Fourier analysis results.

The library string termination setting determines whether or not a null terminator is included in the key sizes. See gn_set_string_termination.

Parameters:
  • key_sizes – [out] Key size array pointer

  • key_sizes_size – [in] Key size array size

  • cfg_id – [in] Configuration identifier (filename or object key)

  • in_size – [in] Input array size

  • nfft – [in] FFT size

Returns:

0 on success, non-zero otherwise

int gn_fft_analysis_results_size(size_t *size, const char *cfg_id, size_t in_size, size_t nfft)

Get the number of key-value pairs in Fourier analysis results.

Parameters:
  • size – [out] Number of key-value result pairs

  • cfg_id – [in] Configuration identifier (filename or object key)

  • in_size – [in] Input array size

  • nfft – [in] FFT size

Returns:

0 on success, non-zero otherwise

Fourier Transforms

group Fourier Transforms

Functions

int gn_fft(double *out, size_t out_size, const double *i, size_t i_size, const double *q, size_t q_size, size_t navg, size_t nfft, GnWindow window)

Compute the complex FFT of normalized (double) I/Q data.

Parameters:
  • out – [out] Interleaved Re/Im output array pointer

  • out_size – [in] Output array size

  • i – [in] In-phase input array pointer

  • i_size – [in] In-phase input array size

  • q – [in] Quadrature input array pointer

  • q_size – [in] Quadrature input array size

  • navg – [in] FFT averaging number

  • nfft – [in] FFT size

  • window – [in] Window

Returns:

0 on success, non-zero otherwise

int gn_fft16(double *out, size_t out_size, const int16_t *i, size_t i_size, const int16_t *q, size_t q_size, int n, size_t navg, size_t nfft, GnWindow window, GnCodeFormat format)

Compute the complex FFT of 16-bit quantized I/Q data.

Parameters:
  • out – [out] Interleaved Re/Im output array pointer

  • out_size – [in] Output array size

  • i – [in] In-phase input array pointer

  • i_size – [in] In-phase input array size

  • q – [in] Quadrature input array pointer

  • q_size – [in] Quadrature input array size

  • n – [in] Resolution

  • navg – [in] FFT averaging number

  • nfft – [in] FFT size

  • window – [in] Window

  • format – [in] Code format

Returns:

0 on success, non-zero otherwise

int gn_fft32(double *out, size_t out_size, const int32_t *i, size_t i_size, const int32_t *q, size_t q_size, int n, size_t navg, size_t nfft, GnWindow window, GnCodeFormat format)

Compute the complex FFT of 32-bit quantized I/Q data.

Parameters:
  • out – [out] Interleaved Re/Im output array pointer

  • out_size – [in] Output array size

  • i – [in] In-phase input array pointer

  • i_size – [in] In-phase input array size

  • q – [in] Quadrature input array pointer

  • q_size – [in] Quadrature input array size

  • n – [in] Resolution

  • navg – [in] FFT averaging number

  • nfft – [in] FFT size

  • window – [in] Window

  • format – [in] Code format

Returns:

0 on success, non-zero otherwise

int gn_fft64(double *out, size_t out_size, const int64_t *i, size_t i_size, const int64_t *q, size_t q_size, int n, size_t navg, size_t nfft, GnWindow window, GnCodeFormat format)

Compute the complex FFT of 64-bit quantized I/Q data.

Parameters:
  • out – [out] Interleaved Re/Im output array pointer

  • out_size – [in] Output array size

  • i – [in] In-phase input array pointer

  • i_size – [in] In-phase input array size

  • q – [in] Quadrature input array pointer

  • q_size – [in] Quadrature input array size

  • n – [in] Resolution

  • navg – [in] FFT averaging number

  • nfft – [in] FFT size

  • window – [in] Window

  • format – [in] Code format

Returns:

0 on success, non-zero otherwise

int gn_rfft(double *out, size_t out_size, const double *in, size_t in_size, size_t navg, size_t nfft, GnWindow window, GnRfftScale scale)

Compute the real FFT (one-sided spectrum) of normalized (double) data.

This function will be implemented in the future.

Parameters:
  • out – [out] Interleaved Re/Im output array pointer

  • out_size – [in] Output array size

  • in – [in] Input array pointer

  • in_size – [in] Input array size

  • navg – [in] FFT averaging number

  • nfft – [in] FFT size

  • window – [in] Window

  • scale – [in] Scaling mode

Returns:

0 on success, non-zero otherwise

int gn_rfft16(double *out, size_t out_size, const int16_t *in, size_t in_size, int n, size_t navg, size_t nfft, GnWindow window, GnCodeFormat format, GnRfftScale scale)

Compute the real FFT of 16-bit quantized data.

Parameters:
  • out – [out] Interleaved Re/Im output array pointer

  • out_size – [in] Output array size

  • in – [in] Input array pointer

  • in_size – [in] Input array size

  • n – [in] Resolution

  • navg – [in] FFT averaging number

  • nfft – [in] FFT size

  • window – [in] Window

  • format – [in] Code format

  • scale – [in] Scaling mode

Returns:

0 on success, non-zero otherwise

int gn_rfft32(double *out, size_t out_size, const int32_t *in, size_t in_size, int n, size_t navg, size_t nfft, GnWindow window, GnCodeFormat format, GnRfftScale scale)

Compute the real FFT of 32-bit quantized data.

Parameters:
  • out – [out] Interleaved Re/Im output array pointer

  • out_size – [in] Output array size

  • in – [in] Input array pointer

  • in_size – [in] Input array size

  • n – [in] Resolution

  • navg – [in] FFT averaging number

  • nfft – [in] FFT size

  • window – [in] Window

  • format – [in] Code format

  • scale – [in] Scaling mode

Returns:

0 on success, non-zero otherwise

int gn_rfft64(double *out, size_t out_size, const int64_t *in, size_t in_size, int n, size_t navg, size_t nfft, GnWindow window, GnCodeFormat format, GnRfftScale scale)

Compute the real FFT of 64-bit quantized data.

Parameters:
  • out – [out] Interleaved Re/Im output array pointer

  • out_size – [in] Output array size

  • in – [in] Input array pointer

  • in_size – [in] Input array size

  • n – [in] Resolution

  • navg – [in] FFT averaging number

  • nfft – [in] FFT size

  • window – [in] Window

  • format – [in] Code format

  • scale – [in] Scaling mode

Returns:

0 on success, non-zero otherwise

Fourier Transform Helpers

group Helpers

Functions

int gn_fft_size(size_t *out_size, size_t i_size, size_t q_size, size_t navg, size_t nfft)

Get the output array size for complex FFT functions.

Parameters:
  • out_size – [out] Output array size

  • i_size – [in] In-phase input array size

  • q_size – [in] Quadrature input array size

  • navg – [in] FFT averaging number

  • nfft – [in] FFT size

Returns:

0 on success, non-zero otherwise

int gn_rfft_size(size_t *out_size, size_t in_size, size_t navg, size_t nfft)

Get the output array size for real FFT functions.

Parameters:
  • out_size – [out] Output array size

  • in_size – [in] Input array size

  • navg – [in] FFT averaging number

  • nfft – [in] FFT size

Returns:

0 on success, non-zero otherwise

Fourier Utilities

group Fourier Utilities

Functions

int gn_alias(double *out, double fs, double freq, GnFreqAxisType axis_type)

Compute the aliased frequency for a given sample rate and axis type.

Parameters:
  • out – [out] Output pointer

  • fs – [in] Sample rate (S/s)

  • freq – [in] Frequency (Hz)

  • axis_type – [in] Frequency axis type

Returns:

0 on success, non-zero otherwise

int gn_coherent(double *out, size_t nfft, double fs, double freq)

Compute the nearest coherent frequency for a given FFT size and sample rate.

Parameters:
  • out – [out] Output pointer

  • nfft – [in] FFT size

  • fs – [in] Sample rate (S/s)

  • freq – [in] Desired frequency (Hz)

Returns:

0 on success, non-zero otherwise

int gn_fftshift(double *out, size_t out_size, const double *in, size_t in_size)

Shift the DC component to the center of the spectrum.

Parameters:
  • out – [out] Output array pointer

  • out_size – [in] Output array size

  • in – [in] Input array pointer

  • in_size – [in] Input array size

Returns:

0 on success, non-zero otherwise

int gn_freq_axis(double *out, size_t size, size_t nfft, GnFreqAxisType axis_type, double fs, GnFreqAxisFormat axis_format)

Generate a frequency axis array for plotting FFT results.

Parameters:
  • out – [out] Array pointer

  • size – [in] Array size

  • nfft – [in] FFT size

  • axis_type – [in] Frequency axis type

  • fs – [in] Sample rate (S/s)

  • axis_format – [in] Frequency axis format

Returns:

0 on success, non-zero otherwise

int gn_ifftshift(double *out, size_t out_size, const double *in, size_t in_size)

Shift the DC component from the center back to the left of the spectrum.

Parameters:
  • out – [out] Output array pointer

  • out_size – [in] Output array size

  • in – [in] Input array pointer

  • in_size – [in] Input array size

Returns:

0 on success, non-zero otherwise

Fourier Utility Helpers

group Helpers

Functions

int gn_freq_axis_size(size_t *size, size_t nfft, GnFreqAxisType axis_type)

Get the size of the frequency axis array.

Parameters:
  • size – [out] Output array size

  • nfft – [in] FFT size

  • axis_type – [in] Frequency axis type

Returns:

0 on success, non-zero otherwise

Manager

group Manager

Functions

int gn_mgr_clear()

Remove all objects from the global object manager.

Returns:

Always returns 0

int gn_mgr_compare(bool *result, const char *obj_key1, const char *obj_key2)

Compare two managed objects for equality.

Parameters:
  • result – [out] true if the objects are equal, false otherwise

  • obj_key1 – [in] Object key 1

  • obj_key2 – [in] Object key 2

Returns:

0 on success, non-zero otherwise

int gn_mgr_contains(bool *result, const char *obj_key)

Check whether the manager contains an object with the given key.

Parameters:
  • result – [out] true if Manager contains key, false otherwise

  • obj_key – [in] Object key

Returns:

Always returns 0

int gn_mgr_remove(const char *obj_key)

Remove an object from the manager.

Parameters:

obj_key – [in] Object key

Returns:

Always returns 0

int gn_mgr_save(char *buf, size_t size, const char *obj_key, const char *filename)

Serialize a managed object to a JSON file.

If filename is empty, the filename is derived from obj_key.

Parameters:
  • buf – [out] Pointer to character array

  • size – [in] Size of character array

  • obj_key – [in] Object key

  • filename – [in] Filename

Returns:

0 on success, non-zero otherwise

int gn_mgr_size(size_t *size)

Get the number of objects in the manager.

Parameters:

size – [out] Number of objects owned by the manager

Returns:

Always returns 0

int gn_mgr_to_string(char *buf, size_t size, const char *obj_key)

Get a string representation of a managed object.

Parameters:
  • buf – [out] Pointer to character array

  • size – [in] Size of character array

  • obj_key – [in] Object key

Returns:

0 on success, non-zero otherwise

int gn_mgr_type(char *buf, size_t size, const char *obj_key)

Get the type name of a managed object.

Parameters:
  • buf – [out] Pointer to character array

  • size – [in] Size of character array

  • obj_key – [in] Object key

Returns:

0 on success, non-zero otherwise

Manager Helpers

group Helpers

Functions

int gn_mgr_save_filename_size(size_t *size, const char *obj_key, const char *filename)

Get the size of the filename string returned by gn_mgr_save.

The library string termination setting determines whether or not a null terminator is included in the size. See gn_set_string_termination.

Parameters:
  • size – [out] Number of characters in filename

  • obj_key – [in] Object key

  • filename – [in] Filename

Returns:

0 on success, non-zero otherwise

int gn_mgr_to_string_size(size_t *size, const char *obj_key)

Get the size of the string returned by gn_mgr_to_string.

The library string termination setting determines whether or not a null terminator is included in the size. See gn_set_string_termination.

Parameters:
  • size – [out] Number of characters in the string

  • obj_key – [in] Object key

Returns:

0 on success, non-zero otherwise

int gn_mgr_type_size(size_t *size, const char *obj_key)

Get the size of the type string returned by gn_mgr_type.

The library string termination setting determines whether or not a null terminator is included in the size. See gn_set_string_termination.

Parameters:
  • size – [out] Number of characters in object type string

  • obj_key – [in] Object key

Returns:

0 on success, non-zero otherwise

Signal Processing

group Signal Processing

Functions

int gn_downsample(double *out, size_t out_size, const double *in, size_t in_size, int ratio, bool interleaved)

Decimate a normalized (double) waveform by keeping every Nth sample.

Parameters:
  • out – [out] Output array pointer

  • out_size – [in] Output array size

  • in – [in] Input array pointer

  • in_size – [in] Input array size

  • ratio – [in] Downsample ratio

  • interleaved – [in] If true, ‘in’ is interleaved I/Q data

Returns:

0 on success, non-zero otherwise

int gn_downsample16(int16_t *out, size_t out_size, const int16_t *in, size_t in_size, int ratio, bool interleaved)

Decimate a 16-bit waveform by keeping every Nth sample.

Parameters:
  • out – [out] Output array pointer

  • out_size – [in] Output array size

  • in – [in] Input array pointer

  • in_size – [in] Input array size

  • ratio – [in] Downsample ratio

  • interleaved – [in] If true, ‘in’ is interleaved I/Q data

Returns:

0 on success, non-zero otherwise

int gn_downsample32(int32_t *out, size_t out_size, const int32_t *in, size_t in_size, int ratio, bool interleaved)

Decimate a 32-bit waveform by keeping every Nth sample.

Parameters:
  • out – [out] Output array pointer

  • out_size – [in] Output array size

  • in – [in] Input array pointer

  • in_size – [in] Input array size

  • ratio – [in] Downsample ratio

  • interleaved – [in] If true, ‘in’ is interleaved I/Q data

Returns:

0 on success, non-zero otherwise

int gn_downsample64(int64_t *out, size_t out_size, const int64_t *in, size_t in_size, int ratio, bool interleaved)

Decimate a 64-bit waveform by keeping every Nth sample.

Parameters:
  • out – [out] Output array pointer

  • out_size – [in] Output array size

  • in – [in] Input array pointer

  • in_size – [in] Input array size

  • ratio – [in] Downsample ratio

  • interleaved – [in] If true, ‘in’ is interleaved I/Q data

Returns:

0 on success, non-zero otherwise

int gn_fshift(double *out, size_t out_size, const double *i, size_t i_size, const double *q, size_t q_size, double fs, double fshift)

Apply a frequency shift to normalized (double) complex data.

Parameters:
  • out – [out] Output array pointer

  • out_size – [in] Output array size

  • i – [in] In-phase input array pointer

  • i_size – [in] In-phase input array size

  • q – [in] Quadrature input array pointer

  • q_size – [in] Quadrature input array size

  • fs – [in] Sample rate

  • fshift – [in] Shift frequency

Returns:

0 on success, non-zero otherwise

int gn_fshift16(int16_t *out, size_t out_size, const int16_t *i, size_t i_size, const int16_t *q, size_t q_size, int n, double fs, double fshift, GnCodeFormat format)

Apply a frequency shift to 16-bit quantized complex data.

Parameters:
  • out – [out] Output array pointer

  • out_size – [in] Output array size

  • i – [in] In-phase input array pointer

  • i_size – [in] In-phase input array size

  • q – [in] Quadrature input array pointer

  • q_size – [in] Quadrature input array size

  • n – [in] Code width

  • fs – [in] Sample rate

  • fshift – [in] Shift frequency

  • format – [in] Code format

Returns:

0 on success, non-zero otherwise

int gn_fshift32(int32_t *out, size_t out_size, const int32_t *i, size_t i_size, const int32_t *q, size_t q_size, int n, double fs, double fshift, GnCodeFormat format)

Apply a frequency shift to 32-bit quantized complex data.

Parameters:
  • out – [out] Output array pointer

  • out_size – [in] Output array size

  • i – [in] In-phase input array pointer

  • i_size – [in] In-phase input array size

  • q – [in] Quadrature input array pointer

  • q_size – [in] Quadrature input array size

  • n – [in] Code width

  • fs – [in] Sample rate

  • fshift – [in] Shift frequency

  • format – [in] Code format

Returns:

0 on success, non-zero otherwise

int gn_fshift64(int64_t *out, size_t out_size, const int64_t *i, size_t i_size, const int64_t *q, size_t q_size, int n, double fs, double fshift, GnCodeFormat format)

Apply a frequency shift to 64-bit quantized complex data.

Parameters:
  • out – [out] Output array pointer

  • out_size – [in] Output array size

  • i – [in] In-phase input array pointer

  • i_size – [in] In-phase input array size

  • q – [in] Quadrature input array pointer

  • q_size – [in] Quadrature input array size

  • n – [in] Code width

  • fs – [in] Sample rate

  • fshift – [in] Shift frequency

  • format – [in] Code format

Returns:

0 on success, non-zero otherwise

int gn_normalize16(double *out, size_t out_size, const int16_t *in, size_t in_size, int n, GnCodeFormat format)

Convert 16-bit quantized samples to normalized floating-point values.

Parameters:
  • out – [out] Output array pointer

  • out_size – [in] Output array size

  • in – [in] Input array pointer

  • in_size – [in] Input array size

  • n – [in] Resolution

  • format – [in] Code format

Returns:

0 on success, non-zero otherwise

int gn_normalize32(double *out, size_t out_size, const int32_t *in, size_t in_size, int n, GnCodeFormat format)

Convert 32-bit quantized samples to normalized floating-point values.

Parameters:
  • out – [out] Output array pointer

  • out_size – [in] Output array size

  • in – [in] Input array pointer

  • in_size – [in] Input array size

  • n – [in] Resolution

  • format – [in] Code format

Returns:

0 on success, non-zero otherwise

int gn_normalize64(double *out, size_t out_size, const int64_t *in, size_t in_size, int n, GnCodeFormat format)

Convert 64-bit quantized samples to normalized floating-point values.

Parameters:
  • out – [out] Output array pointer

  • out_size – [in] Output array size

  • in – [in] Input array pointer

  • in_size – [in] Input array size

  • n – [in] Resolution

  • format – [in] Code format

Returns:

0 on success, non-zero otherwise

int gn_polyval(double *out, size_t out_size, const double *in, size_t in_size, const double *c, size_t c_size)

Evaluate a polynomial at each element of the input array.

Parameters:
  • out – [out] Output array pointer

  • out_size – [in] Output array size

  • in – [in] Input array pointer

  • in_size – [in] Input array size

  • c – [in] Coefficient array pointer

  • c_size – [in] Coefficient array size

Returns:

0 on success, non-zero otherwise

int gn_quantize16(int16_t *out, size_t out_size, const double *in, size_t in_size, double fsr, int n, double noise, GnCodeFormat format)

Quantize floating-point samples to 16-bit integer codes.

Parameters:
  • out – [out] Output array pointer

  • out_size – [in] Output array size

  • in – [in] Input array pointer

  • in_size – [in] Input array size

  • fsr – [in] Full-scale range

  • n – [in] Resolution

  • noise – [in] Input referred RMS noise

  • format – [in] Code format

Returns:

0 on success, non-zero otherwise

int gn_quantize32(int32_t *out, size_t out_size, const double *in, size_t in_size, double fsr, int n, double noise, GnCodeFormat format)

Quantize floating-point samples to 32-bit integer codes.

Parameters:
  • out – [out] Output array pointer

  • out_size – [in] Output array size

  • in – [in] Input array pointer

  • in_size – [in] Input array size

  • fsr – [in] Full-scale range

  • n – [in] Resolution

  • noise – [in] Input referred RMS noise

  • format – [in] Code format

Returns:

0 on success, non-zero otherwise

int gn_quantize64(int64_t *out, size_t out_size, const double *in, size_t in_size, double fsr, int n, double noise, GnCodeFormat format)

Quantize floating-point samples to 64-bit integer codes.

Parameters:
  • out – [out] Output array pointer

  • out_size – [in] Output array size

  • in – [in] Input array pointer

  • in_size – [in] Input array size

  • fsr – [in] Full-scale range

  • n – [in] Resolution

  • noise – [in] Input referred RMS noise

  • format – [in] Code format

Returns:

0 on success, non-zero otherwise

Signal Processing Helpers

group Helpers

Functions

int gn_downsample_size(size_t *out_size, size_t in_size, int ratio, bool interleaved)

Get the output array size for downsample functions.

Parameters:
  • out_size – [out] Output array size

  • in_size – [in] Input array size

  • ratio – [in] Downsample ratio

  • interleaved – [in] If bool, ‘in’ is interleaved I/Q data

Returns:

0 on success, non-zero otherwise

int gn_fshift_size(size_t *out_size, size_t i_size, size_t q_size)

Get the output array size for frequency shift functions.

Parameters:
  • out_size – [out] Output array size

  • i_size – [in] In-phase input array size

  • q_size – [in] Quadrature input array size

Returns:

0 on success, non-zero otherwise

Waveforms

group Waveforms

Functions

int gn_cos(double *out, size_t size, double fs, double ampl, double freq, double phase, double td, double tj)

Generate a cosine waveform with optional aperture jitter.

Parameters:
  • out – [out] Array pointer

  • size – [in] Array size

  • fs – [in] Sample rate (S/s)

  • ampl – [in] Amplitude

  • freq – [in] Frequency (Hz)

  • phase – [in] Phase (rad)

  • td – [in] Time delay (s)

  • tj – [in] RMS Aperture jitter (s)

Returns:

0 on success, non-zero otherwise

int gn_gaussian(double *out, size_t size, double mean, double sd)

Generate Gaussian (normally distributed) random samples.

Parameters:
  • out – [out] Array pointer

  • size – [in] Array size

  • mean – [in] Mean

  • sd – [in] Standard deviation

Returns:

0 on success, non-zero otherwise

int gn_ramp(double *out, size_t size, double start, double stop, double noise)

Generate a linear ramp waveform with optional noise.

Parameters:
  • out – [out] Array pointer

  • size – [in] Array size

  • start – [in] Start value

  • stop – [in] Stop value

  • noise – [in] RMS noise

Returns:

0 on success, non-zero otherwise

int gn_sin(double *out, size_t size, double fs, double ampl, double freq, double phase, double td, double tjrms)

Generate a sine waveform with optional aperture jitter.

Parameters:
  • out – [out] Array pointer

  • size – [in] Array size

  • fs – [in] Sample rate (S/s)

  • ampl – [in] Amplitude

  • freq – [in] Frequency (Hz)

  • phase – [in] Phase (rad)

  • td – [in] Time delay (s)

  • tjrms – [in] RMS Aperture jitter (s)

Returns:

0 on success, non-zero otherwise

int gn_wf_analysis(char **rkeys, size_t rkeys_size, double *rvalues, size_t rvalues_size, const double *in, size_t in_size)

Compute time-domain waveform statistics from normalized (double) data.

The results contain the following key-value pairs (see general description of Analysis Routines).

Key

Description

min

Minumum value

max

Maximum value

mid

Middle value ((max + min) / 2)

range

Range (max - min)

avg

Average value

rms

RMS value

rmsac

RMS value with DC removed

min_index

Index of first occurence of minimum value

max_index

Index of first occurence of maximum value

Parameters:
  • rkeys – [out] Result keys array pointer

  • rkeys_size – [in] Result keys array size

  • rvalues – [out] Result values array pointer

  • rvalues_size – [in] Result values array size

  • in – [in] Waveform array pointer

  • in_size – [in] Waveform array size

Returns:

0 on success, non-zero otherwise

int gn_wf_analysis16(char **rkeys, size_t rkeys_size, double *rvalues, size_t rvalues_size, const int16_t *in, size_t in_size)

Compute time-domain waveform statistics from 16-bit data.

See description of gn_wf_analysis.

Parameters:
  • rkeys – [out] Result keys array pointer

  • rkeys_size – [in] Result keys array size

  • rvalues – [out] Result values array pointer

  • rvalues_size – [in] Result values array size

  • in – [in] Waveform array pointer

  • in_size – [in] Waveform array size

Returns:

0 on success, non-zero otherwise

int gn_wf_analysis32(char **rkeys, size_t rkeys_size, double *rvalues, size_t rvalues_size, const int32_t *in, size_t in_size)

Compute time-domain waveform statistics from 32-bit data.

See description of gn_wf_analysis.

Parameters:
  • rkeys – [out] Result keys array pointer

  • rkeys_size – [in] Result keys array size

  • rvalues – [out] Result values array pointer

  • rvalues_size – [in] Result values array size

  • in – [in] Waveform array pointer

  • in_size – [in] Waveform array size

Returns:

0 on success, non-zero otherwise

int gn_wf_analysis64(char **rkeys, size_t rkeys_size, double *rvalues, size_t rvalues_size, const int64_t *in, size_t in_size)

Compute time-domain waveform statistics from 64-bit data.

See description of gn_wf_analysis.

Parameters:
  • rkeys – [out] Result keys array pointer

  • rkeys_size – [in] Result keys array size

  • rvalues – [out] Result values array pointer

  • rvalues_size – [in] Result values array size

  • in – [in] Waveform array pointer

  • in_size – [in] Waveform array size

Returns:

0 on success, non-zero otherwise