some work
This commit is contained in:
parent
445763f4fc
commit
969f31569e
1 changed files with 63 additions and 36 deletions
99
src/main.c
99
src/main.c
|
@ -16,6 +16,64 @@ http://lsp-plug.in/plugins/lv2/para_equalizer_x32_lr
|
||||||
http://calf.sourceforge.net/plugins/BassEnhancer
|
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[]) {
|
int main(int argc, char *argv[]) {
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
printf("Usage: %s <input> [output]\n", argv[0]);
|
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_left[BUFFER_SIZE];
|
||||||
float output_right[BUFFER_SIZE];
|
float output_right[BUFFER_SIZE];
|
||||||
|
|
||||||
const int instancesCount = 10;
|
const int instancesCount = 2;
|
||||||
LilvInstance **instances = malloc(instancesCount * sizeof(LilvInstance*));
|
LilvInstance **instances = malloc(instancesCount * sizeof(LilvInstance*));
|
||||||
if (instances == NULL) {
|
if (instances == NULL) {
|
||||||
fprintf(stderr, "mallocing instances failed: %s\n", strerror(errno));
|
fprintf(stderr, "mallocing instances failed: %s\n", strerror(errno));
|
||||||
return 1;
|
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;
|
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);
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
// start processing
|
// start processing
|
||||||
|
|
||||||
|
@ -118,7 +146,6 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
for (int i=0; i<instancesCount; i++) {
|
for (int i=0; i<instancesCount; i++) {
|
||||||
lilv_instance_run(instances[i], frames_read);
|
lilv_instance_run(instances[i], frames_read);
|
||||||
// TODO maybe I don't have to
|
|
||||||
if (i + 1 != instancesCount) {
|
if (i + 1 != instancesCount) {
|
||||||
memcpy(input_left, output_left, frames_read * sizeof(float));
|
memcpy(input_left, output_left, frames_read * sizeof(float));
|
||||||
memcpy(input_right, output_right, frames_read * sizeof(float));
|
memcpy(input_right, output_right, frames_read * sizeof(float));
|
||||||
|
|
Loading…
Reference in a new issue