diff options
Diffstat (limited to 'share/web_surfaces')
-rw-r--r-- | share/web_surfaces/builtin/mixer-demo/css/main.css | 92 | ||||
-rw-r--r-- | share/web_surfaces/builtin/mixer-demo/css/widget.css | 50 | ||||
-rw-r--r-- | share/web_surfaces/builtin/mixer-demo/index.html | 18 | ||||
-rw-r--r-- | share/web_surfaces/builtin/mixer-demo/js/connection.js | 77 | ||||
-rw-r--r-- | share/web_surfaces/builtin/mixer-demo/js/main.js | 156 | ||||
-rw-r--r-- | share/web_surfaces/builtin/mixer-demo/js/widget.js | 157 | ||||
-rw-r--r-- | share/web_surfaces/builtin/mixer-demo/manifest.xml | 5 | ||||
-rw-r--r-- | share/web_surfaces/builtin/transport/index.html | 10 | ||||
-rw-r--r-- | share/web_surfaces/builtin/transport/manifest.xml | 5 | ||||
-rw-r--r-- | share/web_surfaces/css/junge-regular-webfont.ttf | bin | 0 -> 71400 bytes | |||
-rw-r--r-- | share/web_surfaces/css/junge-regular-webfont.woff | bin | 0 -> 30848 bytes | |||
-rw-r--r-- | share/web_surfaces/css/main.css | 79 | ||||
-rw-r--r-- | share/web_surfaces/img/logo.png | bin | 0 -> 36211 bytes | |||
-rw-r--r-- | share/web_surfaces/index.html | 25 | ||||
-rw-r--r-- | share/web_surfaces/js/main.js | 69 | ||||
-rw-r--r-- | share/web_surfaces/wscript | 13 |
16 files changed, 756 insertions, 0 deletions
diff --git a/share/web_surfaces/builtin/mixer-demo/css/main.css b/share/web_surfaces/builtin/mixer-demo/css/main.css new file mode 100644 index 0000000000..5578ab3e55 --- /dev/null +++ b/share/web_surfaces/builtin/mixer-demo/css/main.css @@ -0,0 +1,92 @@ +html { + height: 100%; +} + +body { + background: #282923; + color: rgb(248,248,242); + font-family: Helvetica, Arial, sans-serif; + height: 100%; + margin: 0; +} + +div { + box-sizing: border-box; +} + +#main { + display: flex; + flex-direction: column; + height: 100%; +} + +#strips { + flex: 1; + overflow: scroll; + overflow-x: hidden; + box-shadow: 0px 0px 10px #000; +} + +#log { + height: 6em; + overflow: scroll; + overflow-x: hidden; +} + +#log pre { + margin: 0; + font-family: Menlo, monospace; + font-size: 1em; +} + +.message-in { + color: rgb(166,226,44); +} + +.message-out { + color: rgb(172,128,255); +} + +.error { + color: rgb(249,36,114); +} + +.comp-name { + font-size: 1.5em; + font-weight: bold; +} + +.strip { + margin: 5%; + padding: 2.5% 5%; + background: rgba(0,0,0,0.1); + border-radius: 5px; +} + +.slider-meter { + float: right; +} + +.strip-slider { + margin-top: 2.5%; +} + +.plugin { + margin: 5%; + padding: 2.5% 5%; + background: rgba(0,0,0,0.05); + border: solid 1px rgba(255,255,255,0.1); + border-radius: 5px; +} + +.plugin-enable { + float: right; +} + +.plugin-param { + margin: 5%; +} + +.plugin-param.boolean { + display: inline-block; +} diff --git a/share/web_surfaces/builtin/mixer-demo/css/widget.css b/share/web_surfaces/builtin/mixer-demo/css/widget.css new file mode 100644 index 0000000000..75be020642 --- /dev/null +++ b/share/web_surfaces/builtin/mixer-demo/css/widget.css @@ -0,0 +1,50 @@ +.widget-switch { + display: block; + -webkit-appearance:none; + width: 37px; + height: 37px; + border: 3.5px solid rgb(248,248,242); + border-radius: 50%; +} + +.widget-switch:checked { + background: rgb(235,141,33); +} + +.widget-slider { + display: block; + -webkit-appearance: none; + height: 37px; + width: 100%; + background: transparent; +} + +.widget-slider::-webkit-slider-runnable-track { + height: 4px; + background: rgb(248,248,242); +} + +.widget-slider::-webkit-slider-thumb { + -webkit-appearance: none; + height: 36px; + width: 36px; + margin-top: -16px; + border-radius: 50%; + background: rgb(235,141,33); +} + +/* repeat slider style for firefox */ + +.widget-slider::-moz-range-track { + height: 4px; + background: rgb(248,248,242); +} + +.widget-slider::-moz-range-thumb { + -webkit-appearance: none; + height: 36px; + width: 36px; + margin-top: -16px; + border-radius: 50%; + background: rgb(235,141,33); +} diff --git a/share/web_surfaces/builtin/mixer-demo/index.html b/share/web_surfaces/builtin/mixer-demo/index.html new file mode 100644 index 0000000000..947d017397 --- /dev/null +++ b/share/web_surfaces/builtin/mixer-demo/index.html @@ -0,0 +1,18 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8"> + <title>Ardour WebSockets Demo</title> + <link rel="stylesheet" type="text/css" href="css/main.css"> + <link rel="stylesheet" type="text/css" href="css/widget.css"> + </head> + <body> + <div id="main"> + <div id="strips"></div> + <div id="log"></div> + </div> + <script src="js/connection.js"></script> + <script src="js/widget.js"></script> + <script src="js/main.js"></script> + </body> +</html> diff --git a/share/web_surfaces/builtin/mixer-demo/js/connection.js b/share/web_surfaces/builtin/mixer-demo/js/connection.js new file mode 100644 index 0000000000..077799b48b --- /dev/null +++ b/share/web_surfaces/builtin/mixer-demo/js/connection.js @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2020 Luciano Iam <lucianito@gmail.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +const JSON_INF = 1.0e+128; + +class Connection { + + // https://developer.mozilla.org/en-US/docs/Web/API/URL/host + + constructor (host) { + this.socket = new WebSocket(`ws://${host}`); + this.socket.onopen = () => this.openCallback(); + this.socket.onclose = () => this.closeCallback(); + this.socket.onerror = (error) => this.errorCallback(error); + this.socket.onmessage = (event) => this._onMessage(event); + } + + openCallback () { + // empty + } + + closeCallback () { + // empty + } + + errorCallback (error) { + // empty + } + + messageCallback (node, addr, val) { + // empty + } + + send (node, addr, val) { + for (const i in val) { + if (val[i] == Infinity) { + val[i] = JSON_INF; + } else if (val[i] == -Infinity) { + val[i] = -JSON_INF; + } + } + + const json = JSON.stringify({node: node, addr: addr, val: val}); + + this.socket.send(json); + } + + _onMessage (event) { + const msg = JSON.parse(event.data); + + for (const i in msg.val) { + if (msg.val[i] >= JSON_INF) { + msg.val[i] = Infinity; + } else if (msg.val[i] <= -JSON_INF) { + msg.val[i] = -Infinity; + } + } + + this.messageCallback(msg.node, msg.addr || [], msg.val); + } + +} diff --git a/share/web_surfaces/builtin/mixer-demo/js/main.js b/share/web_surfaces/builtin/mixer-demo/js/main.js new file mode 100644 index 0000000000..931371979a --- /dev/null +++ b/share/web_surfaces/builtin/mixer-demo/js/main.js @@ -0,0 +1,156 @@ +/* + * Copyright (C) 2020 Luciano Iam <lucianito@gmail.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +(() => { + + const MAX_LOG_LINES = 1000; + const FEEDBACK_NODES = ['strip_gain', 'strip_pan', 'strip_meter', 'strip_plugin_enable', + 'strip_plugin_param_value']; + + const conn = new Connection(location.host); + const widgets = {}; + + conn.messageCallback = (node, addr, val) => { + log(`↙ ${node} (${addr}) = ${val}`, 'message-in'); + + if (node == 'strip_desc') { + createStrip (addr, ...val); + } else if (node == 'strip_plugin_desc') { + createStripPlugin (addr, ...val); + } else if (node == 'strip_plugin_param_desc') { + createStripPluginParam (addr, ...val); + } else if (FEEDBACK_NODES.includes(node)) { + if (widgets[[node, addr]]) { + widgets[[node, addr]].value = val[0]; + } + } + }; + + conn.closeCallback = () => { + log('Connection dropped', 'error'); + }; + + conn.errorCallback = () => { + log('Connection error', 'error'); + }; + + function createStrip (addr, name) { + const id = `strip-${addr[0]}`; + const strips = document.getElementById('strips'); + const div = createElem(`<div class="strip" id="${id}"></div>`, strips); + createElem(`<label class="comp-name" for="${id}">∿  ${name}</label>`, div); + + // meter + const meter = new StripMeter('strip_meter', addr); + meter.el.classList.add('slider-meter'); + meter.attach(div); + register(meter); + + // gain + let holder = createElem(`<div class="strip-slider"></div>`, div); + createElem(`<label>Gain</label>`, holder); + const gain = new StripGainSlider('strip_gain', addr); + gain.attach(holder, (val) => send(gain)); + register(gain); + + // pan + holder = createElem(`<div class="strip-slider"></div>`, div); + createElem(`<label>Pan</label>`, holder); + const pan = new StripPanSlider('strip_pan', addr); + pan.attach(holder, (val) => send(pan)); + register(pan); + } + + function createStripPlugin (addr, name) { + const strip = document.getElementById(`strip-${addr[0]}`); + const id = `plugin-${addr[0]}-${addr[1]}`; + const div = createElem(`<div class="plugin" id="${id}"></div>`, strip); + createElem(`<label class="comp-name">⨍  ${name}</label>`, div); + const enable = new Switch('strip_plugin_enable', addr); + enable.el.classList.add('plugin-enable'); + enable.attach(div, (val) => send(enable)); + register(enable); + } + + function createStripPluginParam (addr, name, data_type, min, max, is_log) { + let param, clazz; + + if (data_type == 'b') { + clazz = 'boolean'; + param = new Switch('strip_plugin_param_value', addr); + } else if (data_type == 'i') { + clazz = 'discrete'; + param = new DiscreteSlider('strip_plugin_param_value', addr, min, max); + } else if (data_type == 'd') { + clazz = 'continuous'; + if (is_log) { + param = new LogarithmicSlider('strip_plugin_param_value', addr, min, max); + } else { + param = new ContinuousSlider('strip_plugin_param_value', addr, min, max); + } + } + + const plugin = document.getElementById(`plugin-${addr[0]}-${addr[1]}`); + const id = `param-${addr[0]}-${addr[1]}-${addr[2]}`; + const div = createElem(`<div class="plugin-param ${clazz}" id="${id}"></div>`, plugin); + createElem(`<label for="${id}">${name}</label>`, div); + + param.attach(div, (val) => send(param)); + param.el.name = id; + register(param); + } + + function send (widget) { + const val = widget.value; + log(`↗ ${widget.node} (${widget.addr}) = ${val}`, 'message-out'); + conn.send(widget.node, widget.addr, [val]); + } + + function createElem (html, parent) { + const t = document.createElement('template'); + t.innerHTML = html; + + const elem = t.content.firstChild; + + if (parent) { + parent.appendChild(elem); + } + + return elem; + } + + function register (widget) { + widgets[widget.hash] = widget; + } + + function log (message, className) { + const output = document.getElementById('log'); + + if (output.childElementCount > MAX_LOG_LINES) { + output.removeChild(output.childNodes[0]); + } + + const pre = document.createElement('pre'); + pre.innerHTML = message; + pre.className = className; + + output.appendChild(pre); + output.scrollTop = output.scrollHeight; + } + +})(); diff --git a/share/web_surfaces/builtin/mixer-demo/js/widget.js b/share/web_surfaces/builtin/mixer-demo/js/widget.js new file mode 100644 index 0000000000..7bab5b1b1a --- /dev/null +++ b/share/web_surfaces/builtin/mixer-demo/js/widget.js @@ -0,0 +1,157 @@ +/* + * Copyright (C) 2020 Luciano Iam <lucianito@gmail.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +class Widget { + + constructor (node, addr, html) { + this.node = node; + this.addr = addr; + const template = document.createElement('template'); + template.innerHTML = html; + this.el = template.content.firstChild; + } + + attach (parent, callback) { + parent.appendChild(this.el); + + if (callback) { + this.callback = callback; + } + } + + callback (value) { + // do nothing by default + } + + get hash () { + return [this.node, this.addr]; + } + +} + +class Switch extends Widget { + + constructor (node, addr) { + super (node, addr, `<input type="checkbox" class="widget-switch">`); + this.el.addEventListener('input', (ev) => this.callback(this.value)); + } + + get value () { + return this.el.checked; + } + + set value (val) { + this.el.checked = val; + } + +} + +class Slider extends Widget { + + constructor (node, addr, min, max, step) { + const html = `<input type="range" class="widget-slider" + min="${min}" max="${max}" step="${step}">`; + super(node, addr, html); + this.min = min; + this.max = max; + this.el.addEventListener('input', (ev) => this.callback(this.value)); + } + + get value () { + return parseFloat(this.el.value) + } + + set value (val) { + this.el.value = val; + } + +} + +class DiscreteSlider extends Slider { + + constructor (node, addr, min, max) { + super(node, addr, min, max, 1); + } + +} + +class ContinuousSlider extends Slider { + + constructor (node, addr, min, max) { + super(node, addr, min, max, 0.001); + } + +} + +class LogarithmicSlider extends ContinuousSlider { + + constructor (node, addr, min, max) { + super(node, addr, 0, 1.0); + this.minVal = Math.log(min); + this.maxVal = Math.log(max); + this.scale = this.maxVal - this.minVal; + } + + get value () { + return Math.exp(this.minVal + this.scale * super.value); + } + + set value (val) { + this.el.value = (Math.log(val) - this.minVal) / this.scale; + } + +} + +class StripPanSlider extends ContinuousSlider { + + constructor (node, addr) { + super(node, addr, -1.0, 1.0); + } + +} + +class StripGainSlider extends ContinuousSlider { + + constructor (node, addr) { + super(node, addr, 0, 1.0) + this.minVal = -58.0; + this.maxVal = 6.0; + this.scale = (this.maxVal - this.minVal); + } + + get value () { + return this.maxVal + Math.log10(super.value) * this.scale; + } + + set value (val) { + this.el.value = Math.pow(10.0, (val - this.maxVal) / this.scale); + } + +} + +class StripMeter extends Widget { + + constructor (node, addr) { + super(node, addr, `<label></label>`); + } + + set value (val) { + this.el.innerHTML = val == -Infinity ? '-∞' : `${Math.round(val)} dB`; + } + +} diff --git a/share/web_surfaces/builtin/mixer-demo/manifest.xml b/share/web_surfaces/builtin/mixer-demo/manifest.xml new file mode 100644 index 0000000000..e4a4287d7d --- /dev/null +++ b/share/web_surfaces/builtin/mixer-demo/manifest.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<WebSurface> + <Name value="Mixer Demo"/> + <Description value="Mixer control capabilities demo aimed at developers"/> +</WebSurface> diff --git a/share/web_surfaces/builtin/transport/index.html b/share/web_surfaces/builtin/transport/index.html new file mode 100644 index 0000000000..9d1a40f24c --- /dev/null +++ b/share/web_surfaces/builtin/transport/index.html @@ -0,0 +1,10 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8"> + <title>Ardour Transport</title> + </head> + <body> + <h1>Under Construction</h1> + </body> +</html> diff --git a/share/web_surfaces/builtin/transport/manifest.xml b/share/web_surfaces/builtin/transport/manifest.xml new file mode 100644 index 0000000000..ff48533743 --- /dev/null +++ b/share/web_surfaces/builtin/transport/manifest.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<WebSurface> + <Name value="Transport"/> + <Description value="Provides basic transport control (under construction)"/> +</WebSurface> diff --git a/share/web_surfaces/css/junge-regular-webfont.ttf b/share/web_surfaces/css/junge-regular-webfont.ttf Binary files differnew file mode 100644 index 0000000000..4e381e9e3f --- /dev/null +++ b/share/web_surfaces/css/junge-regular-webfont.ttf diff --git a/share/web_surfaces/css/junge-regular-webfont.woff b/share/web_surfaces/css/junge-regular-webfont.woff Binary files differnew file mode 100644 index 0000000000..4a74925aa9 --- /dev/null +++ b/share/web_surfaces/css/junge-regular-webfont.woff diff --git a/share/web_surfaces/css/main.css b/share/web_surfaces/css/main.css new file mode 100644 index 0000000000..f4f1360f6e --- /dev/null +++ b/share/web_surfaces/css/main.css @@ -0,0 +1,79 @@ +@font-face { + font-family: 'junge-regular'; + src: url('junge-regular-webfont.woff') format('woff'), + url('junge-regular-webfont.ttf') format('truetype'); + font-weight: normal; + font-style: normal; +} + +html { + height: 100%; +} + +body { + font-family: 'junge-regular'; + font-size: 16px; + height: 100%; + margin: 0; +} + +div { + box-sizing: border-box; +} + +a { + color: #337ab7; + text-decoration: none; +} + +a:visited { + text-decoration: underline; +} + +a:focus, a:hover { + color: #23527c; + text-decoration: underline; +} + +#top-bar { + background: #212a30; + padding: 4px; +} + +#logo { + height: 36px; + margin: 8px 8px 0 8px; +} + +#content { + padding: 24px; +} + +#content h1, #content h2 { + font-weight: normal; +} + +#content h1 { + font-size: 1.8em; + margin: 0 0 2ex 0; + padding-bottom: .8ex; + /*border-bottom: 2px solid #ccc;*/ +} + +#content h2 { + font-size: 1.3em; + margin: 2ex 0 1ex 0; + border-bottom: 2px solid #ddd; +} + +.surface-list { + margin-bottom: 6ex; +} + +.surface-list > ul { + list-style-type: none; +} + +.surface-list > ul > li { + margin: 4ex 0; +}
\ No newline at end of file diff --git a/share/web_surfaces/img/logo.png b/share/web_surfaces/img/logo.png Binary files differnew file mode 100644 index 0000000000..652a6c3e1c --- /dev/null +++ b/share/web_surfaces/img/logo.png diff --git a/share/web_surfaces/index.html b/share/web_surfaces/index.html new file mode 100644 index 0000000000..e5bcfce013 --- /dev/null +++ b/share/web_surfaces/index.html @@ -0,0 +1,25 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8"> + <title>Ardour Web Surfaces</title> + <link rel="stylesheet" type="text/css" href="css/main.css"> + </head> + <body> + <div id="top-bar"> + <img id="logo" src="img/logo.png"> + </div> + <div id="content"> + <h1>Available Web Surfaces</h1> + <div class="surface-list"> + <h2>Built-In</h2> + <ul id="builtin"></ul> + </div> + <div class="surface-list"> + <h2>User</h2> + <ul id="user"></ul> + </div> + </div> + <script src="js/main.js"></script> + </body> +</html> diff --git a/share/web_surfaces/js/main.js b/share/web_surfaces/js/main.js new file mode 100644 index 0000000000..fad17e3671 --- /dev/null +++ b/share/web_surfaces/js/main.js @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2020 Luciano Iam <lucianito@gmail.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +(() => { + + const INDEX_RESOURCE = 'index.json'; + + async function fetchIndex (url) { + const response = await fetch(url); + if (response.status == 200) { + return await response.json(); + } else { + throw new Error(`HTTP response status ${response.status}`); + } + } + + function buildItem (group, model) { + const li = document.createElement('li'); + li.innerHTML = `<li> + <a href="${group}/${model.id}/">${model.name}</a> + <p>${model.description}</p> + </li>`; + return li; + } + + function printIndex (index) { + ['builtin', 'user'].forEach((group) => { + const ul = document.getElementById(group); + let models = index[group]; + if (models.length > 0) { + models.sort((a, b) => a.name.localeCompare(b.name)); + for (model of models) { + ul.appendChild(buildItem(group, model)); + } + } else { + ul.parentNode.style.display = 'none'; + } + }); + } + + async function main () { + try { + const indexUrl = `${location.protocol}//${location.host}/${INDEX_RESOURCE}`; + const index = await fetchIndex (indexUrl); + printIndex (index); + } catch (err) { + const content = document.getElementById('content'); + content.innerHTML = `<pre>${INDEX_RESOURCE}: ${err.message}</pre>`; + } + } + + main(); + +})(); diff --git a/share/web_surfaces/wscript b/share/web_surfaces/wscript new file mode 100644 index 0000000000..d549abea38 --- /dev/null +++ b/share/web_surfaces/wscript @@ -0,0 +1,13 @@ +#!/usr/bin/env python +import os + +def configure(conf): + pass + +def build(bld): + datadir = os.path.join(bld.env['DATADIR'], 'web_surfaces') + surfaces = bld.path.ant_glob ('**', excl='wscript') + bld.install_files (datadir, surfaces, relative_trick=True) + +def options(opt): + pass |