2020-06-21 17:29:27 -04:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import ArdourClient from '/shared/ardour.js';
|
2020-08-22 15:33:49 -04:00
|
|
|
import { createRootContainer, Container, Dialog, Label, Button, Toggle,
|
|
|
|
DiscreteKnob, LinearKnob, LogKnob, PanKnob,
|
|
|
|
StripGainFader, StripMeter } from './tkwidget.js';
|
2020-06-21 17:29:27 -04:00
|
|
|
|
|
|
|
(() => {
|
|
|
|
|
|
|
|
const ardour = new ArdourClient();
|
|
|
|
|
|
|
|
async function main () {
|
2020-07-25 12:09:12 -04:00
|
|
|
setupFullscreenButton();
|
|
|
|
|
2020-06-21 17:29:27 -04:00
|
|
|
const root = await createRootContainer();
|
|
|
|
|
|
|
|
ardour.mixer.on('ready', () => {
|
|
|
|
if (root.children.length > 0) {
|
|
|
|
root.removeChild(root.children[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
const mixer = new Container();
|
|
|
|
mixer.id = 'mixer';
|
|
|
|
mixer.appendTo(root);
|
|
|
|
|
2020-07-25 12:09:12 -04:00
|
|
|
// left flexbox padding
|
2020-06-21 17:29:27 -04:00
|
|
|
mixer.appendChild(new Container());
|
|
|
|
|
|
|
|
for (const strip of ardour.mixer.strips) {
|
|
|
|
const container = new Container();
|
2020-07-25 11:45:39 -04:00
|
|
|
container.classList.add('strip');
|
2020-06-21 17:29:27 -04:00
|
|
|
container.appendTo(mixer);
|
|
|
|
createStrip(strip, container);
|
|
|
|
}
|
|
|
|
|
2020-07-25 12:09:12 -04:00
|
|
|
// right flexbox padding
|
2020-06-21 17:29:27 -04:00
|
|
|
mixer.appendChild(new Container());
|
|
|
|
});
|
|
|
|
|
|
|
|
ardour.connect();
|
|
|
|
}
|
|
|
|
|
2020-08-22 15:33:49 -04:00
|
|
|
function setupFullscreenButton () {
|
|
|
|
const doc = document.documentElement,
|
|
|
|
button = document.getElementById('fullscreen');
|
|
|
|
|
|
|
|
let requestFullscreen = null, fullscreenChange = null;
|
|
|
|
|
|
|
|
if ('requestFullscreen' in doc) {
|
|
|
|
requestFullscreen = doc.requestFullscreen.bind(doc);
|
|
|
|
fullscreenChange = 'fullscreenchange';
|
|
|
|
} else if ('webkitRequestFullscreen' in doc) {
|
|
|
|
requestFullscreen = doc.webkitRequestFullscreen.bind(doc);
|
|
|
|
fullscreenChange = 'webkitfullscreenchange';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (requestFullscreen && fullscreenChange) {
|
|
|
|
button.addEventListener('click', requestFullscreen);
|
|
|
|
|
|
|
|
document.addEventListener(fullscreenChange, (e) => {
|
|
|
|
const fullscreen = document.fullscreen || document.webkitIsFullScreen;
|
|
|
|
button.style.display = fullscreen ? 'none' : 'inline';
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
button.style.display = 'none';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-21 17:29:27 -04:00
|
|
|
function createStrip (strip, container) {
|
2020-08-22 15:33:49 -04:00
|
|
|
const plugins = new Button();
|
|
|
|
plugins.text = 'ƒ';
|
|
|
|
plugins.classList.add('strip-plugins');
|
|
|
|
plugins.appendTo(container);
|
|
|
|
|
2020-09-01 16:28:00 -04:00
|
|
|
if (strip.plugins.length == 0) {
|
2020-08-22 15:33:49 -04:00
|
|
|
plugins.classList.add('disabled');
|
2020-09-01 16:28:00 -04:00
|
|
|
plugins.element.style.visibility = 'hidden';
|
2020-08-16 09:03:17 -04:00
|
|
|
} else {
|
2020-08-22 15:33:49 -04:00
|
|
|
plugins.callback = () => openPlugins (strip);
|
2020-08-16 09:03:17 -04:00
|
|
|
}
|
|
|
|
|
2020-06-21 17:29:27 -04:00
|
|
|
const pan = new PanKnob();
|
|
|
|
pan.appendTo(container);
|
2020-07-25 11:45:39 -04:00
|
|
|
|
2020-09-01 16:28:00 -04:00
|
|
|
if (strip.hasPan) {
|
2020-06-21 17:29:27 -04:00
|
|
|
pan.bindTo(strip, 'pan');
|
2020-09-01 16:28:00 -04:00
|
|
|
} else {
|
|
|
|
pan.element.style.visibility = 'hidden';
|
2020-06-21 17:29:27 -04:00
|
|
|
}
|
|
|
|
|
2020-08-16 09:03:17 -04:00
|
|
|
const mute = new Toggle();
|
|
|
|
mute.text = 'Mute';
|
2020-08-22 15:33:49 -04:00
|
|
|
mute.classList.add('strip-mute');
|
2020-08-16 09:03:17 -04:00
|
|
|
mute.appendTo(container);
|
|
|
|
mute.bindTo(strip, 'mute');
|
|
|
|
|
2020-06-21 17:29:27 -04:00
|
|
|
const meterFader = new Container();
|
2020-07-25 11:45:39 -04:00
|
|
|
meterFader.classList.add('strip-meter-fader');
|
2020-08-22 15:33:49 -04:00
|
|
|
meterFader.appendTo(container);
|
2020-06-21 17:29:27 -04:00
|
|
|
|
|
|
|
const gain = new StripGainFader();
|
|
|
|
gain.appendTo(meterFader);
|
|
|
|
gain.bindTo(strip, 'gain');
|
|
|
|
|
|
|
|
const meter = new StripMeter();
|
|
|
|
meter.appendTo(meterFader);
|
|
|
|
meter.bindTo(strip, 'meter');
|
|
|
|
|
2020-07-25 11:45:39 -04:00
|
|
|
const label = new Label();
|
|
|
|
label.text = strip.name;
|
|
|
|
label.classList.add('strip-label');
|
|
|
|
label.appendTo(container);
|
2020-06-21 17:29:27 -04:00
|
|
|
}
|
|
|
|
|
2020-08-22 15:33:49 -04:00
|
|
|
function openPlugins (strip) {
|
|
|
|
const dialog = new Dialog();
|
|
|
|
dialog.id = 'plugins-dialog';
|
|
|
|
|
|
|
|
const close = new Button();
|
|
|
|
close.id = 'plugins-close';
|
|
|
|
close.icon = 'close';
|
|
|
|
dialog.closeButton = close;
|
|
|
|
|
|
|
|
const plugins = new Container();
|
|
|
|
plugins.id = 'plugins';
|
|
|
|
plugins.appendTo(dialog);
|
|
|
|
|
|
|
|
const label = new Label();
|
|
|
|
label.id = 'plugins-title';
|
|
|
|
label.text = strip.name;
|
|
|
|
label.appendTo(plugins);
|
|
|
|
|
|
|
|
for (const plugin of strip.plugins) {
|
|
|
|
createStripPlugin(plugin, plugins);
|
|
|
|
}
|
|
|
|
|
|
|
|
dialog.onClose = () => {
|
|
|
|
// disconnect all parameters
|
|
|
|
for (const plugin of strip.plugins) {
|
|
|
|
for (const param of plugin.parameters) {
|
|
|
|
param.removeObserver();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
dialog.show();
|
|
|
|
}
|
|
|
|
|
|
|
|
function createStripPlugin (plugin, dialog) {
|
|
|
|
const enableAndName = new Container();
|
|
|
|
enableAndName.appendTo(dialog);
|
|
|
|
|
2020-06-21 17:29:27 -04:00
|
|
|
const enable = new Toggle();
|
2020-08-22 15:33:49 -04:00
|
|
|
enable.setIcons('unchecked', 'checked');
|
|
|
|
enable.appendTo(enableAndName);
|
2020-06-21 17:29:27 -04:00
|
|
|
enable.bindTo(plugin, 'enable');
|
|
|
|
|
2020-08-22 15:33:49 -04:00
|
|
|
const label = new Label();
|
|
|
|
label.text = plugin.name;
|
|
|
|
label.appendTo(enableAndName);
|
|
|
|
|
|
|
|
const container = new Container();
|
|
|
|
container.classList.add('plugin-parameters');
|
|
|
|
container.appendTo(dialog);
|
|
|
|
|
2020-06-21 17:29:27 -04:00
|
|
|
for (const param of plugin.parameters) {
|
|
|
|
createStripPluginParam(param, container);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function createStripPluginParam (param, container) {
|
|
|
|
let widget;
|
|
|
|
|
|
|
|
if (param.valueType.isBoolean) {
|
|
|
|
widget = new Toggle();
|
2020-08-22 15:33:49 -04:00
|
|
|
widget.setIcons('unchecked', 'checked');
|
2020-06-21 17:29:27 -04:00
|
|
|
} else if (param.valueType.isInteger) {
|
|
|
|
widget = new DiscreteKnob(param.min, param.max);
|
|
|
|
} else if (param.valueType.isDouble) {
|
|
|
|
if (param.isLog) {
|
|
|
|
widget = new LogKnob(param.min, param.max);
|
|
|
|
} else {
|
|
|
|
widget = new LinearKnob(param.min, param.max);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-22 15:33:49 -04:00
|
|
|
const labeledWidget = new Container();
|
|
|
|
labeledWidget.classList.add('plugin-parameter');
|
|
|
|
labeledWidget.appendTo(container);
|
2020-07-25 12:09:12 -04:00
|
|
|
|
2020-08-22 15:33:49 -04:00
|
|
|
const widgetContainer = new Container();
|
|
|
|
widgetContainer.classList.add('plugin-parameter-widget');
|
|
|
|
widgetContainer.appendTo(labeledWidget);
|
2020-07-25 12:09:12 -04:00
|
|
|
|
2020-08-22 15:33:49 -04:00
|
|
|
widget.appendTo(widgetContainer);
|
|
|
|
widget.bindTo(param, 'value');
|
2020-08-16 09:03:17 -04:00
|
|
|
|
|
|
|
const label = new Label();
|
2020-08-22 15:33:49 -04:00
|
|
|
label.text = param.name;
|
|
|
|
label.appendTo(labeledWidget);
|
2020-08-16 09:03:17 -04:00
|
|
|
}
|
|
|
|
|
2020-06-21 17:29:27 -04:00
|
|
|
main();
|
|
|
|
|
|
|
|
})();
|