diff options
author | David Robillard <d@drobilla.net> | 2013-05-09 20:18:07 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2013-05-09 20:18:07 +0000 |
commit | 582d60337783ddf9fc1e50267a12fe50c5d6f7bc (patch) | |
tree | 9220eac880bb97207a23d86a63fe6f76746c6bb0 | |
parent | abb8cfaf30475f25659d89605cb24fb0d5aee68d (diff) | |
download | jalv-582d60337783ddf9fc1e50267a12fe50c5d6f7bc.tar.gz jalv-582d60337783ddf9fc1e50267a12fe50c5d6f7bc.tar.bz2 jalv-582d60337783ddf9fc1e50267a12fe50c5d6f7bc.zip |
Communicate UI update rate to plugin and UI.
git-svn-id: http://svn.drobilla.net/lad/trunk/jalv@5107 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r-- | src/jalv.c | 34 | ||||
-rw-r--r-- | src/jalv_gtk.c | 2 | ||||
-rw-r--r-- | src/jalv_internal.h | 5 | ||||
-rw-r--r-- | wscript | 2 |
4 files changed, 24 insertions, 19 deletions
@@ -833,6 +833,7 @@ main(int argc, char** argv) jalv.urids.time_beatsPerMinute = symap_map(jalv.symap, LV2_TIME__beatsPerMinute); jalv.urids.time_frame = symap_map(jalv.symap, LV2_TIME__frame); jalv.urids.time_speed = symap_map(jalv.symap, LV2_TIME__speed); + jalv.urids.ui_updateRate = symap_map(jalv.symap, LV2_UI__updateRate); #ifdef _WIN32 jalv.temp_dir = jalv_strdup("jalvXXXXXX"); @@ -1026,6 +1027,22 @@ main(int argc, char** argv) jalv.opts.buffer_size = jalv.midi_buf_size * 4; } + if (jalv.opts.update_rate == 0.0) { + /* Calculate a reasonable UI update frequency. */ + jalv.ui_update_hz = (float)jalv.sample_rate / jalv.midi_buf_size * 2.0f; + jalv.ui_update_hz = MAX(25.0f, jalv.ui_update_hz); + } else { + /* Use user-specified UI update rate. */ + jalv.ui_update_hz = jalv.opts.update_rate; + jalv.ui_update_hz = MAX(1.0f, jalv.ui_update_hz); + } + + /* The UI can only go so fast, clamp to reasonable limits */ + jalv.ui_update_hz = MIN(60, jalv.ui_update_hz); + jalv.opts.buffer_size = MAX(4096, jalv.opts.buffer_size); + fprintf(stderr, "Comm buffers: %d bytes\n", jalv.opts.buffer_size); + fprintf(stderr, "Update rate: %.01f Hz\n", jalv.ui_update_hz); + /* Build options array to pass to plugin */ const LV2_Options_Option options[] = { { LV2_OPTIONS_INSTANCE, 0, jalv.urids.param_sampleRate, @@ -1036,26 +1053,13 @@ main(int argc, char** argv) sizeof(int32_t), jalv.urids.atom_Int, &jalv.block_length }, { LV2_OPTIONS_INSTANCE, 0, jalv.urids.bufsz_sequenceSize, sizeof(int32_t), jalv.urids.atom_Int, &jalv.midi_buf_size }, + { LV2_OPTIONS_INSTANCE, 0, jalv.urids.ui_updateRate, + sizeof(float), jalv.urids.atom_Float, &jalv.ui_update_hz }, { LV2_OPTIONS_INSTANCE, 0, 0, 0, 0, NULL } }; options_feature.data = &options; - if (!jalv.opts.update_rate) { - /* Calculate theoretical UI update frequency. */ - jalv.ui_update_hz = (double)jalv.sample_rate / jalv.midi_buf_size * 2.0; - jalv.ui_update_hz = MAX(25, jalv.ui_update_hz); - } else { - jalv.ui_update_hz = jalv.opts.update_rate; - jalv.ui_update_hz = MAX(1, jalv.ui_update_hz); - } - - /* The UI can only go so fast, clamp to reasonable limits */ - jalv.ui_update_hz = MIN(60, jalv.ui_update_hz); - jalv.opts.buffer_size = MAX(4096, jalv.opts.buffer_size); - fprintf(stderr, "Comm buffers: %d bytes\n", jalv.opts.buffer_size); - fprintf(stderr, "Update rate: %d Hz\n", jalv.ui_update_hz); - /* Create Plugin <=> UI communication buffers */ jalv.ui_events = jack_ringbuffer_create(jalv.opts.buffer_size); jalv.plugin_events = jack_ringbuffer_create(jalv.opts.buffer_size); diff --git a/src/jalv_gtk.c b/src/jalv_gtk.c index e371a6c..45d1080 100644 --- a/src/jalv_gtk.c +++ b/src/jalv_gtk.c @@ -91,7 +91,7 @@ jalv_init(int* argc, char*** argv, JalvOptions* opts) "Use Jalv generic UI and not the plugin UI", NULL}, { "buffer-size", 'b', 0, G_OPTION_ARG_INT, &opts->buffer_size, "Buffer size for plugin <=> UI communication", "SIZE"}, - { "update-frequency", 'r', 0, G_OPTION_ARG_INT, &opts->update_rate, + { "update-frequency", 'r', 0, G_OPTION_ARG_DOUBLE, &opts->update_rate, "UI update frequency", NULL}, { 0, 0, 0, 0, 0, 0, 0 } }; GError* error = NULL; diff --git a/src/jalv_internal.h b/src/jalv_internal.h index 2fccbc5..1eb6899 100644 --- a/src/jalv_internal.h +++ b/src/jalv_internal.h @@ -86,7 +86,7 @@ typedef struct { char* uuid; char* load; uint32_t buffer_size; - uint32_t update_rate; + double update_rate; bool dump; bool generic_ui; } JalvOptions; @@ -112,6 +112,7 @@ typedef struct { LV2_URID time_beatsPerMinute; LV2_URID time_frame; LV2_URID time_speed; + LV2_URID ui_updateRate; } JalvURIDs; typedef struct { @@ -186,7 +187,7 @@ typedef struct { uint32_t control_in; ///< Index of control input port uint32_t num_ports; ///< Size of the two following arrays: uint32_t longest_sym; ///< Longest port symbol - uint32_t ui_update_hz; ///< Frequency of UI updates + float ui_update_hz; ///< Frequency of UI updates jack_nframes_t sample_rate; ///< Sample rate jack_nframes_t event_delta_t; ///< Frames since last update sent to UI uint32_t midi_event_id; ///< MIDI event class ID in event context @@ -30,7 +30,7 @@ def configure(conf): autowaf.set_c99_mode(conf) autowaf.display_header('Jalv Configuration') - autowaf.check_pkg(conf, 'lv2', atleast_version='1.3.0', uselib_store='LV2') + autowaf.check_pkg(conf, 'lv2', atleast_version='1.4.3', uselib_store='LV2') autowaf.check_pkg(conf, 'lilv-0', uselib_store='LILV', atleast_version='0.15.1', mandatory=True) autowaf.check_pkg(conf, 'serd-0', uselib_store='SERD', |