lib-ai 1_0_704
lib-ai automated documentation
|
Main entry point class to handle AI audio processing. More...
#include <AudioModel.h>
Public Member Functions | |
AudioModel (std::string const &activation="tanh", unsigned int sampleRate=44100) | |
Constructor for AudioModel. | |
~AudioModel () | |
Destructor for AudioModel. | |
AudioModel (const AudioModel &)=delete | |
AudioModel & | operator= (const AudioModel &)=delete |
bool | prepare (std::string const &modelName) |
Loads and prepares the model for processing. | |
void | setNewParam (std::string const ¶m) |
Adds a new parameter to the model. | |
bool | setLicense (std::string const &license) |
Adds license. | |
void | setParamValueAt (size_t param, double value) |
Sets the value of a parameter by index. | |
void | setParamValueAt (size_t param, float value) |
Sets the value of a parameter by index. | |
void | setParamValueAt (std::string const ¶m, double value) |
Sets the value of a parameter by name. | |
void | setParamValueAt (std::string const ¶m, float value) |
Sets the value of a parameter by name. | |
bool | process (const float *input, float *output) |
Processes audio through the model. | |
bool | loadJsonEQParameters (std::string const &inJsonConfigPathName, int samplingRate) |
Loads EQ parameters from a JSON configuration file. | |
size_t | getFrameLength () const |
Gets the frame length required for processing. | |
size_t | getNumberOfFilters () const |
Gets the number of filters in the model. | |
size_t | getDenseLocalSize () const |
Gets the dense local size of the model. | |
size_t | getMaxPoolingPoolSize () const |
Gets the max pooling pool size. | |
size_t | getNumberOfParams () const |
Gets the number of parameters supported by the model. | |
void | setLogger (WS::Logger *logger) |
Sets a logger for the model. | |
float * | getValidationValues (const std::string &bufferName, size_t &filterCnt, size_t &sampleCnt) |
Gets validation values for a specific buffer. | |
Private Member Functions | |
float | oneminus (float x) |
float | softplus (float x) |
float * | getBreakPoints (size_t numBreakPoints) |
Private Attributes | |
Impl * | pImpl |
WS::Logger * | mLogger {nullptr} |
Friends | |
class | ::AudioModelUT |
Main entry point class to handle AI audio processing.
The AudioModel class provides the primary interface for loading and using AI models for audio processing. It supports various activation functions, parameter setting, and model processing capabilities.
WS::AudioModel::AudioModel | ( | std::string const & | activation = "tanh" , |
unsigned int | sampleRate = 44100 |
||
) |
Constructor for AudioModel.
activation | The activation function to use (default: "tanh") |
Creates a new AudioModel instance with the specified activation function. Unless otherwise stated, most of the WS AI models use "tanh"
WS::AudioModel::~AudioModel | ( | ) |
Destructor for AudioModel.
|
delete |
|
private |
size_t WS::AudioModel::getDenseLocalSize | ( | ) | const |
Gets the dense local size of the model.
size_t WS::AudioModel::getFrameLength | ( | ) | const |
Gets the frame length required for processing.
size_t WS::AudioModel::getMaxPoolingPoolSize | ( | ) | const |
Gets the max pooling pool size.
size_t WS::AudioModel::getNumberOfFilters | ( | ) | const |
Gets the number of filters in the model.
size_t WS::AudioModel::getNumberOfParams | ( | ) | const |
Gets the number of parameters supported by the model.
float * WS::AudioModel::getValidationValues | ( | const std::string & | bufferName, |
size_t & | filterCnt, | ||
size_t & | sampleCnt | ||
) |
Gets validation values for a specific buffer.
bufferName | Name of the buffer |
filterCnt | Output parameter to receive filter count |
sampleCnt | Output parameter to receive sample count |
bool WS::AudioModel::loadJsonEQParameters | ( | std::string const & | inJsonConfigPathName, |
int | samplingRate | ||
) |
Loads EQ parameters from a JSON configuration file.
inJsonConfigPathName | Path to the JSON configuration file |
samplingRate | Sample rate of the audio to be processed |
If EQ effects are to be applied, a JSON formatted config file for the parameters needs to be loaded prior to calling process().
|
private |
|
delete |
bool WS::AudioModel::prepare | ( | std::string const & | modelName | ) |
Loads and prepares the model for processing.
modelName | Path to the model directory |
Prepare needs to be called once to allocate the proper layers before calling process() multiple times for processing audio frames.
bool WS::AudioModel::process | ( | const float * | input, |
float * | output | ||
) |
Processes audio through the model.
input | Pointer to input buffer of audio samples (size must match getFrameLength()) |
output | Pointer to output buffer where processed audio will be stored |
bool WS::AudioModel::setLicense | ( | std::string const & | license | ) |
Adds license.
license | License to use |
This is just a placeholder for a license checker We need a way to manage the license
void WS::AudioModel::setLogger | ( | WS::Logger * | logger | ) |
Sets a logger for the model.
logger | Pointer to a Logger instance |
void WS::AudioModel::setNewParam | ( | std::string const & | param | ) |
Adds a new parameter to the model.
param | Name of the parameter |
Parameters will be added in order and indexed according to their order:
void WS::AudioModel::setParamValueAt | ( | size_t | param, |
double | value | ||
) |
Sets the value of a parameter by index.
param | Index of the parameter |
value | Double value to set (0.0 to 1.0 recommended) |
void WS::AudioModel::setParamValueAt | ( | size_t | param, |
float | value | ||
) |
Sets the value of a parameter by index.
param | Index of the parameter |
value | Float value to set (0.0 to 1.0 recommended) |
void WS::AudioModel::setParamValueAt | ( | std::string const & | param, |
double | value | ||
) |
Sets the value of a parameter by name.
param | Name of the parameter |
value | Double value to set (0.0 to 1.0 recommended) |
void WS::AudioModel::setParamValueAt | ( | std::string const & | param, |
float | value | ||
) |
Sets the value of a parameter by name.
param | Name of the parameter |
value | Float value to set (0.0 to 1.0 recommended) |
|
private |
|
friend |
|
private |
|
private |