UNPKG

reaper-osc

Version:
151 lines 5.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.LastMarker = exports.Marker = void 0; /** * Contains classes for Reaper markers * @module */ const Notify_1 = require("./Notify"); const Commands_1 = require("./Client/Commands"); /** A marker in the current device marker bank */ let Marker = class Marker { /** * @param slotIndex The 1-based slot index within the current device marker bank * @param send A callback used to send typed commands to Reaper */ constructor(slotIndex, _send) { this.slotIndex = slotIndex; this._send = _send; this._name = ''; /** The user-assigned marker number (as shown in Reaper's UI), or empty string if not yet populated */ this._number = ''; this._time = 0; } /** The marker's name */ get name() { return this._name; } /** * The user-assigned marker number (as shown in Reaper's UI). * This is a string because Reaper sends it as a string (e.g. "1", "2"). * Empty string if not yet populated. */ get number() { return this._number; } /** The marker's time position in seconds */ get time() { return this._time; } /** * Handle a typed incoming event * @param event The event to handle */ handleEvent(event) { switch (event.type) { case 'marker:name': if (event.slotIndex === this.slotIndex) this._name = event.name; break; case 'marker:number': if (event.slotIndex === this.slotIndex) this._number = event.number; break; case 'marker:time': if (event.slotIndex === this.slotIndex) this._time = event.time; break; } } // eslint-disable-next-line @typescript-eslint/no-unused-vars onPropertyChanged(property, callback) { throw new Error('not implemented'); } /** * Rename this marker. Uses write-by-ID: the user-assigned marker number from {@link number}. * @param name The new name for the marker */ rename(name) { this._send(Commands_1.SetMarkerName(parseInt(this._number), name)); } /** * Move this marker to a new time position. Uses write-by-ID. * Note: moving a marker may change its bank slot index on the next sync. * @param time The new time position in seconds */ setTime(time) { this._send(Commands_1.SetMarkerTime(parseInt(this._number), time)); } /** * Change the user-assigned number of this marker. Uses write-by-ID. * @param number The new user-assigned marker number */ setNumber(number) { this._send(Commands_1.SetMarkerNumber(parseInt(this._number), number)); } }; __decorate([ Notify_1.notify('name') ], Marker.prototype, "_name", void 0); __decorate([ Notify_1.notify('number') ], Marker.prototype, "_number", void 0); __decorate([ Notify_1.notify('time') ], Marker.prototype, "_time", void 0); Marker = __decorate([ Notify_1.notifyOnPropertyChanged ], Marker); exports.Marker = Marker; /** The most recently passed marker during playback */ let LastMarker = class LastMarker { constructor() { this._name = ''; this._number = ''; this._time = 0; } /** The marker's name */ get name() { return this._name; } /** * The user-assigned marker number (as shown in Reaper's UI). * Empty string if no marker has been passed yet. */ get number() { return this._number; } /** The marker's time position in seconds */ get time() { return this._time; } /** * Handle a typed incoming event * @param event The event to handle */ handleEvent(event) { switch (event.type) { case 'lastMarker:name': this._name = event.name; break; case 'lastMarker:number': this._number = event.number; break; case 'lastMarker:time': this._time = event.time; break; } } // eslint-disable-next-line @typescript-eslint/no-unused-vars onPropertyChanged(property, callback) { throw new Error('not implemented'); } }; __decorate([ Notify_1.notify('name') ], LastMarker.prototype, "_name", void 0); __decorate([ Notify_1.notify('number') ], LastMarker.prototype, "_number", void 0); __decorate([ Notify_1.notify('time') ], LastMarker.prototype, "_time", void 0); LastMarker = __decorate([ Notify_1.notifyOnPropertyChanged ], LastMarker); exports.LastMarker = LastMarker; //# sourceMappingURL=Marker.js.map