aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/eg-metro.lv2/metro.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/eg-metro.lv2/metro.c')
-rw-r--r--plugins/eg-metro.lv2/metro.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/plugins/eg-metro.lv2/metro.c b/plugins/eg-metro.lv2/metro.c
index f3fe164..e60a33f 100644
--- a/plugins/eg-metro.lv2/metro.c
+++ b/plugins/eg-metro.lv2/metro.c
@@ -1,14 +1,14 @@
// Copyright 2012-2016 David Robillard <d@drobilla.net>
// SPDX-License-Identifier: ISC
-#include "lv2/atom/atom.h"
-#include "lv2/atom/util.h"
-#include "lv2/core/lv2.h"
-#include "lv2/core/lv2_util.h"
-#include "lv2/log/log.h"
-#include "lv2/log/logger.h"
-#include "lv2/time/time.h"
-#include "lv2/urid/urid.h"
+#include <lv2/atom/atom.h>
+#include <lv2/atom/util.h>
+#include <lv2/core/lv2.h>
+#include <lv2/core/lv2_util.h>
+#include <lv2/log/log.h>
+#include <lv2/log/logger.h>
+#include <lv2/time/time.h>
+#include <lv2/urid/urid.h>
#include <math.h>
#include <stdbool.h>
@@ -199,6 +199,7 @@ play(Metro* self, uint32_t begin, uint32_t end)
{
float* const output = self->ports.output;
const uint32_t frames_per_beat = (uint32_t)(60.0f / self->bpm * self->rate);
+ const float attack_den = self->attack_len ? (float)self->attack_len : 1.0f;
if (self->speed == 0.0f) {
memset(output, 0, (end - begin) * sizeof(float));
@@ -209,8 +210,8 @@ play(Metro* self, uint32_t begin, uint32_t end)
switch (self->state) {
case STATE_ATTACK:
// Amplitude increases from 0..1 until attack_len
- output[i] = self->wave[self->wave_offset] * (float)self->elapsed_len /
- (float)self->attack_len;
+ output[i] =
+ self->wave[self->wave_offset] * (float)self->elapsed_len / attack_den;
if (self->elapsed_len >= self->attack_len) {
self->state = STATE_DECAY;
}
@@ -331,8 +332,7 @@ static const LV2_Descriptor descriptor = {
NULL, // extension_data
};
-LV2_SYMBOL_EXPORT
-const LV2_Descriptor*
+LV2_SYMBOL_EXPORT const LV2_Descriptor*
lv2_descriptor(uint32_t index)
{
return index == 0 ? &descriptor : NULL;