shimi
Version:
A JS framework for building complex MIDI applications
60 lines (59 loc) • 2.5 kB
TypeScript
import { ClockChildFinishedEvent, IClockChild } from './Clock';
import { IMetronome } from './Metronome';
import { IMidiIn } from './MidiIn';
/**
* The TickReceiver class allows a shimi IMetronome instance to be updated by ticks coming from a MIDI input, rather than it updating itself.
*
* @category Timing
*/
export default class TickReceiver implements IClockChild {
/** Returns the name of this type. This can be used rather than instanceof which is sometimes unreliable. */
get typeName(): string;
/** The MIDI In object which tick events are received from. */
get midiIn(): IMidiIn;
set midiIn(value: IMidiIn);
private _midiIn;
/** The metronome which gets updated each cycle. */
get metronome(): IMetronome;
set metronome(value: IMetronome);
private _metronome;
/** How many ticks occur per quarter note. */
get ticksPerQuarterNote(): number;
set ticksPerQuarterNote(value: number);
private _ticksPerQuarterNote;
constructor(midiIn: IMidiIn, metronome: IMetronome, ticksPerQuarterNote?: number);
/** Returns the number of ticks that have been received since the last update cycle. */
get newTicksReceived(): number;
private _newTicksReceived;
private _onMidiTick;
private _onSongPosition;
/** Provides a way of identifying TickReceivers 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 TickReceiver(midiInput, metronome, 24).withRef('tickReceiver'));
* ```
*
* @param ref The ref to set on the object.
* @returns The calling object.
*/
withRef(ref: string): IClockChild;
/** Returns true if the Metronome has been instructed to stop everything by the `finish()` method. */
get isFinished(): boolean;
private _isFinished;
/** This event fires when the arpeggiator finishes. */
get finished(): ClockChildFinishedEvent;
private _finished;
/** Calling this tells the TickReceiver 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;
}