diff --git a/dynamite.ttl b/dynamite.ttl index e900514..b46a5a1 100644 --- a/dynamite.ttl +++ b/dynamite.ttl @@ -3,6 +3,12 @@ @prefix rdfs: . @prefix doap: . @prefix foaf: . +@prefix guiext: . +@prefix ll: . + + a guiext:GtkUI; + guiext:binary ; + guiext:requiredFeature guiext:makeResident. a lv2:Plugin , lv2:AmplifierPlugin , lv2:DistortionPlugin , doap:Project ; lv2:binary ; @@ -14,7 +20,9 @@ foaf:name "Aleks Rutins" ; ] ; lv2:optionalFeature lv2:hardRTCapable ; - + ll:pegName "p"; + guiext:ui ; + lv2:port [ a lv2:InputPort , lv2:AudioPort ; diff --git a/gui.cc b/gui.cc new file mode 100644 index 0000000..08db9a6 --- /dev/null +++ b/gui.cc @@ -0,0 +1,79 @@ +#include +#include +#include +#include +#include + +#include "dynamite.peg" + +using namespace sigc; +using namespace Gtk; + +namespace Dynamite { + class LabeledWidget : public VBox { + public: + LabeledWidget(const Glib::ustring &label, Widget &child) { + add(child); + add(*manage(new Label(label))); + } + }; + + class DriveGUI : public LV2::GUI { + protected: + Scale *drive_scale; + Scale *threshold_scale; + Scale *gain_scale; + Scale *mix_scale; + Scale *create_vscale(p_port_enum nport) { + auto port = p_ports[nport]; + auto result = manage(new VScale(port.min, port.max, 0.01)); + auto scale_slot = bind<0>(bind<0>(bind<0>(&DriveGUI::write_control_ptr, this), (uint32_t)nport), result); + result->signal_value_changed().connect(scale_slot); + return result; + } + public: + DriveGUI(const std::string &url) { + auto vbox = manage(new VBox(false, 6)); + auto hbox = manage(new HBox(false, 6)); + + vbox->add(*manage(new Label("Dynamite"))); + + drive_scale = create_vscale(p_drive); + hbox->add(*manage(new LabeledWidget("Drive", *drive_scale))); + threshold_scale = create_vscale(p_threshold); + hbox->add(*manage(new LabeledWidget("Threshold", *threshold_scale))); + gain_scale = create_vscale(p_gain); + hbox->add(*manage(new LabeledWidget("Gain", *gain_scale))); + + vbox->add(*hbox); + + auto mix = p_ports[p_mix]; + mix_scale = manage(new HScale(mix.min, mix.max, 0.01)); + auto mix_slot = bind<0>(bind<0>(bind<0>(&DriveGUI::write_control_ptr, this), (uint32_t)p_mix), mix_scale); + mix_scale->signal_value_changed().connect(mix_slot); + vbox->add(*manage(new LabeledWidget("Mix", *mix_scale))); + add(*vbox); + } + + static void write_control_ptr(DriveGUI *self, uint32_t port, Scale *ctrl) { + self->write_control(port, ctrl->get_value()); + } + + void port_event(uint32_t port, uint32_t buffer_size, uint32_t format, const void *buffer) { + auto value = *static_cast(buffer); + switch((p_port_enum)port) { + case p_drive: + drive_scale->set_value(value); break; + case p_threshold: + threshold_scale->set_value(value); break; + case p_gain: + gain_scale->set_value(value); break; + case p_mix: + mix_scale->set_value(value); break; + + } + } + }; +} + +static int _ = Dynamite::DriveGUI::register_class("https://github.com/aleksrutins/dynamite/gui"); diff --git a/install.sh b/install.sh deleted file mode 100755 index f9547fe..0000000 --- a/install.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/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/ \ No newline at end of file diff --git a/meson.build b/meson.build index 811a0f2..56ecdaa 100644 --- a/meson.build +++ b/meson.build @@ -2,11 +2,6 @@ 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 = [ @@ -21,8 +16,24 @@ lib_args = [ cc = meson.get_compiler('cpp') +lv2peg = find_program('lv2peg') + +peg = custom_target('dynamite.peg', + output: 'dynamite.peg', + input: 'dynamite.ttl', + command: [lv2peg, '@INPUT@', '@OUTPUT@'], + install: false +) + +srcs = [ + 'dynamite.cc', + 'plugin.cc', + peg +] + shlib = shared_library('dynamite', srcs, - install : false, + install : true, + install_dir : 'lib64/lv2/dynamite.lv2', cpp_args : lib_args, gnu_symbol_visibility : 'hidden', name_prefix : '', @@ -34,6 +45,23 @@ shlib = shared_library('dynamite', srcs, ] ) +guilib = shared_library('dynamite_gui', ['gui.cc', peg], + install: true, + install_dir: 'lib64/lv2/dynamite.lv2', + cpp_args: lib_args, + gnu_symbol_visibility: 'hidden', + name_prefix: '', + dependencies: [ + dependency('lv2'), + dependency('lv2-plugin'), + dependency('lv2-gui'), + dependency('threads'), + dependency('gtkmm-2.4') + ] +) + +install_data(['manifest.ttl', 'dynamite.ttl'], install_dir: 'lib64/lv2/dynamite.lv2') + # test_exe = executable('dynamite_test', 'dynamite_test.cpp', # link_with : shlib) # test('dynamite', test_exe)