shimi
Version:
A JS framework for building complex MIDI applications
54 lines (53 loc) • 2.54 kB
TypeScript
import PropertyTracker from './PropertyTracker';
/**
* The Note class models a single musical note which can be started and stopped, to be played at a specific pitch & velocity, on a specific channel.
*
* @category Midi IO
*/
export default class Note {
/** Returns the name of this type. This can be used rather than instanceof which is sometimes unreliable. */
get typeName(): string;
/**
* The MIDI pitch of the note, valid values range from 0 - 127.
*
* WARNING! Even though the pitch value can be set at any time, you should avoid setting it once the note has already started being played.
*/
get pitch(): number;
set pitch(value: number);
private _pitch;
/** Tracks changes to the note velocity. */
velocityTracker: PropertyTracker<number>;
/** The note's velocity (loudness), valid values range from 0 - 127. The setter for this rounds the value to the nearest integer so that note velocity tweening will not recognise tiny marginal changes and send out unnecessary aftertouch messages. */
get velocity(): number;
set velocity(value: number);
/**
* Tracks changes to whether the note is playing.
*
* By default the state is on and dirty.
*/
onTracker: PropertyTracker<boolean>;
/** Is the note playing. */
get on(): boolean;
set on(value: boolean);
/**
* Which channel should the note play on, valid values range from 0 - 15.
*
* WARNING! Even though the channel value can be set at any time, you should avoid setting it once the note has already started being played.
*/
get channel(): number;
set channel(value: number);
private _channel;
/** Provides way of identifying notes so they can be easily retrieved later. */
ref: string;
/**
* @param pitch The MIDI pitch of the note, valid values range from 0 - 127. Can also take pitch names, see the [pitch](../functions/pitch.html) method for more information.
* @param velocity The note's velocity (loudness), valid values range from 0 - 127.
* @param channel Which channel should the note play on, valid values range from 0 - 15.
* @param ref Provides way of identifying notes so they can be easily retrieved later.
*/
constructor(pitch: number | string, velocity: number, channel: number, ref?: string);
/** Sets on = true, returns whether this changed the note's state. */
start(): boolean;
/** Sets on = false, returns whether this changed the note's state. */
stop(): boolean;
}