some work

This commit is contained in:
Minecon724 2024-11-13 16:45:20 +01:00
parent 445763f4fc
commit 969f31569e
Signed by: Minecon724
GPG key ID: 3CCC4D267742C8E8

View file

@ -16,6 +16,64 @@ http://lsp-plug.in/plugins/lv2/para_equalizer_x32_lr
http://calf.sourceforge.net/plugins/BassEnhancer
*/
LilvInstance *instance_two(LilvWorld *world, double sample_rate, float *input_left, float *input_right, float *output_left, float *output_right) {
const LilvPlugin* plugin = easy_load_plugin(world, "http://calf.sourceforge.net/plugins/BassEnhancer");
if (plugin == NULL) {
fprintf(stderr, "Plugin not found: BassEnhancer (from calf.sourceforge.net)\n");
return NULL;
}
LilvInstance *instance = lilv_plugin_instantiate(plugin, sample_rate, NULL);
if (instance == NULL) {
fprintf(stderr, "Failed to initialize instance two\n");
return NULL;
}
lilv_instance_connect_port(instance, 0, input_left); // Input L
lilv_instance_connect_port(instance, 1, input_right); // Input R
lilv_instance_connect_port(instance, 2, output_left); // Output L
lilv_instance_connect_port(instance, 3, output_right); // Output R
lilv_instance_activate(instance);
return instance;
}
LilvInstance *instance_three(LilvWorld *world, double sample_rate, float *input_left, float *input_right, float *output_left, float *output_right) {
const LilvPlugin* plugin = easy_load_plugin(world, "http://lsp-plug.in/plugins/lv2/comp_delay_x2_stereo");
if (plugin == NULL) {
fprintf(stderr, "Plugin not found: comp_delay_x2_stereo (from lsp-plug.in)\n");
return NULL;
}
float *knob_enabled = malloc(sizeof(float));
*knob_enabled = 1.0f;
float *knob_mode = malloc(sizeof(float));
*knob_mode = 2.0f;
float *knob_time = malloc(sizeof(float));
*knob_time = 100.0f; // ms
LilvInstance *instance = lilv_plugin_instantiate(plugin, sample_rate, NULL);
if (instance == NULL) {
fprintf(stderr, "Failed to initialize instance three\n");
return NULL;
}
lilv_instance_connect_port(instance, 4, knob_enabled);
lilv_instance_connect_port(instance, 16, knob_mode);
lilv_instance_connect_port(instance, 22, knob_time);
lilv_instance_connect_port(instance, 0, input_left); // Input L
lilv_instance_connect_port(instance, 1, input_right); // Input R
lilv_instance_connect_port(instance, 2, output_left); // Output L
lilv_instance_connect_port(instance, 3, output_right); // Output R
lilv_instance_activate(instance);
return instance;
}
int main(int argc, char *argv[]) {
if (argc < 2) {
printf("Usage: %s <input> [output]\n", argv[0]);
@ -58,48 +116,18 @@ int main(int argc, char *argv[]) {
float output_left[BUFFER_SIZE];
float output_right[BUFFER_SIZE];
const int instancesCount = 10;
const int instancesCount = 2;
LilvInstance **instances = malloc(instancesCount * sizeof(LilvInstance*));
if (instances == NULL) {
fprintf(stderr, "mallocing instances failed: %s\n", strerror(errno));
return 1;
}
const LilvPlugin* plugin = easy_load_plugin(world, "http://lsp-plug.in/plugins/lv2/comp_delay_x2_stereo");
if (plugin == NULL) {
fprintf(stderr, "Plugin not found: comp_delay_x2_stereo (from lsp-plug.in)\n");
return 1;
}
//
float *knob_enabled = malloc(instancesCount * sizeof(float));
for (int i=0; i<instancesCount; i++) knob_enabled[i] = 1.0f;
float *knob_mode = malloc(instancesCount * sizeof(float));
for (int i=0; i<instancesCount; i++) knob_mode[i] = 2.0f;
float *knob_time = malloc(instancesCount * sizeof(float));
for (int i=0; i<instancesCount; i++) knob_time[i] = 100.0f; // ms
for (int i=0; i<instancesCount; i++) {
LilvInstance *instance = lilv_plugin_instantiate(plugin, sfinfo.samplerate, NULL);
if (instance == NULL) {
fprintf(stderr, "Instance %d initialization failed\n", i);
return 1;
}
lilv_instance_connect_port(instance, 4, knob_enabled);
lilv_instance_connect_port(instance, 16, knob_mode);
lilv_instance_connect_port(instance, 22, knob_time);
lilv_instance_connect_port(instance, 0, input_left); // Input L
lilv_instance_connect_port(instance, 1, input_right); // Input R
lilv_instance_connect_port(instance, 2, output_left); // Output L
lilv_instance_connect_port(instance, 3, output_right); // Output R
lilv_instance_activate(instance);
instances[i] = instance;
}
instances[0] = instance_two(world, sfinfo.samplerate, input_left, input_right, output_left, output_right);
instances[1] = instance_three(world, sfinfo.samplerate, input_left, input_right, output_left, output_right);
// start processing
@ -118,7 +146,6 @@ int main(int argc, char *argv[]) {
for (int i=0; i<instancesCount; i++) {
lilv_instance_run(instances[i], frames_read);
// TODO maybe I don't have to
if (i + 1 != instancesCount) {
memcpy(input_left, output_left, frames_read * sizeof(float));
memcpy(input_right, output_right, frames_read * sizeof(float));