yes
This commit is contained in:
parent
9a77ac6e26
commit
445763f4fc
3 changed files with 63 additions and 26 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,3 +2,4 @@ build/
|
||||||
.vscode/
|
.vscode/
|
||||||
|
|
||||||
*.flac
|
*.flac
|
||||||
|
*.html
|
|
@ -26,6 +26,13 @@ const LilvPlugin* easy_load_plugin(LilvWorld* world, const char* uri) {
|
||||||
lilv_node_free(defNode);
|
lilv_node_free(defNode);
|
||||||
|
|
||||||
printf("Port %d: %s = %f\n", i, name, defaultValue);
|
printf("Port %d: %s = %f\n", i, name, defaultValue);
|
||||||
|
|
||||||
|
LilvNodes *classes = lilv_port_get_classes(plugin, port);
|
||||||
|
LILV_FOREACH(nodes, i, classes) {
|
||||||
|
LilvNode *n = lilv_nodes_get(classes, i);
|
||||||
|
printf(" %s\n", lilv_node_as_uri(n));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
79
src/main.c
79
src/main.c
|
@ -3,11 +3,12 @@
|
||||||
#include <sndfile.h>
|
#include <sndfile.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
#include "easy.h"
|
#include "easy.h"
|
||||||
#include "audiofile.h"
|
#include "audiofile.h"
|
||||||
|
|
||||||
#define BUFFER_SIZE 256 // this is per channel
|
#define BUFFER_SIZE 8192 // this is per channel
|
||||||
|
|
||||||
/*
|
/*
|
||||||
http://lsp-plug.in/plugins/lv2/comp_delay_x2_stereo
|
http://lsp-plug.in/plugins/lv2/comp_delay_x2_stereo
|
||||||
|
@ -25,7 +26,7 @@ int main(int argc, char *argv[]) {
|
||||||
char *output_filename;
|
char *output_filename;
|
||||||
|
|
||||||
if (argc < 3) {
|
if (argc < 3) {
|
||||||
output_filename = malloc((strlen(input_filename) + 4) * sizeof(char));
|
output_filename = malloc((strlen(input_filename) + 5) * sizeof(char));
|
||||||
strcpy(output_filename, "out-");
|
strcpy(output_filename, "out-");
|
||||||
strcat(output_filename, input_filename);
|
strcat(output_filename, input_filename);
|
||||||
} else {
|
} else {
|
||||||
|
@ -50,7 +51,19 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
audiofile_copy_metadata(in_sndfile, out_sndfile);
|
audiofile_copy_metadata(in_sndfile, out_sndfile);
|
||||||
|
|
||||||
// load lilv plugin
|
// prepare lilv instance
|
||||||
|
|
||||||
|
float input_left[BUFFER_SIZE];
|
||||||
|
float input_right[BUFFER_SIZE];
|
||||||
|
float output_left[BUFFER_SIZE];
|
||||||
|
float output_right[BUFFER_SIZE];
|
||||||
|
|
||||||
|
const int instancesCount = 10;
|
||||||
|
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");
|
const LilvPlugin* plugin = easy_load_plugin(world, "http://lsp-plug.in/plugins/lv2/comp_delay_x2_stereo");
|
||||||
if (plugin == NULL) {
|
if (plugin == NULL) {
|
||||||
|
@ -58,34 +71,38 @@ int main(int argc, char *argv[]) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// prepare lilv instance
|
float *knob_enabled = malloc(instancesCount * sizeof(float));
|
||||||
|
for (int i=0; i<instancesCount; i++) knob_enabled[i] = 1.0f;
|
||||||
|
|
||||||
LilvInstance *instance = lilv_plugin_instantiate(plugin, sfinfo.samplerate, NULL);
|
float *knob_mode = malloc(instancesCount * sizeof(float));
|
||||||
|
for (int i=0; i<instancesCount; i++) knob_mode[i] = 2.0f;
|
||||||
|
|
||||||
float knob_enabled = 1;
|
float *knob_time = malloc(instancesCount * sizeof(float));
|
||||||
lilv_instance_connect_port(instance, 4, &knob_enabled);
|
for (int i=0; i<instancesCount; i++) knob_time[i] = 100.0f; // ms
|
||||||
|
|
||||||
float knob_mode = 2;
|
for (int i=0; i<instancesCount; i++) {
|
||||||
lilv_instance_connect_port(instance, 16, &knob_mode);
|
LilvInstance *instance = lilv_plugin_instantiate(plugin, sfinfo.samplerate, NULL);
|
||||||
|
if (instance == NULL) {
|
||||||
|
fprintf(stderr, "Instance %d initialization failed\n", i);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
float knob_time = 50.0f; // ms
|
lilv_instance_connect_port(instance, 4, knob_enabled);
|
||||||
lilv_instance_connect_port(instance, 22, &knob_time);
|
lilv_instance_connect_port(instance, 16, knob_mode);
|
||||||
|
|
||||||
//
|
lilv_instance_connect_port(instance, 22, knob_time);
|
||||||
|
|
||||||
float input_left[BUFFER_SIZE];
|
lilv_instance_connect_port(instance, 0, input_left); // Input L
|
||||||
float input_right[BUFFER_SIZE];
|
lilv_instance_connect_port(instance, 1, input_right); // Input R
|
||||||
float output_left[BUFFER_SIZE];
|
lilv_instance_connect_port(instance, 2, output_left); // Output L
|
||||||
float output_right[BUFFER_SIZE];
|
lilv_instance_connect_port(instance, 3, output_right); // Output R
|
||||||
|
|
||||||
lilv_instance_connect_port(instance, 0, input_left); // Input L
|
lilv_instance_activate(instance);
|
||||||
lilv_instance_connect_port(instance, 1, input_right); // Input R
|
instances[i] = instance;
|
||||||
lilv_instance_connect_port(instance, 2, output_left); // Output L
|
}
|
||||||
lilv_instance_connect_port(instance, 3, output_right); // Output R
|
|
||||||
|
|
||||||
// start processing
|
// start processing
|
||||||
|
|
||||||
lilv_instance_activate(instance);
|
|
||||||
printf("Now processing\n");
|
printf("Now processing\n");
|
||||||
clock_t start = clock();
|
clock_t start = clock();
|
||||||
|
|
||||||
|
@ -99,7 +116,15 @@ int main(int argc, char *argv[]) {
|
||||||
input_right[i] = input_buffer[i * 2 + 1];
|
input_right[i] = input_buffer[i * 2 + 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
lilv_instance_run(instance, frames_read);
|
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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
for (sf_count_t i = 0; i < frames_read; i++) {
|
for (sf_count_t i = 0; i < frames_read; i++) {
|
||||||
output_buffer[i * 2] = output_left[i];
|
output_buffer[i * 2] = output_left[i];
|
||||||
|
@ -110,12 +135,16 @@ int main(int argc, char *argv[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
clock_t end = clock();
|
clock_t end = clock();
|
||||||
printf("Done processing. Took %ldns\n", (long)((double)(end - start) / CLOCKS_PER_SEC * 1000000));
|
printf("Done processing. Took %ldms\n", (clock_t)((double)(end - start) / CLOCKS_PER_SEC * 1000));
|
||||||
|
|
||||||
// end processing
|
// end processing
|
||||||
|
|
||||||
lilv_instance_deactivate(instance);
|
for (int i=0; i<instancesCount; i++) {
|
||||||
lilv_instance_free(instance);
|
LilvInstance *instance = instances[i];
|
||||||
|
lilv_instance_deactivate(instance);
|
||||||
|
lilv_instance_free(instance);
|
||||||
|
}
|
||||||
|
free(instances);
|
||||||
|
|
||||||
lilv_world_free(world);
|
lilv_world_free(world);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue