aboutsummaryrefslogtreecommitdiffstats
path: root/src/jalv.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2013-05-09 20:18:07 +0000
committerDavid Robillard <d@drobilla.net>2013-05-09 20:18:07 +0000
commit582d60337783ddf9fc1e50267a12fe50c5d6f7bc (patch)
tree9220eac880bb97207a23d86a63fe6f76746c6bb0 /src/jalv.c
parentabb8cfaf30475f25659d89605cb24fb0d5aee68d (diff)
downloadjalv-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
Diffstat (limited to 'src/jalv.c')
-rw-r--r--src/jalv.c34
1 files changed, 19 insertions, 15 deletions
diff --git a/src/jalv.c b/src/jalv.c
index 0e77239..6f8d07c 100644
--- a/src/jalv.c
+++ b/src/jalv.c
@@ -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);