aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/eg-metro.lv2
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2013-01-28 01:33:10 +0000
committerDavid Robillard <d@drobilla.net>2013-01-28 01:33:10 +0000
commitda9b240ce1392f7b1d9d51d4938898868d8d1d83 (patch)
tree74fd96057a2ca59ffe4ce0e9261306caa047cdfb /plugins/eg-metro.lv2
parent21d16ed2e53601f8a26f378b3274a207a9426b12 (diff)
downloadlv2-da9b240ce1392f7b1d9d51d4938898868d8d1d83.tar.xz
Update metronome example to produce sensible book output.
Diffstat (limited to 'plugins/eg-metro.lv2')
-rw-r--r--plugins/eg-metro.lv2/README.txt8
-rw-r--r--plugins/eg-metro.lv2/manifest.ttl.in1
-rw-r--r--plugins/eg-metro.lv2/metro.c33
-rw-r--r--plugins/eg-metro.lv2/metro.ttl17
4 files changed, 36 insertions, 23 deletions
diff --git a/plugins/eg-metro.lv2/README.txt b/plugins/eg-metro.lv2/README.txt
index 52a650e..5e9a84a 100644
--- a/plugins/eg-metro.lv2/README.txt
+++ b/plugins/eg-metro.lv2/README.txt
@@ -1 +1,9 @@
== Metronome ==
+
+This plugin demonstrates tempo synchronisation by clicking on every beat. The
+host sends this information to the plugin as events, so an event with new time
+and tempo information will be received whenever there is a change.
+
+Time is assumed to continue rolling at the tempo and speed defined by the last
+received tempo event, even across cycles, until a new tempo event is received
+or the plugin is deactivated.
diff --git a/plugins/eg-metro.lv2/manifest.ttl.in b/plugins/eg-metro.lv2/manifest.ttl.in
index f81794f..bd93f66 100644
--- a/plugins/eg-metro.lv2/manifest.ttl.in
+++ b/plugins/eg-metro.lv2/manifest.ttl.in
@@ -1,6 +1,5 @@
@prefix lv2: <http://lv2plug.in/ns/lv2core#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
-@prefix ui: <http://lv2plug.in/ns/extensions/ui#> .
<http://lv2plug.in/plugins/eg-metro>
a lv2:Plugin ;
diff --git a/plugins/eg-metro.lv2/metro.c b/plugins/eg-metro.lv2/metro.c
index d36ac15..97821a1 100644
--- a/plugins/eg-metro.lv2/metro.c
+++ b/plugins/eg-metro.lv2/metro.c
@@ -76,16 +76,35 @@ typedef struct {
float* output;
} ports;
+ /** The rate, bpm, and speed are the basic information sent by the host. */
double rate;
float bpm;
float speed;
- uint32_t elapsed_len; /**< Frames since last click start */
- uint32_t wave_offset; /**< Current play offset in wave */
- float* wave; /**< One cycle of a sine wave */
- uint32_t wave_len; /**< Length of wave in frames */
- uint32_t attack_len; /**< Attack duration in frames */
- uint32_t decay_len; /**< Decay duration in frames */
- State state; /**< Play state */
+
+ /** To keep track of when to play the next click, we need to keep track of
+ a few pieces of information: */
+
+ /** - The frames since the start of the last click is stored */
+ uint32_t elapsed_len;
+
+ /** - The current play offset in the wave */
+ uint32_t wave_offset;
+
+ /** - The current play state (attack, decay, or off) */
+ State state;
+
+ /** The wave to play is a simple sine wave generated at instantiation time
+ based on the sample rate. The length in frames is stored in order to
+ continuously play the wave in a cycle to avoid discontinuity clicks. */
+ float* wave;
+ uint32_t wave_len;
+
+ /** The continuously playing sine wave is enveloped to provide an actual
+ metronome tick. This plugin uses a simple AD envelope with fixed
+ parameters. A more sophisticated implementation might use a more
+ advanced envelope and allow the user to modify these parameters. */
+ uint32_t attack_len;
+ uint32_t decay_len;
} Metro;
static void
diff --git a/plugins/eg-metro.lv2/metro.ttl b/plugins/eg-metro.lv2/metro.ttl
index 53a3d01..a6f297f 100644
--- a/plugins/eg-metro.lv2/metro.ttl
+++ b/plugins/eg-metro.lv2/metro.ttl
@@ -1,18 +1,3 @@
-# LV2 Metronome Example Plugin
-# Copyright 2012 David Robillard <d@drobilla.net>
-#
-# Permission to use, copy, modify, and/or distribute this software for any
-# purpose with or without fee is hereby granted, provided that the above
-# copyright notice and this permission notice appear in all copies.
-#
-# THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
@prefix atom: <http://lv2plug.in/ns/ext/atom#> .
@prefix doap: <http://usefulinc.com/ns/doap#> .
@prefix lv2: <http://lv2plug.in/ns/lv2core#> .
@@ -30,6 +15,8 @@
a lv2:InputPort ,
atom:AtomPort ;
atom:bufferType atom:Sequence ;
+# Since this port supports time:Position, the host knows to deliver time and
+# tempo information
atom:supports time:Position ;
lv2:index 0 ;
lv2:symbol "control" ;