shimi
Version:
A JS framework for building complex MIDI applications
99 lines (98 loc) • 4.68 kB
TypeScript
import Chord from './Chord';
import ChordProgression, { ChordProgressionChord } from './ChordProgression';
import { IMetronome } from './Metronome';
import ShimiEvent, { ShimiEventData } from './ShimiEvent';
import { ClockChildFinishedEvent, IClockChild } from './Clock';
/**
* The ChordEventData extends ShimiEventData, and contains a chord which some object wants to notify others about.
*
* @category Chords & Scales
*/
export declare class ChordEventData<TSource> extends ShimiEventData<TSource> {
get chord(): Chord;
private _chord;
constructor(source: TSource, chord: Chord);
}
/**
* The ChordEvent class extends ShimiEvent, providing an object which can be subscribed to.
*
* It distributes events which point back to the source object that fired the event, and a ChordEventData object that contains the event information.
*
* @category Chords & Scales
*/
export declare class ChordEvent<TSource> extends ShimiEvent<ChordEventData<TSource>, TSource> {
}
/**
* The ChordProgressionPlayer facilitates the playing of a chord. It doesn't actually cause the generation of any note on/note off events. Instead it triggers events whenever the chord changes, allowing other objects to easily play/arpeggiate/do whatever they like over a series of changing chords.
*
* @category Chords & Scales
*/
export default class ChordProgressionPlayer implements IClockChild {
/** Returns the name of this type. This can be used rather than instanceof which is sometimes unreliable. */
get typeName(): string;
/** The chord progression to play */
get chordProgression(): ChordProgression;
set chordProgression(value: ChordProgression);
private _chordProgression;
/** The metronome which the player uses for tracking passed beats. */
get metronome(): IMetronome;
set metronome(value: IMetronome);
private _metronome;
/** How many beats in the chord progression to play for every beat that passes in actual time. For example: 1.5 means the chord progression is played 1.5 times faster than it would normally. */
get speed(): number;
set speed(value: number);
private _speed;
/** Which beat of the chord progression to start playing from. This allows for a chord progression player to begin playing a chord progression from half-way through for example. */
get startBeat(): number;
set startBeat(value: number);
private _startBeat;
/** How many beats should have passed before the chord progression player stops. The default value is null, meaning the chord progression player never stops, and continually loops playback of the chord progression. */
get beatCount(): number;
set beatCount(value: number);
private _beatCount;
/** How many beats have passed since the chord progression player started. */
get beatsPassed(): number;
private _beatsPassed;
/** Provides a way of identifying a chord progression player so that it can be easily retrieved later. */
get ref(): string;
set ref(value: string);
private _ref;
/** Returns true if the chord progression player has finished playing its chord progression. */
get isFinished(): boolean;
private _isFinished;
/** This event fires when the chord progression player finishes. */
get finished(): ClockChildFinishedEvent;
private _finished;
/** Returns the chord that is currently being played. */
get currentChord(): ChordProgressionChord;
private _currentChord;
/**
* The chordChanged event dispatches a new event data object each time the current chord changes.
*/
get chordChanged(): ChordEvent<ChordProgressionPlayer>;
private _chordChanged;
/**
* @param chordProgression The chord progression to play.
* @param metronome The metronome which the player uses for tracking passed beats.
*/
constructor(chordProgression: ChordProgression, metronome: IMetronome);
/**
* 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.
* @returns
*/
update(deltaMs: number): void;
/** Calling this tells the player 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(new ChordProgressionPlayer(chords, metronome).withRef('player'));
* ```
*
* @param ref The ref to set on the object.
* @returns The calling object.
*/
withRef(ref: string): IClockChild;
}