shimi
Version:
A JS framework for building complex MIDI applications
30 lines (29 loc) • 1.47 kB
TypeScript
declare global {
interface Number {
near(target: number | string): number;
get octave(): number;
toOctave(targetOctave: number): number;
}
}
/**
* This function is provided as an extension of the number prototype, so that once you've got a pitch, you can easily find another pitch of the same pitch class, but within a different octave.
*
* For example: `shimi.pitch('C4').near(shimi.pitch('B5'))` will return the same value as if you'd just used `shimi.pitch('C6')`.
*
* In the case where the target pitch is exactly halfway between 2 possible pitches, this function will return the one that is closest to the current pitch value. For example: `shimi.pitch('C2').near(shimi.pitch('F#5'))` returns the pitch value for C5 rather than C6.
*
* @param target The target pitch which the returned value should be near to
* @returns
*/
export declare function near(target: number | string): number;
/**
* This getter is provided as an extension of the number prototype, so that once you've got a pitch, you can easily identify which octave it's within.
* @returns
*/
export declare function octave(): number;
/**
* This function is provided as an extension of the number prototype, so that once you've got a pitch, you can easily translate it over to a particular octave.
* @param targetOctave The target octave which the new pitch should be within.
* @returns
*/
export declare function toOctave(targetOctave: number): number;