summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/LV2-render.c36
-rw-r--r--src/LV2-render_console.c21
-rw-r--r--src/LV2-render_internal.h3
3 files changed, 47 insertions, 13 deletions
diff --git a/src/LV2-render.c b/src/LV2-render.c
index 8065bcb..7e2d7b5 100644
--- a/src/LV2-render.c
+++ b/src/LV2-render.c
@@ -71,7 +71,6 @@
really ought to be enough for anybody(TM).
*/
#define N_BUFFER_CYCLES 16
-#define SAMPLE_RATE 48000
#include <alsa/asoundlib.h>
@@ -79,6 +78,7 @@
#include "midi/midi_loader.h"
#include "midi/fluidsynth_priv.h"
+
int min(int x, int y) {
return (x < y) ? x : y;
}
@@ -175,7 +175,7 @@ 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;
+ int nchannels = ctx->jalv->opts.nchannels;
if (nchannels > pluginAudioOutputCount){
fprintf(stderr, "ERROR: Requesting more audio outputs than available from plugin.\n");
exit(1);
@@ -527,15 +527,26 @@ main(int argc, char** argv)
jalv.play_state = JALV_PAUSED;
jalv.bpm = 120.0f;
+
if (jalv_init(&argc, &argv, &jalv.opts)) {
return EXIT_FAILURE;
}
- if (jalv.opts.uuid) {
- printf("UUID: %s\n", jalv.opts.uuid);
- }
+ if (! jalv.opts.nchannels){
+ jalv.opts.nchannels = 2;
+ }
+
+ if (! strlen(&jalv.opts.outfile)){
+ //FIXME
+ printf("here it is: %d\n", strlen(&jalv.opts.outfile));
+ exit(1);
+ }
- jalv.symap = symap_new();
+ if (! jalv.opts.sample_rate){
+ jalv.opts.sample_rate = 48000;
+ }
+
+ jalv.symap = symap_new();
zix_sem_init(&jalv.symap_lock, 1);
uri_map.callback_data = &jalv;
@@ -700,7 +711,7 @@ main(int argc, char** argv)
lilv_node_free(name);
- jalv.sample_rate = SAMPLE_RATE;
+ jalv.sample_rate = jalv.opts.sample_rate;
jalv.block_length = 256; //TODO used to be 256 try 1024 4096
jalv.midi_buf_size = 32768; //used to be 256
@@ -775,15 +786,14 @@ main(int argc, char** argv)
//FIXME get sample rate from above...right? yes
- jalv.sample_rate = SAMPLE_RATE;
+ jalv.sample_rate = jalv.opts.sample_rate;
jalv.play_state = JALV_RUNNING;
// open_wav_file here
- char *output_file = "output.wav";
- size_t length = SAMPLE_RATE; //gets changed when file is closed
- float sample_rate = SAMPLE_RATE;
- int nchannels = 2;
- SNDFILE *outfile = open_wav_file(output_file, sample_rate, nchannels, length);
+ char *output_file = jalv.opts.outfile;
+ size_t length = (size_t)jalv.opts.sample_rate; //gets changed when file is closed
+ float sample_rate = (float)jalv.opts.sample_rate;
+ SNDFILE *outfile = open_wav_file(output_file, sample_rate, jalv.opts.nchannels, length);
process_midi_ctx_t process_midi_ctx;
process_midi_ctx.jalv = &jalv;
process_midi_ctx.outfile = outfile;
diff --git a/src/LV2-render_console.c b/src/LV2-render_console.c
index 1d421d2..def8eb4 100644
--- a/src/LV2-render_console.c
+++ b/src/LV2-render_console.c
@@ -19,6 +19,9 @@ print_usage(const char* name, bool error)
fprintf(os, " -h Display this help and exit\n");
fprintf(os, " -p Print control output changes to stdout\n");
fprintf(os, " -c SYM=VAL Set control value (e.g. \"vol=1.4\")\n");
+ fprintf(os, " -F STRING filename for wavfile output (DEFAULT=output.wav)\n");
+ fprintf(os, " -C NUM Integer number of channels for output, e.g. 2 (DEFAULT=2)\n");
+ fprintf(os, " -S NUM Integer sample rate of output, e.g. 44100 (DEFAULT=48000)\n");
fprintf(os, " -l DIR Load state from save directory\n");
fprintf(os, " -d DIR Dump plugin <=> UI communication\n");
fprintf(os, " -b SIZE Buffer size for plugin <=> UI communication\n");
@@ -61,6 +64,24 @@ jalv_init(int* argc, char*** argv, JalvOptions* opts)
(++n_controls + 1) * sizeof(char*));
opts->controls[n_controls - 1] = (*argv)[a];
opts->controls[n_controls] = NULL;
+ } else if ((*argv)[a][1] == 'C') {
+ if (++a == *argc) {
+ fprintf(stderr, "Missing argument for -C\n");
+ return 1;
+ }
+ opts->nchannels = atoi((*argv)[a]);
+ } else if ((*argv)[a][1] == 'S') {
+ if (++a == *argc) {
+ fprintf(stderr, "Missing argument for -S\n");
+ return 1;
+ }
+ opts->sample_rate = atoi((*argv)[a]);
+ } else if ((*argv)[a][1] == 'F') {
+ if (++a == *argc) {
+ fprintf(stderr, "Missing argument for -F\n");
+ return 1;
+ }
+ opts->outfile = (*argv)[a];
} else if ((*argv)[a][1] == 'd') {
opts->dump = true;
} else {
diff --git a/src/LV2-render_internal.h b/src/LV2-render_internal.h
index cac20b0..6b1cd51 100644
--- a/src/LV2-render_internal.h
+++ b/src/LV2-render_internal.h
@@ -80,6 +80,9 @@ typedef struct {
int no_menu; ///< Hide menu iff true
int show_ui; ///< Show non-embedded UI
int print_controls; ///< Print control changes to stdout
+ int nchannels; ///
+ int sample_rate; ///
+ char* outfile; ///
} JalvOptions;
typedef struct {