2020-05-29 05:37:34 -04:00
|
|
|
/*
|
2021-06-13 19:07:40 -04:00
|
|
|
* Copyright © 2020 Luciano Iam <oss@lucianoiam.com>
|
2020-05-29 05:37:34 -04:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2020-06-14 07:04:43 -04:00
|
|
|
import { ChildComponent } from '../base/component.js';
|
2020-05-29 05:37:34 -04:00
|
|
|
import { StateNode } from '../base/protocol.js';
|
2020-06-14 06:10:30 -04:00
|
|
|
import Strip from './strip.js';
|
2020-05-29 05:37:34 -04:00
|
|
|
|
2020-06-14 07:04:43 -04:00
|
|
|
export default class Mixer extends ChildComponent {
|
2020-05-29 05:37:34 -04:00
|
|
|
|
2020-06-14 07:04:43 -04:00
|
|
|
constructor (parent) {
|
|
|
|
super(parent);
|
2020-05-29 05:37:34 -04:00
|
|
|
this._strips = {};
|
|
|
|
this._ready = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
get ready () {
|
|
|
|
return this._ready;
|
|
|
|
}
|
|
|
|
|
|
|
|
get strips () {
|
|
|
|
return Object.values(this._strips);
|
|
|
|
}
|
|
|
|
|
|
|
|
getStripByName (name) {
|
|
|
|
name = name.trim().toLowerCase();
|
|
|
|
return this.strips.find(strip => strip.name.trim().toLowerCase() == name);
|
|
|
|
}
|
|
|
|
|
|
|
|
handle (node, addr, val) {
|
|
|
|
if (node.startsWith('strip')) {
|
|
|
|
if (node == StateNode.STRIP_DESCRIPTION) {
|
|
|
|
this._strips[addr] = new Strip(this, addr, val);
|
2020-06-14 06:34:27 -04:00
|
|
|
this.notifyPropertyChanged('strips');
|
2020-06-01 05:11:01 -04:00
|
|
|
return true;
|
2020-05-29 05:37:34 -04:00
|
|
|
} else {
|
|
|
|
const stripAddr = [addr[0]];
|
|
|
|
if (stripAddr in this._strips) {
|
2020-06-01 05:11:01 -04:00
|
|
|
return this._strips[stripAddr].handle(node, addr, val);
|
2020-05-29 05:37:34 -04:00
|
|
|
}
|
|
|
|
}
|
2020-05-30 13:08:27 -04:00
|
|
|
} else {
|
|
|
|
// all initial strip description messages have been received at this point
|
|
|
|
if (!this._ready) {
|
|
|
|
this.updateLocal('ready', true);
|
2020-06-01 05:11:01 -04:00
|
|
|
// passthrough by allowing to return false
|
2020-05-30 13:08:27 -04:00
|
|
|
}
|
2020-05-29 05:37:34 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|