UNPKG

shimi

Version:

A JS framework for building complex MIDI applications

145 lines (144 loc) 6.12 kB
import { IMetronome } from './Metronome'; import { ClockChildFinishedEvent, IClockChild } from './Clock'; /** * @category Timing */ declare class CueBase implements IClockChild { /** Provides a way of identifying cues so they can be easily retrieved later. */ get ref(): string; set ref(value: string); private _ref; /** Signifies whether the Cue has stopped. */ get isFinished(): boolean; private _isFinished; /** This event fires when the Cue finishes. This is included because it's part of the IClockChild definition. In practice, there's no reason to use it though, since the whole point of a Cue object is that it's already lining up some action to be performed once it finishes. */ get finished(): ClockChildFinishedEvent; private _finished; /** The action to perform once the cue has finished waiting. */ get action(): () => void; private _action; /** * @param action The action to perform once the cue has finished waiting. */ constructor(action: () => void); /** * This method is intended to be called by a clock to provide regular updates. It should not be called by consumers of the library. * @param deltaMs How many milliseconds have passed since the last update cycle. */ update(deltaMs: number): void; /** Calling this tells the Cue to stop whatever it's doing and that it will no longer be used. */ finish(): void; /** * Provides a way for setting the ref through a chained function call. For example: * * ``` * clock.addChild(Cue.afterMs(100, console.log('Hello!')).withRef('cue')); * ``` * * @param ref The ref to set on the object. * @returns The calling object. */ withRef(ref: string): IClockChild; } /** * The MsCue defines some action which should be performed after x number of milliseconds have passed. * * @category Timing */ export declare class MsCue extends CueBase { /** Returns the name of this type. This can be used rather than instanceof which is sometimes unreliable. */ get typeName(): string; /** The number of milliseconds to wait before performing some action. */ get msCount(): number; private _msCount; private _countPassed; /** * @param msCount The number of milliseconds to wait before performing some action. * @param action The action to perform once the cue has finished waiting. */ constructor(msCount: number, action: () => void); /** * This method is intended to be called by a clock to provide regular updates. It should not be called by consumers of the library. * @param deltaMs How many milliseconds have passed since the last update cycle. */ update(deltaMs: number): void; } /** * The ConditionalCue defines some action which should be performed once some condition has been met. * * @category Timing */ export declare class ConditionalCue extends CueBase { /** Returns the name of this type. This can be used rather than instanceof which is sometimes unreliable. */ get typeName(): string; /** The condition which must be satisfied before performing some action. */ get condition(): () => boolean; private _condition; /** * @param condition The condition which must be satisfied before performing some action. * @param action The action to perform once the cue has finished waiting. */ constructor(condition: () => boolean, action: () => void); /** * This method is intended to be called by a clock to provide regular updates. It should not be called by consumers of the library. * @param deltaMs How many milliseconds have passed since the last update cycle. */ update(deltaMs: number): void; } /** * The BeatCue defines some action which should be performed after x number of beats has passed. * * @category Timing */ export declare class BeatCue extends CueBase { /** Returns the name of this type. This can be used rather than instanceof which is sometimes unreliable. */ get typeName(): string; /** The metronome to use for counting beats. */ get metronome(): IMetronome; private _metronome; /** The number of beats to wait before performing some action. */ get beatCount(): number; private _beatCount; private _beatsPassed; /** * @param metronome The metronome to use for counting beats. * @param beatCount The number of beats to wait before performing some action. * @param action The action to perform once the cue has finished waiting. */ constructor(metronome: IMetronome, beatCount: number, action: () => void); /** * This method is intended to be called by a clock to provide regular updates. It should not be called by consumers of the library. * @param deltaMs How many milliseconds have passed since the last update cycle. */ update(deltaMs: number): void; } /** * The Cue class contains static methods for slightly more nice and intuitive creation of cues. * * @category Timing */ export default class Cue { /** * Creates a new instance of ConditionalCue. * @param condition The condition which must be satisfied before performing some action. * @param action The action to perform once the cue has finished waiting. * @returns */ static when(condition: () => boolean, action: () => void): ConditionalCue; /** * Creates a new instance of MsCue. * @param msCount The number of milliseconds to wait before performing some action. * @param action The action to perform once the cue has finished waiting. * @returns */ static afterMs(msCount: number, action: () => void): MsCue; /** * Creates a new instance of BeatCue. * @param metronome The metronome to use for counting beats. * @param beatCount The number of beats to wait before performing some action. * @param action The action to perform once the cue has finished waiting. * @returns */ static afterBeats(metronome: IMetronome, beatCount: number, action: () => void): BeatCue; } export {};