UNPKG

reaper-osc

Version:
227 lines 8.13 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.SelectedTrackSend = exports.TrackSend = void 0; /** * Contains classes for track send routing controls * @module */ const Notify_1 = require("./Notify"); const Commands_1 = require("./Client/Commands"); /** A send from a specific track to another destination */ let TrackSend = class TrackSend { constructor(trackNumber, sendNumber, send) { this.trackNumber = trackNumber; this.sendNumber = sendNumber; 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:send:name': if (event.trackNumber === this.trackNumber && event.sendNumber === this.sendNumber) this._name = event.name; break; case 'track:send:volume': if (event.trackNumber === this.trackNumber && event.sendNumber === this.sendNumber) this._volume = event.volume; break; case 'track:send:volumeStr': if (event.trackNumber === this.trackNumber && event.sendNumber === this.sendNumber) this._volumeStr = event.volumeStr; break; case 'track:send:pan': if (event.trackNumber === this.trackNumber && event.sendNumber === this.sendNumber) this._pan = event.pan; break; case 'track:send:panStr': if (event.trackNumber === this.trackNumber && event.sendNumber === this.sendNumber) this._panStr = event.panStr; break; } } /** The destination 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.SetTrackSendPan(this.trackNumber, this.sendNumber, value)); this._pan = value; } /** * Sets the send 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.SetTrackSendVolume(this.trackNumber, this.sendNumber, 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') ], TrackSend.prototype, "_name", void 0); __decorate([ Notify_1.notify('volume') ], TrackSend.prototype, "_volume", void 0); __decorate([ Notify_1.notify('volumeStr') ], TrackSend.prototype, "_volumeStr", void 0); __decorate([ Notify_1.notify('pan') ], TrackSend.prototype, "_pan", void 0); __decorate([ Notify_1.notify('panStr') ], TrackSend.prototype, "_panStr", void 0); TrackSend = __decorate([ Notify_1.notifyOnPropertyChanged ], TrackSend); exports.TrackSend = TrackSend; /** A send from the OSC device's currently selected track */ let SelectedTrackSend = class SelectedTrackSend { constructor(sendNumber, send) { this.sendNumber = sendNumber; 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:send:name': if (event.sendNumber === this.sendNumber) this._name = event.name; break; case 'selectedTrack:send:volume': if (event.sendNumber === this.sendNumber) this._volume = event.volume; break; case 'selectedTrack:send:volumeStr': if (event.sendNumber === this.sendNumber) this._volumeStr = event.volumeStr; break; case 'selectedTrack:send:pan': if (event.sendNumber === this.sendNumber) this._pan = event.pan; break; case 'selectedTrack:send:panStr': if (event.sendNumber === this.sendNumber) this._panStr = event.panStr; break; } } /** The destination 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.SetSelectedTrackSendPan(this.sendNumber, value)); this._pan = value; } /** * Sets the send 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.SetSelectedTrackSendVolume(this.sendNumber, 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') ], SelectedTrackSend.prototype, "_name", void 0); __decorate([ Notify_1.notify('volume') ], SelectedTrackSend.prototype, "_volume", void 0); __decorate([ Notify_1.notify('volumeStr') ], SelectedTrackSend.prototype, "_volumeStr", void 0); __decorate([ Notify_1.notify('pan') ], SelectedTrackSend.prototype, "_pan", void 0); __decorate([ Notify_1.notify('panStr') ], SelectedTrackSend.prototype, "_panStr", void 0); SelectedTrackSend = __decorate([ Notify_1.notifyOnPropertyChanged ], SelectedTrackSend); exports.SelectedTrackSend = SelectedTrackSend; //# sourceMappingURL=Send.js.map