first commit
This commit is contained in:
commit
391f9e9a0b
10 changed files with 225 additions and 0 deletions
4
.vscode/settings.json
vendored
Normal file
4
.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"mesonbuild.configureOnOpen": false,
|
||||
"C_Cpp.default.compileCommands": "builddir/vscode_compile_commands.json"
|
||||
}
|
7
LICENSE
Normal file
7
LICENSE
Normal file
|
@ -0,0 +1,7 @@
|
|||
Copyright 2023 Aleks Rutins
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
42
dynamite.cc
Normal file
42
dynamite.cc
Normal file
|
@ -0,0 +1,42 @@
|
|||
#include <lv2/core/lv2.h>
|
||||
#include "plugin.hh"
|
||||
|
||||
using Dynamite::Plugin;
|
||||
|
||||
static LV2_Handle
|
||||
instantiate(const LV2_Descriptor* descriptor,
|
||||
double rate,
|
||||
const char* bundle_path,
|
||||
const LV2_Feature* const* features)
|
||||
{
|
||||
return new Plugin;
|
||||
}
|
||||
|
||||
static void
|
||||
cleanup(LV2_Handle instance)
|
||||
{
|
||||
delete (Plugin *)instance;
|
||||
}
|
||||
|
||||
static const void*
|
||||
extension_data(const char *uri)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static const LV2_Descriptor descriptor = {
|
||||
"https://github.com/aleksrutins/dynamite",
|
||||
instantiate,
|
||||
(void (*)(LV2_Handle, uint32_t, void*)) &Plugin::connect_port,
|
||||
(void (*)(LV2_Handle)) &Plugin::activate,
|
||||
(void (*)(LV2_Handle, uint32_t)) &Plugin::run,
|
||||
(void (*)(LV2_Handle)) &Plugin::deactivate,
|
||||
cleanup,
|
||||
extension_data
|
||||
};
|
||||
|
||||
LV2_SYMBOL_EXPORT
|
||||
const LV2_Descriptor*
|
||||
lv2_descriptor(uint32_t index) {
|
||||
return index == 0 ? &descriptor : nullptr;
|
||||
}
|
41
dynamite.ttl
Normal file
41
dynamite.ttl
Normal file
|
@ -0,0 +1,41 @@
|
|||
@prefix lv2: <http://lv2plug.in/ns/lv2core#> .
|
||||
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
||||
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
|
||||
@prefix doap: <http://usefulinc.com/ns/doap#> .
|
||||
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
|
||||
|
||||
<https://github.com/aleksrutins/dynamite> a lv2:Plugin , lv2:AmplifierPlugin , doap:Project ;
|
||||
lv2:binary <dynamite.so> ;
|
||||
doap:name "Dynamite" ;
|
||||
doap:license <https://opensource.org/licenses/mit> ;
|
||||
doap:maintainer [
|
||||
a foaf:Person ;
|
||||
foaf:homepage <https://aleks.rutins.com> ;
|
||||
foaf:name "Aleks Rutins" ;
|
||||
] ;
|
||||
lv2:optionalFeature lv2:hardRTCapable ;
|
||||
|
||||
lv2:port
|
||||
[
|
||||
a lv2:InputPort , lv2:AudioPort ;
|
||||
lv2:index 0 ;
|
||||
lv2:symbol "audio_in" ;
|
||||
lv2:name "Audio Input" ;
|
||||
] ,
|
||||
|
||||
[
|
||||
a lv2:OutputPort , lv2:AudioPort ;
|
||||
lv2:index 1 ;
|
||||
lv2:symbol "audio_out" ;
|
||||
lv2:name "Audio Output" ;
|
||||
] ,
|
||||
|
||||
[
|
||||
a lv2:InputPort , lv2:ControlPort ;
|
||||
lv2:index 2 ;
|
||||
lv2:symbol "drive" ;
|
||||
lv2:name "Drive" ;
|
||||
lv2:default 0.0 ;
|
||||
lv2:minimum -20.0 ;
|
||||
lv2:maximum 20.0 ;
|
||||
] .
|
10
install.sh
Executable file
10
install.sh
Executable file
|
@ -0,0 +1,10 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
: "${PREFIX:="$HOME/.lv2"}"
|
||||
|
||||
meson builddir
|
||||
ninja -C builddir
|
||||
|
||||
rm -rf $PREFIX/dynamite.lv2
|
||||
mkdir -p $PREFIX/dynamite.lv2
|
||||
cp {dynamite,manifest}.ttl builddir/dynamite.{so,dylib,dll} $PREFIX/dynamite.lv2/
|
6
manifest.ttl
Normal file
6
manifest.ttl
Normal file
|
@ -0,0 +1,6 @@
|
|||
@prefix lv2: <http://lv2plug.in/ns/lv2core#> .
|
||||
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
|
||||
|
||||
<https://github.com/aleksrutins/dynamite> a lv2:Plugin ;
|
||||
lv2:binary <dynamite@LIB_EXT@> ;
|
||||
rdfs:seeAlso <dynamite.ttl> .
|
57
meson.build
Normal file
57
meson.build
Normal file
|
@ -0,0 +1,57 @@
|
|||
project('dynamite', 'cpp',
|
||||
version : '0.1',
|
||||
default_options : ['warning_level=3', 'cpp_std=c++14'])
|
||||
|
||||
srcs = [
|
||||
'dynamite.cc',
|
||||
'plugin.cc',
|
||||
]
|
||||
|
||||
# These arguments are only used to build the shared library
|
||||
# not the executables that use the library.
|
||||
lib_args = [
|
||||
'-DBUILDING_DYNAMITE',
|
||||
'-fvisibility=hidden',
|
||||
'-fPIC',
|
||||
'-Wl,-Bstatic',
|
||||
'-Wl,-Bdynamic',
|
||||
'-Wl,--as-needed',
|
||||
'-shared'
|
||||
]
|
||||
|
||||
cc = meson.get_compiler('cpp')
|
||||
|
||||
shlib = shared_library('dynamite', srcs,
|
||||
install : false,
|
||||
cpp_args : lib_args,
|
||||
gnu_symbol_visibility : 'hidden',
|
||||
name_prefix : '',
|
||||
dependencies : [
|
||||
dependency('lv2'),
|
||||
cc.find_library('m'),
|
||||
dependency('threads')
|
||||
]
|
||||
)
|
||||
|
||||
# test_exe = executable('dynamite_test', 'dynamite_test.cpp',
|
||||
# link_with : shlib)
|
||||
# test('dynamite', test_exe)
|
||||
|
||||
# Make this library usable as a Meson subproject.
|
||||
#dynamite_dep = declare_dependency(
|
||||
# include_directories: include_directories('.'),
|
||||
# link_with : shlib)
|
||||
|
||||
# Make this library usable from the system's11
|
||||
# package manager.
|
||||
# install_headers('dynamite.hpp', subdir : 'dynamite')
|
||||
|
||||
# pkg_mod = import('pkgconfig')
|
||||
# pkg_mod.generate(
|
||||
# name : 'dynamite',
|
||||
# filebase : 'dynamite',
|
||||
# description : 'Meson sample project.',
|
||||
# subdirs : 'dynamite',
|
||||
# libraries : shlib,
|
||||
# version : '0.1',
|
||||
# )
|
33
plugin.cc
Normal file
33
plugin.cc
Normal file
|
@ -0,0 +1,33 @@
|
|||
#include <lv2/core/lv2.h>
|
||||
#include "plugin.hh"
|
||||
#include "util.hh"
|
||||
|
||||
namespace Dynamite {
|
||||
void Plugin::activate() {
|
||||
|
||||
}
|
||||
|
||||
void Plugin::connect_port(PluginPort port, void* data) {
|
||||
switch(port) {
|
||||
case IN:
|
||||
input = (const float *)data;
|
||||
break;
|
||||
case OUT:
|
||||
output = (float *)data;
|
||||
break;
|
||||
case DRIVE:
|
||||
drive = (const float *)data;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Plugin::run(uint32_t n_samples) {
|
||||
const float coeff = dbCo(*drive);
|
||||
|
||||
for(uint32_t pos = 0; pos < n_samples; pos++) {
|
||||
output[pos] = input[pos] * coeff;
|
||||
}
|
||||
}
|
||||
|
||||
void Plugin::deactivate() {}
|
||||
}
|
19
plugin.hh
Normal file
19
plugin.hh
Normal file
|
@ -0,0 +1,19 @@
|
|||
#pragma once
|
||||
#include <stdint.h>
|
||||
|
||||
namespace Dynamite {
|
||||
enum PluginPort {
|
||||
IN, OUT, DRIVE
|
||||
};
|
||||
|
||||
class Plugin {
|
||||
const float *drive;
|
||||
const float *input;
|
||||
float *output;
|
||||
public:
|
||||
void connect_port(PluginPort port, void* data);
|
||||
void activate();
|
||||
void run(uint32_t n_samples);
|
||||
void deactivate();
|
||||
};
|
||||
}
|
6
util.hh
Normal file
6
util.hh
Normal file
|
@ -0,0 +1,6 @@
|
|||
#pragma once
|
||||
#include <math.h>
|
||||
|
||||
inline float dbCo(float g) {
|
||||
return powf(10.0f, g*0.05f);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue