diff options
Diffstat (limited to 'plugins/eg-metro.lv2')
-rw-r--r-- | plugins/eg-metro.lv2/meson.build | 42 | ||||
-rw-r--r-- | plugins/eg-metro.lv2/metro.c | 51 | ||||
l--------- | plugins/eg-metro.lv2/waf | 1 | ||||
-rw-r--r-- | plugins/eg-metro.lv2/wscript | 50 |
4 files changed, 61 insertions, 83 deletions
diff --git a/plugins/eg-metro.lv2/meson.build b/plugins/eg-metro.lv2/meson.build new file mode 100644 index 0000000..ee4016e --- /dev/null +++ b/plugins/eg-metro.lv2/meson.build @@ -0,0 +1,42 @@ +# Copyright 2022 David Robillard <d@drobilla.net> +# SPDX-License-Identifier: 0BSD OR ISC + +plugin_sources = files('metro.c') +bundle_name = 'eg-metro.lv2' +data_filenames = ['manifest.ttl.in', 'metro.ttl'] + +module = shared_library( + 'metro', + plugin_sources, + c_args: c_suppressions, + dependencies: [lv2_dep, m_dep], + gnu_symbol_visibility: 'hidden', + implicit_include_directories: false, + install: true, + install_dir: lv2dir / bundle_name, + name_prefix: '', +) + +config = configuration_data( + { + 'LIB_EXT': '.' + module.full_path().split('.')[-1], + }, +) + +foreach filename : data_filenames + if filename.endswith('.in') + configure_file( + configuration: config, + input: files(filename), + install_dir: lv2dir / bundle_name, + output: filename.substring(0, -3), + ) + else + configure_file( + copy: true, + input: files(filename), + install_dir: lv2dir / bundle_name, + output: filename, + ) + endif +endforeach diff --git a/plugins/eg-metro.lv2/metro.c b/plugins/eg-metro.lv2/metro.c index 46ca41b..e60a33f 100644 --- a/plugins/eg-metro.lv2/metro.c +++ b/plugins/eg-metro.lv2/metro.c @@ -1,28 +1,14 @@ -/* - LV2 Metronome Example Plugin - Copyright 2012-2016 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. -*/ - -#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" +// 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 <math.h> #include <stdbool.h> @@ -212,7 +198,8 @@ static void play(Metro* self, uint32_t begin, uint32_t end) { float* const output = self->ports.output; - const uint32_t frames_per_beat = 60.0f / self->bpm * self->rate; + 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)); @@ -223,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] * 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; } @@ -289,7 +276,7 @@ update_position(Metro* self, const LV2_Atom_Object* obj) const float frames_per_beat = (float)(60.0 / self->bpm * self->rate); const float bar_beats = ((LV2_Atom_Float*)beat)->body; const float beat_beats = bar_beats - floorf(bar_beats); - self->elapsed_len = beat_beats * frames_per_beat; + self->elapsed_len = (uint32_t)(beat_beats * frames_per_beat); if (self->elapsed_len < self->attack_len) { self->state = STATE_ATTACK; } else if (self->elapsed_len < self->attack_len + self->decay_len) { @@ -313,7 +300,7 @@ run(LV2_Handle instance, uint32_t sample_count) !lv2_atom_sequence_is_end(&in->body, in->atom.size, ev); ev = lv2_atom_sequence_next(ev)) { // Play the click for the time slice from last_t until now - play(self, last_t, ev->time.frames); + play(self, last_t, (uint32_t)ev->time.frames); // Check if this event is an Object // (or deprecated Blank to tolerate old hosts) @@ -327,7 +314,7 @@ run(LV2_Handle instance, uint32_t sample_count) } // Update time for next iteration and move to next event - last_t = ev->time.frames; + last_t = (uint32_t)ev->time.frames; } // Play for remainder of cycle @@ -346,7 +333,7 @@ static const LV2_Descriptor descriptor = { }; LV2_SYMBOL_EXPORT const LV2_Descriptor* - lv2_descriptor(uint32_t index) +lv2_descriptor(uint32_t index) { return index == 0 ? &descriptor : NULL; } diff --git a/plugins/eg-metro.lv2/waf b/plugins/eg-metro.lv2/waf deleted file mode 120000 index 59a1ac9..0000000 --- a/plugins/eg-metro.lv2/waf +++ /dev/null @@ -1 +0,0 @@ -../../waf
\ No newline at end of file diff --git a/plugins/eg-metro.lv2/wscript b/plugins/eg-metro.lv2/wscript deleted file mode 100644 index 5fb0d07..0000000 --- a/plugins/eg-metro.lv2/wscript +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env python -from waflib.extras import autowaf as autowaf -import re - -# Variables for 'waf dist' -APPNAME = 'eg-metro.lv2' -VERSION = '1.0.0' - -# Mandatory variables -top = '.' -out = 'build' - -def options(opt): - opt.load('compiler_c') - opt.load('lv2') - autowaf.set_options(opt) - -def configure(conf): - conf.load('compiler_c', cache=True) - conf.load('lv2', cache=True) - conf.load('autowaf', cache=True) - - conf.check_pkg('lv2 >= 0.2.0', uselib_store='LV2') - - conf.check(features='c cshlib', lib='m', uselib_store='M', mandatory=False) - -def build(bld): - bundle = 'eg-metro.lv2' - - # Build manifest.ttl by substitution (for portable lib extension) - bld(features = 'subst', - source = 'manifest.ttl.in', - target = 'lv2/%s/%s' % (bundle, 'manifest.ttl'), - install_path = '${LV2DIR}/%s' % bundle, - LIB_EXT = bld.env.LV2_LIB_EXT) - - # Copy other data files to build bundle (build/eg-metro.lv2) - bld(features = 'subst', - is_copy = True, - source = 'metro.ttl', - target = 'lv2/%s/metro.ttl' % bundle, - install_path = '${LV2DIR}/%s' % bundle) - - # Build plugin library - obj = bld(features = 'c cshlib lv2lib', - source = 'metro.c', - name = 'metro', - target = 'lv2/%s/metro' % bundle, - install_path = '${LV2DIR}/%s' % bundle, - use = ['M', 'LV2']) |