UNPKG

reaper-osc

Version:
227 lines 8.31 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.SelectedTrackReceive = exports.TrackReceive = void 0; /** * Contains classes for track receive routing controls * @module */ const Notify_1 = require("./Notify"); const Commands_1 = require("./Client/Commands"); /** A receive on a specific track from another source */ let TrackReceive = class TrackReceive { constructor(trackNumber, receiveNumber, send) { this.trackNumber = trackNumber; this.receiveNumber = receiveNumber; this._name = ''; this._volume = 0; this._volumeStr = ''; this._pan = 0; this._panStr = ''; this._send = send; } /** * Handle a typed incoming event * @param event The event to handle */ handleEvent(event) { switch (event.type) { case 'track:recv:name': if (event.trackNumber === this.trackNumber && event.receiveNumber === this.receiveNumber) this._name = event.name; break; case 'track:recv:volume': if (event.trackNumber === this.trackNumber && event.receiveNumber === this.receiveNumber) this._volume = event.volume; break; case 'track:recv:volumeStr': if (event.trackNumber === this.trackNumber && event.receiveNumber === this.receiveNumber) this._volumeStr = event.volumeStr; break; case 'track:recv:pan': if (event.trackNumber === this.trackNumber && event.receiveNumber === this.receiveNumber) this._pan = event.pan; break; case 'track:recv:panStr': if (event.trackNumber === this.trackNumber && event.receiveNumber === this.receiveNumber) this._panStr = event.panStr; break; } } /** The source track name */ get name() { return this._name; } // eslint-disable-next-line @typescript-eslint/no-unused-vars onPropertyChanged(property, callback) { throw new Error('not implemented'); } /** A floating-point value between -1 and 1 that indicates the pan position */ get pan() { return this._pan; } /** Human-readable pan position string (e.g. "50%R") */ get panStr() { return this._panStr; } /** * Sets the pan * @param value A floating-point value between -1 and 1, where -1 is 100% left and 1 is 100% right */ setPan(value) { if (value < -1 || value > 1) { throw new RangeError('Must be between -1 and 1'); } this._send(Commands_1.SetTrackReceivePan(this.trackNumber, this.receiveNumber, value)); this._pan = value; } /** * Sets the receive volume fader position * @param value A floating-point value between 0 and 1, where 0 is silent and 1 is unity (0 dB) */ setVolume(value) { if (value < 0 || value > 1) { throw new RangeError('Must be between 0 and 1'); } this._send(Commands_1.SetTrackReceiveVolume(this.trackNumber, this.receiveNumber, value)); this._volume = value; } /** A floating-point value between 0 and 1 that indicates the fader position */ get volume() { return this._volume; } /** Human-readable volume string (e.g. "0.00 dB") */ get volumeStr() { return this._volumeStr; } }; __decorate([ Notify_1.notify('name') ], TrackReceive.prototype, "_name", void 0); __decorate([ Notify_1.notify('volume') ], TrackReceive.prototype, "_volume", void 0); __decorate([ Notify_1.notify('volumeStr') ], TrackReceive.prototype, "_volumeStr", void 0); __decorate([ Notify_1.notify('pan') ], TrackReceive.prototype, "_pan", void 0); __decorate([ Notify_1.notify('panStr') ], TrackReceive.prototype, "_panStr", void 0); TrackReceive = __decorate([ Notify_1.notifyOnPropertyChanged ], TrackReceive); exports.TrackReceive = TrackReceive; /** A receive on the OSC device's currently selected track */ let SelectedTrackReceive = class SelectedTrackReceive { constructor(receiveNumber, send) { this.receiveNumber = receiveNumber; this._name = ''; this._volume = 0; this._volumeStr = ''; this._pan = 0; this._panStr = ''; this._send = send; } /** * Handle a typed incoming event * @param event The event to handle */ handleEvent(event) { switch (event.type) { case 'selectedTrack:recv:name': if (event.receiveNumber === this.receiveNumber) this._name = event.name; break; case 'selectedTrack:recv:volume': if (event.receiveNumber === this.receiveNumber) this._volume = event.volume; break; case 'selectedTrack:recv:volumeStr': if (event.receiveNumber === this.receiveNumber) this._volumeStr = event.volumeStr; break; case 'selectedTrack:recv:pan': if (event.receiveNumber === this.receiveNumber) this._pan = event.pan; break; case 'selectedTrack:recv:panStr': if (event.receiveNumber === this.receiveNumber) this._panStr = event.panStr; break; } } /** The source track name */ get name() { return this._name; } // eslint-disable-next-line @typescript-eslint/no-unused-vars onPropertyChanged(property, callback) { throw new Error('not implemented'); } /** A floating-point value between -1 and 1 that indicates the pan position */ get pan() { return this._pan; } /** Human-readable pan position string (e.g. "50%R") */ get panStr() { return this._panStr; } /** * Sets the pan * @param value A floating-point value between -1 and 1, where -1 is 100% left and 1 is 100% right */ setPan(value) { if (value < -1 || value > 1) { throw new RangeError('Must be between -1 and 1'); } this._send(Commands_1.SetSelectedTrackReceivePan(this.receiveNumber, value)); this._pan = value; } /** * Sets the receive volume fader position * @param value A floating-point value between 0 and 1, where 0 is silent and 1 is unity (0 dB) */ setVolume(value) { if (value < 0 || value > 1) { throw new RangeError('Must be between 0 and 1'); } this._send(Commands_1.SetSelectedTrackReceiveVolume(this.receiveNumber, value)); this._volume = value; } /** A floating-point value between 0 and 1 that indicates the fader position */ get volume() { return this._volume; } /** Human-readable volume string (e.g. "0.00 dB") */ get volumeStr() { return this._volumeStr; } }; __decorate([ Notify_1.notify('name') ], SelectedTrackReceive.prototype, "_name", void 0); __decorate([ Notify_1.notify('volume') ], SelectedTrackReceive.prototype, "_volume", void 0); __decorate([ Notify_1.notify('volumeStr') ], SelectedTrackReceive.prototype, "_volumeStr", void 0); __decorate([ Notify_1.notify('pan') ], SelectedTrackReceive.prototype, "_pan", void 0); __decorate([ Notify_1.notify('panStr') ], SelectedTrackReceive.prototype, "_panStr", void 0); SelectedTrackReceive = __decorate([ Notify_1.notifyOnPropertyChanged ], SelectedTrackReceive); exports.SelectedTrackReceive = SelectedTrackReceive; //# sourceMappingURL=Receive.js.map