shimi
Version:
A JS framework for building complex MIDI applications
68 lines (67 loc) • 2.77 kB
TypeScript
import { ClockChildFinishedEvent, IClockChild } from './Clock';
import { IMetronome } from './Metronome';
import { IMidiOut } from './MidiOut';
/**
* The TickSender is used for sending MIDI clock messages out, so that other MIDI devices can stay in sync with a shimi metronome.
*/
export default class TickSender implements IClockChild {
/** Returns the name of this type. This can be used rather than instanceof which is sometimes unreliable. */
get typeName(): string;
/**
* The metronome object which the TickSender sends out clock messages for.
*/
get metronome(): IMetronome;
set metronome(value: IMetronome);
private _metronome;
/**
* The midi out object which the TickSender sends clock messages to.
*/
get midiOut(): IMidiOut;
set midiOut(value: IMidiOut);
private _midiOut;
/** How many ticks occur per quarter note. */
get ticksPerQuarterNote(): number;
set ticksPerQuarterNote(value: number);
private _ticksPerQuarterNote;
/**
* @param metronome The metronome object which the TickSender sends out clock messages for.
* @param midiOut The midi out object which the TickSender sends clock messages to.
* @param ticksPerQuarterNote How many ticks occur per quarter note.
*/
constructor(metronome: IMetronome, midiOut: IMidiOut, ticksPerQuarterNote?: number);
private _onPositionChanged;
private _onStarted;
private _onContinued;
private _onStopped;
private _unsubscribeFromMetronomeEvents;
private _subscribeToMetronomeEvents;
/** Provides a way of identifying tick senders so they can be easily retrieved later */
get ref(): string;
set ref(value: string);
private _ref;
/**
* Provides a way for setting the ref through a chained function call. For example:
*
* ```
* clock.addChild(new TickSender(metronome, midiOut).withRef('ticksender'));
* ```
*
* @param ref The ref to set on the object.
* @returns The calling object.
*/
withRef(ref: string): IClockChild;
/** Returns true if the TickSender has been instructed to stop everything by the `finish()` method. */
get isFinished(): boolean;
private _isFinished;
/** This event fires when the TickSender finishes. */
get finished(): ClockChildFinishedEvent;
private _finished;
/** Calling this tells the TickSender to stop whatever it's doing and that it will no longer be used. */
finish(): void;
/**
* This method is intended to be called by a clock to provide regular updates. It should be called by consumers of the library.
* @param msDelta How many milliseconds have passed since the last update cycle.
* @returns
*/
update(msDelta: number): void;
}