Immersitech Logo Developer Resources
API Basics

Immersitech ClearVoice is a C/C++ library enabling advanced speech processing utilities. It operates on 10ms buffers of single-channel, floating-point audio data (values from -1 to 1), and has configurable input/output sample rate options. Usage requires a license file. (A trial license is included in your distribution of the library. If it has expired or is unavailable for any reason, please contact us and we will be happy to assist.) This page will outline the steps needed to process audio through ClearVoice.

Step-by-step setup in C

To begin using ClearVoice functions in your project, first include the appropriate header file.

#include immersitech_clearvoice.h

Next, create an imm_cv_config structure. The easiest way is to just use the default configuration, and edit any values relevent to your project. Here, we'll just set ANC Mix to 90%.

config.anc_mix = 90;
IMMERSITECH_API imm_cv_config imm_cv_get_default_config()
Return a default configuration object for initialization.
A structure containing all necessary configuration options to initialize ClearVoice.
Definition: immersitech_clearvoice.h:58
int anc_mix
Definition: immersitech_clearvoice.h:64

We can now use this configuration structure to initialize ClearVoice, and return a handle to our initialized library. We also require the path to a valid license file, and a pointer to an imm_error_code to return any errors.

const char* license_file = "./Immersitech_Engineering_sound_manager_license_key.dat";
imm_error_code error_code;
imm_cv_handle handle = imm_cv_init_from_file(license_file, config, &error_code);
if (error_code != IMM_ERROR_NONE) {
printf("An error occured!\n");
}
IMMERSITECH_API imm_cv_handle imm_cv_init_from_file(const char *license_file_path, imm_cv_config config, imm_error_code *error_code)
Initialize an instance of the Immersitech ClearVoice Library.
void * imm_cv_handle
Definition: immersitech_clearvoice.h:80
imm_error_code
All error codes that may be produced by the library.
Definition: immersitech_general.h:26
@ IMM_ERROR_NONE
This error code indicates the function worked successfully without error.
Definition: immersitech_general.h:28

With an initialized handle, all of the other functions are now available. For example, we can now change ANC Mix back to 100% using the imm_cv_set_config function.

error_code = imm_cv_set_config(handle, IMM_CV_MUT_CONF_ANC_MIX, 100);
if (error_code != IMM_ERROR_NONE) {
printf("An error occured!\n");
}
@ IMM_CV_MUT_CONF_ANC_MIX
The wet/dry mix [0-100] of the AI Noise Cancellation. 0 is only noisy audio, 100 is only noise cancel...
Definition: immersitech_clearvoice.h:39
IMMERSITECH_API imm_error_code imm_cv_set_config(imm_cv_handle handle, imm_cv_mutable_config config, int val)
Set a configuration value.

As you can see above, many configuration settings from the structure used to initialize the library are mutable after initialization, and can even be changed in the audio thread. The full list of mutable configuration settings are in the enum imm_cv_mutable_config.

Most importantly, we can now process audio data.

float* input_audio[480] = {0.0f};
float* output_audio[480] = {0.0f};
error_code = imm_cv_process(handle, input_audio, output_audio, &metadata);
IMMERSITECH_API imm_error_code imm_cv_process(imm_cv_handle handle, float *input, float *output, imm_cv_output_metadata *output_metadata)
Process audio through the Immersitech ClearVoice Library.
A structure to return all extra data from the process function.
Definition: immersitech_clearvoice.h:75

All together, a simple ClearVoice test executable would look like this:

#include <stdio.h>
int main() {
config.anc_mix = 90;
const char* license_file = "./Immersitech_Engineering_sound_manager_license_key.dat";
imm_error_code error_code;
imm_cv_handle handle = imm_cv_init_from_file(license_file, config, &error_code);
if (error_code != IMM_ERROR_NONE) {
printf("An error occured!\n");
}
error_code = imm_cv_set_config(handle, IMM_CV_MUT_CONF_ANC_MIX, 100);
if (error_code != IMM_ERROR_NONE) {
printf("An error occured!\n");
}
float input_audio[480] = {0.0f};
float output_audio[480] = {0.0f};
error_code = imm_cv_process(handle, input_audio, output_audio, &metadata);
imm_cv_destroy(handle);
return 0;
}
IMMERSITECH_API imm_error_code imm_cv_destroy(imm_cv_handle handle)
Destroy an instance of the Immersitech ClearVoice Library.