Skip to content

C API


KFR_DFT_PACK_FORMAT enum

enum KFR_DFT_PACK_FORMAT

Enumeration for DFT packing format. See https://www.kfr.dev/docs/latest/dft_format/ for details


typedef enum KFR_DFT_PACK_FORMAT

Enumeration for DFT packing format. See https://www.kfr.dev/docs/latest/dft_format/ for details


enum KFR_DFT_PACK_FORMAT

Enumeration for DFT packing format. See https://www.kfr.dev/docs/latest/dft_format/ for details


enum (unnamed at /src/include/kfr/capi.h:76:1) enum

enum

Supported architectures enumeration


kfr_add_ref function

void *kfr_add_ref(void *ptr)

Adds a reference to the allocated memory.


kfr_allocate function

void *kfr_allocate(size_t size)

Allocates memory of specified size.


kfr_allocate_aligned function

void *kfr_allocate_aligned(size_t size, size_t alignment)

Allocates aligned memory of specified size and alignment.


kfr_allocated_size function

size_t kfr_allocated_size(void *ptr)

Returns allocated memory size.


kfr_current_arch function

int kfr_current_arch()

Returns the current architecture in use.


kfr_dct_create_plan_f32 function

KFR_DCT_PLAN_F32 *kfr_dct_create_plan_f32(size_t size)

Create a DCT-II plan (Single precision).
Param size Size of the DCT. Must be even.
Returns Pointer to the created DCT plan.


kfr_dct_create_plan_f64 function

KFR_DCT_PLAN_F64 *kfr_dct_create_plan_f64(size_t size)

Create a DCT-II plan (Double precision).
Param size Size of the DCT. Must be even.
Returns Pointer to the created DCT plan.


kfr_dct_delete_plan_f32 function

void kfr_dct_delete_plan_f32(KFR_DCT_PLAN_F32 *plan)

Delete a DCT plan.
Param plan Pointer to the DCT plan. May be NULL.


kfr_dct_delete_plan_f64 function

void kfr_dct_delete_plan_f64(KFR_DCT_PLAN_F64 *plan)

Delete a DCT plan.
Param plan Pointer to the DCT plan. May be NULL.


kfr_dct_dump_f32 function

void kfr_dct_dump_f32(KFR_DCT_PLAN_F32 *plan)

Dump details of the DCT plan to stdout for inspection.
Param plan Pointer to the DCT plan.


kfr_dct_dump_f64 function

void kfr_dct_dump_f64(KFR_DCT_PLAN_F64 *plan)

Dump details of the DCT plan to stdout for inspection.
Param plan Pointer to the DCT plan.


kfr_dct_execute_f32 function

void kfr_dct_execute_f32(KFR_DCT_PLAN_F32 *plan,
                         kfr_f32 *out, const kfr_f32 *in,
                         uint8_t *temp)

Execute DCT-II on in and write the result to out.
Param plan Pointer to the DCT plan.
Param out Pointer to output data.
Param in Pointer to input data.
Param temp Temporary (scratch) buffer. If NULL, scratch buffer of size kfr_dct_get_temp_size_f**(plan) will be allocated on stack or heap.
Note No scaling is applied. This function read \(N\) values from in and writes \(N\) values to out, where \(N\) is the size passed to kfr_dct_create_plan_f**..


kfr_dct_execute_f64 function

void kfr_dct_execute_f64(KFR_DCT_PLAN_F64 *plan,
                         kfr_f64 *out, const kfr_f64 *in,
                         uint8_t *temp)

Execute DCT-II on in and write the result to out.
Param plan Pointer to the DCT plan.
Param out Pointer to output data.
Param in Pointer to input data.
Param temp Temporary (scratch) buffer. If NULL, scratch buffer of size kfr_dct_get_temp_size_f**(plan) will be allocated on stack or heap.
Note No scaling is applied. This function read \(N\) values from in and writes \(N\) values to out, where \(N\) is the size passed to kfr_dct_create_plan_f**..


kfr_dct_execute_inverse_f32 function

void kfr_dct_execute_inverse_f32(KFR_DCT_PLAN_F32 *plan,
                                 kfr_f32 *out,
                                 const kfr_f32 *in,
                                 uint8_t *temp)

Execute inverse DCT-II (aka DCT-III) on in and write the result to out.
Param plan Pointer to the DCT plan.
Param out Pointer to output data.
Param in Pointer to input data.
Param temp Temporary (scratch) buffer. If NULL, scratch buffer of size kfr_dct_get_temp_size_f**(plan) will be allocated on stack or heap.
Note No scaling is applied. This function read \(N\) values from in and writes \(N\) values to out, where \(N\) is the size passed to kfr_dct_create_plan_f**..


kfr_dct_execute_inverse_f64 function

void kfr_dct_execute_inverse_f64(KFR_DCT_PLAN_F64 *plan,
                                 kfr_f64 *out,
                                 const kfr_f64 *in,
                                 uint8_t *temp)

Execute inverse DCT-II (aka DCT-III) on in and write the result to out.
Param plan Pointer to the DCT plan.
Param out Pointer to output data.
Param in Pointer to input data.
Param temp Temporary (scratch) buffer. If NULL, scratch buffer of size kfr_dct_get_temp_size_f**(plan) will be allocated on stack or heap.
Note No scaling is applied. This function read \(N\) values from in and writes \(N\) values to out, where \(N\) is the size passed to kfr_dct_create_plan_f**..


kfr_dct_get_size_f32 function

size_t kfr_dct_get_size_f32(KFR_DCT_PLAN_F32 *plan)

Get the size of a DCT plan.
Param plan Pointer to the DCT plan.
Returns Size of the DCT as passed to kfr_dct_create_plan_f**.


kfr_dct_get_size_f64 function

size_t kfr_dct_get_size_f64(KFR_DCT_PLAN_F64 *plan)

Get the size of a DCT plan.
Param plan Pointer to the DCT plan.
Returns Size of the DCT as passed to kfr_dct_create_plan_f**.


kfr_dct_get_temp_size_f32 function

size_t kfr_dct_get_temp_size_f32(KFR_DCT_PLAN_F32 *plan)

Get temporary (scratch) buffer size for DCT plan.
Param plan Pointer to the DCT plan.
Returns Temporary buffer size in bytes.
Note Preallocating a byte buffer of the returned size and passing its pointer to the kfr_dct_execute_f** and kfr_dct_execute_inverse_f** functions may improve performance.


kfr_dct_get_temp_size_f64 function

size_t kfr_dct_get_temp_size_f64(KFR_DCT_PLAN_F64 *plan)

Get temporary (scratch) buffer size for DCT plan.
Param plan Pointer to the DCT plan.
Returns Temporary buffer size in bytes.
Note Preallocating a byte buffer of the returned size and passing its pointer to the kfr_dct_execute_f** and kfr_dct_execute_inverse_f** functions may improve performance.


kfr_deallocate function

void kfr_deallocate(void *ptr)

Deallocates memory.


kfr_dft_create_plan_f32 function

KFR_DFT_PLAN_F32 *kfr_dft_create_plan_f32(size_t size)

Create a complex DFT plan (Single precision).
Param size Size of the DFT.
Returns Pointer to the created DFT plan. Use kfr_dft_delete_plan_f** to free.


kfr_dft_create_plan_f64 function

KFR_DFT_PLAN_F64 *kfr_dft_create_plan_f64(size_t size)

Create a complex DFT plan (Double precision).
Param size Size of the DFT.
Returns Pointer to the created DFT plan. Use kfr_dft_delete_plan_f** to free.


kfr_dft_delete_plan_f32 function

void kfr_dft_delete_plan_f32(KFR_DFT_PLAN_F32 *plan)

Delete a complex DFT plan.
Param plan Pointer to the DFT plan. May be NULL.


kfr_dft_delete_plan_f64 function

void kfr_dft_delete_plan_f64(KFR_DFT_PLAN_F64 *plan)

Delete a complex DFT plan.
Param plan Pointer to the DFT plan. May be NULL.


kfr_dft_dump_f32 function

void kfr_dft_dump_f32(KFR_DFT_PLAN_F32 *plan)

Dump details of the DFT plan to stdout for inspection.
Param plan Pointer to the DFT plan.


kfr_dft_dump_f64 function

void kfr_dft_dump_f64(KFR_DFT_PLAN_F64 *plan)

Dump details of the DFT plan to stdout for inspection.
Param plan Pointer to the DFT plan.


kfr_dft_execute_f32 function

void kfr_dft_execute_f32(KFR_DFT_PLAN_F32 *plan,
                         kfr_c32 *out, const kfr_c32 *in,
                         uint8_t *temp)

Execute the complex forward DFT on in and write the result to out.
Param plan Pointer to the DFT plan.
Param out Pointer to the output data.
Param in Pointer to the input data.
Param temp Temporary (scratch) buffer. If NULL, scratch buffer of size kfr_dft_get_temp_size_f**(plan) will be allocated on stack or heap.
Note No scaling is applied. This function reads \(N\) complex values from in and writes \(N\) complex values to out, where \(N\) is the size passed to kfr_dft_create_plan_f**.


kfr_dft_execute_f64 function

void kfr_dft_execute_f64(KFR_DFT_PLAN_F64 *plan,
                         kfr_c64 *out, const kfr_c64 *in,
                         uint8_t *temp)

Execute the complex forward DFT on in and write the result to out.
Param plan Pointer to the DFT plan.
Param out Pointer to the output data (frequency domain). May point to the same memory as in for in-place execution.
Param in Pointer to the input data (time domain).
Param temp Temporary (scratch) buffer. If NULL, scratch buffer of size kfr_dft_get_temp_size_f**(plan) will be allocated on stack or heap.
Note No scaling is applied. This function reads \(N\) complex values from in and writes \(N\) complex values to out, where \(N\) is the size passed to kfr_dft_create_plan_f**.


kfr_dft_execute_inverse_f32 function

void kfr_dft_execute_inverse_f32(KFR_DFT_PLAN_F32 *plan,
                                 kfr_c32 *out,
                                 const kfr_c32 *in,
                                 uint8_t *temp)

Execute the inverse complex DFT on in and write the result to out for in-place execution.
Param plan Pointer to the DFT plan.
Param out Pointer to output data (time domain). May point to the same memory as in for in-place execution.
Param in Pointer to input data (frequency domain).
Param temp Temporary (scratch) buffer. If NULL, scratch buffer of size kfr_dft_get_temp_size_f**(plan) will be allocated on stack or heap.
Note No scaling is applied. This function reads \(N\) complex values from in and writes \(N\) complex values to out, where \(N\) is the size passed to kfr_dft_create_plan_f**.


kfr_dft_execute_inverse_f64 function

void kfr_dft_execute_inverse_f64(KFR_DFT_PLAN_F64 *plan,
                                 kfr_c64 *out,
                                 const kfr_c64 *in,
                                 uint8_t *temp)

Execute the inverse complex DFT on in and write the result to out.
Param plan Pointer to the DFT plan.
Param out Pointer to output data (time domain).
Param in Pointer to input data (frequency domain).
Param temp Temporary (scratch) buffer. If NULL, scratch buffer of size kfr_dft_get_temp_size_f**(plan) will be allocated on stack or heap.
Note No scaling is applied. This function reads \(N\) complex values from in and writes \(N\) complex values to out, where \(N\) is the size passed to kfr_dft_create_plan_f**.


kfr_dft_get_size_f32 function

size_t kfr_dft_get_size_f32(KFR_DFT_PLAN_F32 *plan)

Get the size of the DFT plan, in complex numbers.
Param plan Pointer to the DFT plan.
Returns Size of the DFT plan as passed to kfr_dft_create_plan_f**.


kfr_dft_get_size_f64 function

size_t kfr_dft_get_size_f64(KFR_DFT_PLAN_F64 *plan)

Get the size of the DFT plan, in complex numbers.
Param plan Pointer to the DFT plan.
Returns Size of the DFT plan as passed to kfr_dft_create_plan_f**.


kfr_dft_get_temp_size_f32 function

size_t kfr_dft_get_temp_size_f32(KFR_DFT_PLAN_F32 *plan)

Get temporary (scratch) buffer size for DFT plan.
Param plan Pointer to the DFT plan.
Returns Temporary buffer size in bytes.
Note Preallocating a byte buffer of the returned size and passing its pointer to the kfr_dft_execute_f** and kfr_dft_execute_inverse_f** functions may improve performance.


kfr_dft_get_temp_size_f64 function

size_t kfr_dft_get_temp_size_f64(KFR_DFT_PLAN_F64 *plan)

Get temporary (scratch) buffer size for DFT plan.
Param plan Pointer to the DFT plan.
Returns Temporary buffer size in bytes.
Note Preallocating a byte buffer of the returned size and passing its pointer to the kfr_dft_execute_f** and kfr_dft_execute_inverse_f** functions may improve performance.


kfr_dft_real_create_plan_f32 function

KFR_DFT_REAL_PLAN_F32 *kfr_dft_real_create_plan_f32(
    size_t size, KFR_DFT_PACK_FORMAT pack_format)

Create a real DFT plan (Single precision).
Param size Size of the real DFT. Must be even.
Param pack_format Packing format for the DFT.
Returns Pointer to the created DFT plan. Use kfr_dft_real_delete_plan_f** to free.


kfr_dft_real_create_plan_f64 function

KFR_DFT_REAL_PLAN_F64 *kfr_dft_real_create_plan_f64(
    size_t size, KFR_DFT_PACK_FORMAT pack_format)

Create a real DFT plan (Double precision).
Param size Size of the real DFT. Must be even.
Param pack_format Packing format for the DFT.
Returns Pointer to the created DFT plan. Use kfr_dft_real_delete_plan_f** to free.


kfr_dft_real_delete_plan_f32 function

void kfr_dft_real_delete_plan_f32(
    KFR_DFT_REAL_PLAN_F32 *plan)

Delete a real DFT plan.
Param plan Pointer to the DFT plan. May be NULL.


kfr_dft_real_delete_plan_f64 function

void kfr_dft_real_delete_plan_f64(
    KFR_DFT_REAL_PLAN_F64 *plan)

Delete a real DFT plan.
Param plan Pointer to the DFT plan. May be NULL.


kfr_dft_real_dump_f32 function

void kfr_dft_real_dump_f32(KFR_DFT_REAL_PLAN_F32 *plan)

Dump details of the real DFT plan to stdout for inspection.
Param plan Pointer to the DFT plan.


kfr_dft_real_dump_f64 function

void kfr_dft_real_dump_f64(KFR_DFT_REAL_PLAN_F64 *plan)

Dump details of the real DFT plan to stdout for inspection.
Param plan Pointer to the DFT plan.


kfr_dft_real_execute_f32 function

void kfr_dft_real_execute_f32(KFR_DFT_REAL_PLAN_F32 *plan,
                              kfr_c32 *out,
                              const kfr_f32 *in,
                              uint8_t *temp)

Execute real DFT on in and write the result to out
Param plan Pointer to the DFT plan.
Param out Pointer to output data. May point to the same memory as in for in-place execution.
Param in Pointer to input data.
Param temp Temporary (scratch) buffer. If NULL, scratch buffer of size kfr_dft_real_get_temp_size_f**(plan) will be allocated on stack or heap.
Note This function reads \(N\) real values from in and writes \(\frac{N}{2}\) (Perm format) or \(\frac{N}{2}+1\) (CCs format) complex values to out, where \(N\) is the size passed to kfr_dft_real_create_plan_f**.


kfr_dft_real_execute_f64 function

void kfr_dft_real_execute_f64(KFR_DFT_REAL_PLAN_F64 *plan,
                              kfr_c64 *out,
                              const kfr_f64 *in,
                              uint8_t *temp)

Execute real DFT on in and write the result to out.
Param plan Pointer to the DFT plan.
Param out Pointer to output data. May point to the same memory as in for in-place execution.
Param in Pointer to input data.
Param temp Temporary (scratch) buffer. If NULL, scratch buffer of size kfr_dft_real_get_temp_size_f**(plan) will be allocated on stack or heap.
Note This function reads \(N\) real values from in and writes \(\frac{N}{2}\) (Perm format) or \(\frac{N}{2}+1\) (CCs format) complex values to out, where \(N\) is the size passed to kfr_dft_real_create_plan_f**.


kfr_dft_real_execute_inverse_f32 function

void kfr_dft_real_execute_inverse_f32(
    KFR_DFT_REAL_PLAN_F32 *plan, kfr_f32 *out,
    const kfr_c32 *in, uint8_t *temp)

Execute inverse real DFT on in and write the result to out.
Param plan Pointer to the DFT plan.
Param out Pointer to output data. May point to the same memory as in for in-place execution.
Param in Pointer to input data.
Param temp Temporary (scratch) buffer. If NULL, scratch buffer of size kfr_dft_real_get_temp_size_f**(plan) will be allocated on stack or heap.
Note This function reads \(\frac{N}{2}\) (Perm format) or \(\frac{N}{2}+1\) (CCs format) complex values from in and writes \(N\) real values to out, where \(N\) is the size passed to kfr_dft_real_create_plan_f**.


kfr_dft_real_execute_inverse_f64 function

void kfr_dft_real_execute_inverse_f64(
    KFR_DFT_REAL_PLAN_F64 *plan, kfr_f64 *out,
    const kfr_c64 *in, uint8_t *temp)

Execute inverse real DFT on in and write the result to out.
Param plan Pointer to the DFT plan.
Param out Pointer to output data. May point to the same memory as in for in-place execution.
Param in Pointer to input data.
Param temp Temporary (scratch) buffer. If NULL, scratch buffer of size kfr_dft_real_get_temp_size_f**(plan) will be allocated on stack or heap.
Note This function reads \(\frac{N}{2}\) (Perm format) or \(\frac{N}{2}+1\) (CCs format) complex values from in and writes \(N\) real values to out, where \(N\) is the size passed to kfr_dft_real_create_plan_f**.


kfr_dft_real_get_size_f32 function

size_t
kfr_dft_real_get_size_f32(KFR_DFT_REAL_PLAN_F32 *plan)

Get the size of a real DFT plan.
Param plan Pointer to the DFT plan.
Returns Size of the DFT as passed to kfr_dft_real_create_plan_f**.


kfr_dft_real_get_size_f64 function

size_t
kfr_dft_real_get_size_f64(KFR_DFT_REAL_PLAN_F64 *plan)

Get the size of a real DFT plan.
Param plan Pointer to the DFT plan.
Returns Size of the DFT as passed to kfr_dft_real_create_plan_f**.


kfr_dft_real_get_temp_size_f32 function

size_t
kfr_dft_real_get_temp_size_f32(KFR_DFT_REAL_PLAN_F32 *plan)

Get temporary (scratch) buffer size for real DFT plan (Single precision).
Param plan Pointer to the DFT plan.
Returns Temporary buffer size in bytes.
Note Preallocating a byte buffer of the returned size and passing its pointer to the kfr_dft_execute_f** and kfr_dft_execute_inverse_f** functions may improve performance.


kfr_dft_real_get_temp_size_f64 function

size_t
kfr_dft_real_get_temp_size_f64(KFR_DFT_REAL_PLAN_F64 *plan)

Get temporary (scratch) buffer size for real DFT plan (Double precision).
Param plan Pointer to the DFT plan.
Returns Temporary buffer size in bytes.
Note Preallocating a byte buffer of the returned size and passing its pointer to the kfr_dft_execute_f** and kfr_dft_execute_inverse_f** functions may improve performance.


kfr_enabled_archs function

const char *kfr_enabled_archs()

Returns the list of enabled architectures as a string.


kfr_f32 typedef

typedef float kfr_f32

Typedefs for single and double precision floating points


kfr_filter_create_convolution_plan_f32 function

KFR_FILTER_F32 *kfr_filter_create_convolution_plan_f32(
    const kfr_f32 *taps, size_t size, size_t block_size)

Create a convolution filter plan (Single precision).
Param taps Pointer to filter taps.
Param size Number of filter taps.
Param block_size Size of the processing block. Must be a power of two.
Returns Pointer to the created convolution filter plan. Use kfr_filter_delete_plan_f** to free.
Note Mathematically, this produces the same result as an FIR filter, but it uses the FFT overlap-add technique internally to improve performance with larger filter lengths.


kfr_filter_create_convolution_plan_f64 function

KFR_FILTER_F64 *kfr_filter_create_convolution_plan_f64(
    const kfr_f64 *taps, size_t size, size_t block_size)

Create a convolution filter plan (Double precision).
Param taps Pointer to filter taps.
Param size Number of filter taps.
Param block_size Size of the processing block. Must be a power of two.
Returns Pointer to the created convolution filter plan. Use kfr_filter_delete_plan_f** to free.
Note Mathematically, this produces the same result as an FIR filter, but it uses the FFT overlap-add technique internally to improve performance with larger filter lengths.


kfr_filter_create_fir_plan_f32 function

KFR_FILTER_F32 *
kfr_filter_create_fir_plan_f32(const kfr_f32 *taps,
                               size_t size)

Create a FIR filter plan (Single precision).
Param taps Pointer to filter taps.
Param size Number of filter taps.
Returns Pointer to the created FIR filter plan. Use kfr_filter_delete_plan_f** to free.


kfr_filter_create_fir_plan_f64 function

KFR_FILTER_F64 *
kfr_filter_create_fir_plan_f64(const kfr_f64 *taps,
                               size_t size)

Create a FIR filter plan (Double precision).
Param taps Pointer to filter taps.
Param size Number of filter taps.
Returns Pointer to the created FIR filter plan. Use kfr_filter_delete_plan_f** to free.


kfr_filter_create_iir_plan_f32 function

KFR_FILTER_F32 *
kfr_filter_create_iir_plan_f32(const kfr_f32 *sos,
                               size_t sos_count)

Create a IIR filter plan (Single precision).
Param sos Pointer to second-order sections (SOS) coefficients.
Param sos_count Number of second-order sections.
Returns Pointer to the created IIR filter plan. Use kfr_filter_delete_plan_f** to free.


kfr_filter_create_iir_plan_f64 function

KFR_FILTER_F64 *
kfr_filter_create_iir_plan_f64(const kfr_f64 *sos,
                               size_t sos_count)

Create a IIR filter plan (Double precision).
Param sos Pointer to second-order sections (SOS) coefficients.
Param sos_count Number of second-order sections.
Returns Pointer to the created IIR filter plan. Use kfr_filter_delete_plan_f** to free.


kfr_filter_delete_plan_f32 function

void kfr_filter_delete_plan_f32(KFR_FILTER_F32 *plan)

Delete a filter plan.
Param plan Pointer to the filter plan. May be NULL.


kfr_filter_delete_plan_f64 function

void kfr_filter_delete_plan_f64(KFR_FILTER_F64 *plan)

Delete a filter plan.
Param plan Pointer to the filter plan. May be NULL.


kfr_filter_process_f32 function

void kfr_filter_process_f32(KFR_FILTER_F32 *plan,
                            kfr_f32 *output,
                            const kfr_f32 *input,
                            size_t size)

Process input data with a filter.
Param plan Pointer to the filter plan.
Param output Pointer to output data. May point to the same memory as input for in-place execution.
Param input Pointer to input data.
Param size Number of samples to process.


kfr_filter_process_f64 function

void kfr_filter_process_f64(KFR_FILTER_F64 *plan,
                            kfr_f64 *output,
                            const kfr_f64 *input,
                            size_t size)

Process input data with a filter.
Param plan Pointer to the filter plan.
Param output Pointer to output data. May point to the same memory as input for in-place execution.
Param input Pointer to input data.
Param size Number of samples to process.


kfr_filter_reset_f32 function

void kfr_filter_reset_f32(KFR_FILTER_F32 *plan)

Reset the internal state of a filter plan, including delay line.
Param plan Pointer to the filter plan.


kfr_filter_reset_f64 function

void kfr_filter_reset_f64(KFR_FILTER_F64 *plan)

Reset the internal state of a filter plan, including delay line.
Param plan Pointer to the filter plan.


kfr_last_error function

const char *kfr_last_error()

Returns the last error message.


kfr_reallocate function

void *kfr_reallocate(void *ptr, size_t new_size)

Reallocates memory to new size.


kfr_reallocate_aligned function

void *kfr_reallocate_aligned(void *ptr, size_t new_size,
                             size_t alignment)

Reallocates aligned memory to new size and alignment.


kfr_release function

void kfr_release(void *ptr)

Releases a reference to the allocated memory.


kfr_version function

uint32_t kfr_version()

Returns the library version as an integer.


kfr_version_string function

const char *kfr_version_string()

Returns the library version as a string.


Auto-generated from sources, Revision 5191a48df06ea47104ca67db19fa82058d09c20a, https://github.com/kfrlib/kfr/blob/5191a48df06ea47104ca67db19fa82058d09c20a/include/kfr/