From 4fc4ebe425d032f4c251e72b89334409de204de6 Mon Sep 17 00:00:00 2001 From: yo mama Date: Tue, 27 Jan 2015 08:48:45 -0800 Subject: needs to detect output buffers, only works with synthv1 --- src/LV2-render.c | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) (limited to 'src/LV2-render.c') diff --git a/src/LV2-render.c b/src/LV2-render.c index d1be763..b13f50d 100644 --- a/src/LV2-render.c +++ b/src/LV2-render.c @@ -71,14 +71,14 @@ really ought to be enough for anybody(TM). */ #define N_BUFFER_CYCLES 16 +#define SAMPLE_RATE 48000 + #include #include #include "midi/midi_loader.h" #include "midi/fluidsynth_priv.h" -#define SAMPLE_RATE 48000 // here -//so min is here, how come it doesn't see it? not sure, try remove inline int min(int x, int y) { return (x < y) ? x : y; } @@ -171,18 +171,30 @@ int process_midi_cb(fluid_midi_event_t *event, size_t msecs, process_midi_ctx_t } - lilv_instance_run(jalv->instance, nframes); +//TODO +// /* Interleaving for libsndfile. */ + int nchannels = 2; + float sf_output[nchannels * nframes]; //nframes is n times longer now + for (int i = 0; i < nframes; i++) { + /* First, write all the obvious channels */ + /* If outs > nchannels, we *could* do mixing - but don't. */ + //actually you need another for loop in here for 10 channel wavs + sf_output[i * nchannels + 0] = pluginOutputBuffers[3][i]; + sf_output[i * nchannels + 1] = pluginOutputBuffers[4][i]; + /* Then, if user wants *more* output channels than there are + * audio output ports (ie outs < nchannels), copy the last audio + * out to all the remaining channels. If outs >= nchannels, this + * loop is never entered. */ + } - write_audio_to_file(ctx->outfile, pluginOutputBuffers[3], nframes); //TODO ADD LATER -// printf("total ports: %d\n", jalv->num_ports); + write_audio_to_file(ctx->outfile, sf_output, nframes); for(int i=0; inum_ports; i++){ if(pluginOutputBuffers[i]){ - //printf("buffer: %x content:", i); - //print_audio_to_terminal(pluginOutputBuffers[i], nframes); free(pluginOutputBuffers[i]); } } +//something like this