UNPKG

reaper-osc

Version:
96 lines (95 loc) 3.77 kB
/** * Contains classes for controlling Reaper via OSC * @module */ import { OscMessage } from './Messages'; import { Track } from './Tracks'; import { Transport } from './Transport'; import { INotifyPropertyChanged } from './Notify'; /** * Allows control of an instance of Reaper via OSC. * * @example * ```typescript * // Create an instance of Reaper using default settings * const reaper = new Reaper(); * // Start OSC * reaper.startOsc(); * // Give the port a chance to open, then tell Reaper to start playback * setTimeout(() => {reaper.transport.play();}, 100); *``` */ export declare class Reaper implements INotifyPropertyChanged { private _isMetronomeEnabled; private readonly _afterMessageReceived; private readonly _handlers; private _isReady; private readonly _log; private readonly _masterTrack; private readonly _osc; private readonly _tracks; private readonly _transport; constructor(config?: ReaperConfiguration); /** Indicates whether the metronome is enabled */ get isMetronomeEnabled(): boolean; /** Indicates whether OSC is ready to send and receive messages */ get isReady(): boolean; /** The master track */ get master(): Track; onPropertyChanged(property: string, callback: () => void): () => void; /** * Triggers the action `Control surface: Refresh all surfaces` (Command ID: 41743) */ refreshControlSurfaces(): void; /** * Send a message to Reaper via OSC. Messages may not be sent while {@link Reaper.isReady} is false. * @param message The OSC message to be sent */ sendOscMessage(message: OscMessage): void; /** Open the OSC port and start listening for messages */ start(): Promise<void>; /** Stop listening for OSC messages */ stop(): Promise<void>; /** Toggle the metronome on or off */ toggleMetronome(): void; /** The current bank of tracks */ get tracks(): ReadonlyArray<Track>; /** Transport controls */ get transport(): Transport; /** * Trigger a Reaper action * @param commandId The Command ID of the action to be triggered. * @param value The value to send for the action. Note that some actions expect the CC value (0-127) while others expect a decimal value between 0 and 1. * @example * ```typescript * // Trigger action 'Track: Toggle mute for master track' * reaper.triggerAction(14); * // Trigger SWS Extension action 'SWS/S&M: Live Config #1 - Apply config (MIDI/OSC only)' with a CC value of 3, selects config #3 * reaper.triggerAction('_S&M_LIVECFG_APPLY1', 3); * // Trigger action 'Track: Set volume for track 01 (MIDI CC/OSC only)' with a value of 0.75, sets volume of track 1 to +0.0dB * reaper.triggerAction(20, 0.7156) * ``` */ triggerAction(commandId: number | string, value?: number | null): void; private initHandlers; private initOsc; } export declare class ReaperConfiguration { afterMessageReceived: ((message: OscMessage, handled: boolean) => void) | null; /** The address to listen for Reaper OSC messages on */ localAddress: string; /** The port to listen for Reaper OSC messages on */ localPort: number; /** Function for logging messages. Defaults to logging to console */ log: Logger; /** Number of FX per track */ numberOfFx: number; /** Number of tracks per bank */ numberOfTracks: number; /** The address to send Reaper OSC messages to */ remoteAddress: string; /** The port to send Reaper OSC messages to */ remotePort: number; } export declare type LogLevel = 'debug' | 'info' | 'warn' | 'error'; export declare type Logger = (level: LogLevel, message: string, ...optionalParams: any[]) => void;