Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Audio Toolkit snippets
// You need to setup memory, how the parameter is updated
// you need to setup max_interval_process, the number of samples before the next update
class ProcessingClass
{
double parameter_target;
double parameter_current;
int64_t interval_process;
public:
ProcessingClass()
:parameter_target(0), parameter_current(0), interval_process(0)
{}
void update()
{
parameter_current = parameter_current * (1 - memory) + parameter_target * memory;
interval_process = 0;
}
void process(double** in, double** out, int64_t size)
{
// Setup the input/outputs of the pipeline as usual
int64_t processed_size = 0;
do
{
// We can only process max_interval_process elements at a time, but if we already have some elements in the buffer,
// we need to take them into account.
int64_t size_to_process = std::min(max_interval_process - interval_process, size - processed_size);
pipeline_exit.process(size_to_process);
interval_process += size_to_process;
processed_size += size_to_process;
if(interval_process == max_interval_process)
{
update();
interval_process = 0;
}
}while(processed_size != size);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.