UNPKG

reaper-osc

Version:
74 lines (73 loc) 2.63 kB
/// <reference types="node" /> /** * Stateless OSC client for communicating with Reaper * @module */ import { EventEmitter } from 'events'; import { OscMessage } from '../Messages'; import { ReaperOscEvent } from './Events'; import { ReaperOscCommand } from './Commands'; import { ReaperConfiguration } from '../Config'; export declare function parseMessage(msg: OscMessage): ReaperOscEvent; export interface ReaperOscClient { on(event: 'message', listener: (event: ReaperOscEvent) => void): this; on(event: 'rawMessage', listener: (message: OscMessage) => void): this; once(event: 'message', listener: (event: ReaperOscEvent) => void): this; once(event: 'rawMessage', listener: (message: OscMessage) => void): this; off(event: 'message', listener: (event: ReaperOscEvent) => void): this; off(event: 'rawMessage', listener: (message: OscMessage) => void): this; emit(event: 'message', oscEvent: ReaperOscEvent): boolean; emit(event: 'rawMessage', message: OscMessage): boolean; } /** * A stateless OSC client for communicating with Reaper. * * Translates incoming OSC messages into strongly typed events, and accepts * strongly typed commands for sending to Reaper. Does not maintain any state * about track properties, transport, or FX — use {@link Reaper} for that. * * @example * ```typescript * const client = new ReaperOscClient(); * await client.start(); * * // Receive typed events * client.on('message', event => { * switch (event.type) { * case 'track:mute': * console.log(`Track ${event.trackNumber} muted: ${event.muted}`); * break; * case 'transport:play': * console.log(`Playing: ${event.playing}`); * break; * } * }); * * // Send typed commands * client.send({ type: 'transport:play' }); * client.send({ type: 'track:mute', trackNumber: 3, muted: true }); * ``` */ export declare class ReaperOscClient extends EventEmitter { private readonly _osc; private readonly _log; private _isReady; constructor(config?: ReaperConfiguration); /** Indicates whether OSC is ready to send and receive messages */ get isReady(): boolean; /** * Send a typed command to Reaper. * @param command The command to send */ send(command: ReaperOscCommand): void; /** * Send a raw OSC message to Reaper. * @param message The OSC message to send */ sendRaw(message: OscMessage): void; /** Open the OSC port and start listening for messages */ start(): Promise<void>; /** Stop listening for OSC messages */ stop(): Promise<void>; private initOsc; }