Skip to content

Commit

Permalink
Add MOD UI
Browse files Browse the repository at this point in the history
  • Loading branch information
brummer10 committed Oct 10, 2023
1 parent 45d3bc5 commit 6574741
Show file tree
Hide file tree
Showing 11 changed files with 520 additions and 3 deletions.
12 changes: 11 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ endif
# --------------------------------------------------------------
# Installation directories

BUIDL_MOD ?= false
PREFIX ?= /usr/local
BINDIR ?= $(PREFIX)/bin
LIBDIR ?= $(PREFIX)/lib
Expand Down Expand Up @@ -78,6 +79,8 @@ export USER_DSSI_DIR USER_LADSPA_DIR USER_LV2_DIR USER_VST2_DIR USER_VST3_DIR US

all: libs plugins gen

mod: MOD

# --------------------------------------------------------------

submodules:
Expand All @@ -89,6 +92,10 @@ libs:
plugins: libs
$(MAKE) all -C plugins/NeuralRecord

MOD: clean
@BUIDL_MOD=true
$(MAKE) mod -C plugins/NeuralRecord

ifneq ($(CROSS_COMPILING),true)
gen: plugins dpf/utils/lv2_ttl_generator
$(CURDIR)/dpf/utils/generate-ttl.sh
Expand Down Expand Up @@ -117,6 +124,9 @@ install: all
install-user: all
$(MAKE) install-user -C plugins/NeuralRecord

install-mod: mod
$(MAKE) install-mod -C plugins/NeuralRecord

# --------------------------------------------------------------

.PHONY: all clean install install-user submodules libs plugins gen
.PHONY: all mod clean install install-user install-mod submodules libs plugins gen
17 changes: 17 additions & 0 deletions plugins/NeuralRecord/MOD/manifest.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@prefix lv2: <http://lv2plug.in/ns/lv2core#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix pset: <http://lv2plug.in/ns/ext/presets#> .
@prefix ui: <http://lv2plug.in/ns/extensions/ui#> .

<urn:brummer10:neuralrecord>
a lv2:Plugin ;
lv2:binary <neuralrecord_dsp.so> ;
rdfs:seeAlso <neuralrecord_dsp.ttl> ;
rdfs:seeAlso <modgui.ttl> .

<urn:brummer10:neuralrecord#preset001>
a pset:Preset ;
lv2:appliesTo <urn:brummer10:neuralrecord> ;
rdfs:label "" ;
rdfs:seeAlso <presets.ttl> .

21 changes: 21 additions & 0 deletions plugins/NeuralRecord/MOD/modgui.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@prefix modgui: <http://moddevices.com/ns/modgui#> .
@prefix lv2: <http://lv2plug.in/ns/lv2core#> .

<urn:brummer10:neuralrecord>
modgui:gui [
modgui:resourcesDirectory <modgui> ;
modgui:iconTemplate <modgui/icon-profiler.html> ;
modgui:stylesheet <modgui/stylesheet-profiler.css> ;
modgui:screenshot <modgui/screenshot-profiler.png> ;
modgui:thumbnail <modgui/thumbnail-profiler.png> ;
modgui:javascript <modgui/script-profiler.js> ;
modgui:brand "brummer" ;
modgui:label "Neural Record" ;
modgui:model "profiler" ;
modgui:monitoredOutputs [ lv2:symbol "METER" ] , [ lv2:symbol "STATE" ] , [ lv2:symbol "ERRORS" ] ;
modgui:port [
lv2:index 0 ;
lv2:symbol "PROFILE" ;
lv2:name "PROFILE" ;
] ;
] .
53 changes: 53 additions & 0 deletions plugins/NeuralRecord/MOD/modgui/icon-profiler.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<div class="mod-pedal profiler{{{cns}}}">
<div class="popup" mod-role="POPUP"></div>
<div class="background">

<div mod-role="drag-handle" class="mod-drag-handle"></div>
<div class="mod-plugin-name"><h1>{{label}}</h1></div>
<div class="mod-control-group clearfix">
{{#controls.0}}
<div id="js-toggle" class="button" mod-role="input-control-port" mod-port-symbol="{{symbol}}" mod-widget="switch"></div>
{{/controls.0}}
</div>
<div class="meterbar">
<div class="meter" mod-role="METER" mod-port-symbol="{{symbol}}"></div>
</div>
<div class="progressbar" title="{{comment}}">
<div class="progress" mod-role="STATE" mod-port-symbol="{{symbol}}"></div>
</div>
<div class="mod-pedal-input">
{{#effect.ports.audio.input}}
<div class="mod-input mod-input-disconnected" title="{{name}}" mod-role="input-audio-port" mod-port-symbol="{{symbol}}">
<div class="mod-pedal-input-image"></div>
</div>
{{/effect.ports.audio.input}}
{{#effect.ports.midi.input}}
<div class="mod-input mod-input-disconnected" title="{{name}}" mod-role="input-midi-port" mod-port-symbol="{{symbol}}">
<div class="mod-pedal-input-image"></div>
</div>
{{/effect.ports.midi.input}}
{{#effect.ports.cv.input}}
<div class="mod-input mod-input-disconnected" title="{{name}}" mod-role="input-cv-port" mod-port-symbol="{{symbol}}">
<div class="mod-pedal-input-image"></div>
</div>
{{/effect.ports.cv.input}}
</div>
<div class="mod-pedal-output">
{{#effect.ports.audio.output}}
<div class="mod-output mod-output-disconnected" title="{{name}}" mod-role="output-audio-port" mod-port-symbol="{{symbol}}">
<div class="mod-pedal-output-image"></div>
</div>
{{/effect.ports.audio.output}}
{{#effect.ports.midi.output}}
<div class="mod-output mod-output-disconnected" title="{{name}}" mod-role="output-midi-port" mod-port-symbol="{{symbol}}">
<div class="mod-pedal-output-image"></div>
</div>
{{/effect.ports.midi.output}}
{{#effect.ports.cv.output}}
<div class="mod-output mod-output-disconnected" title="{{name}}" mod-role="output-cv-port" mod-port-symbol="{{symbol}}">
<div class="mod-pedal-output-image"></div>
</div>
{{/effect.ports.cv.output}}
</div>
</div>
</div>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
80 changes: 80 additions & 0 deletions plugins/NeuralRecord/MOD/modgui/script-profiler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
function (event) {

const meter = event.icon.find ('[mod-role=METER]');
const state = event.icon.find ('[mod-role=STATE]');
const popup = event.icon.find ('[mod-role=POPUP]');

var position = "0";

function log_meter (db) {
var def = 0.000001; /* Meter deflection %age */

if (db < -70.0) {
def = 0.0000001;
} else if (db < -60.0) {
def = (db + 70.0) * 0.25;
} else if (db < -50.0) {
def = (db + 60.0) * 0.5 + 2.5;
} else if (db < -40.0) {
def = (db + 50.0) * 0.75 + 7.5;
} else if (db < -30.0) {
def = (db + 40.0) * 1.5 + 15.0;
} else if (db < -20.0) {
def = (db + 30.0) * 2.0 + 30.0;
} else if (db < 6.0) {
def = (db + 20.0) * 2.5 + 50.0;
} else {
def = 115.0;
}

return (Math.floor((def/115.0)* 100 ) ).toFixed(1);
}

function handle_event (symbol, value) {
switch (symbol) {
case 'METER':
position = log_meter (value);
meter.css({height: position + `%`});
if (value >= 0) {
meter.css({boxShadow: `5px 5px 15px red`});
} else if (value > -6) {
meter.css({boxShadow: `5px 5px 15px rgba(242, 121, 0, 0.8)`});
} else {
meter.css({boxShadow: `5px 5px 15px rgba(35, 145, 0, 0.8)`});
}
break;
case 'STATE':
position = (Math.floor(value * 100)).toFixed();
state.css({width: `${position}%`});
state.text(`${position}%`);
break;
case 'ERRORS':
if (value >= 3.0) {
popup.text(`Neural Record Error: Sample Rate mismatch, please use 48kHz`);
popup.css({display: 'block'});
setTimeout(function() { popup.css({display: 'none'}); }, 5000);
} else if (value >= 2.0) {
popup.text(`Neural Record Error: Seems we receive only garbage, we stop the process now`);
popup.css({display: 'block'});
setTimeout(function() { popup.css({display: 'none'}); }, 5000);
} else if (value >= 1.0) {
popup.text(`Neural Record Error: No signal comes in, we stop the process now`);
popup.css({display: 'block'});
setTimeout(function() { popup.css({display: 'none'}); }, 5000);
}
break;
default:
break;
}
}

if (event.type == 'start') {
var ports = event.ports;
for (var p in ports) {
handle_event (ports[p].symbol, ports[p].value);
}
}
else if (event.type == 'change') {
handle_event (event.symbol, event.value);
}
}
Loading

0 comments on commit 6574741

Please sign in to comment.