ez-web-audio
Version:
Making the Web Audio API super EZ since 2024.
52 lines • 2.75 kB
TypeScript
import { default as frequencyMap } from './utils/frequency-map';
export type NoteLetter = 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G';
export type Accidental = '' | 'b' | '#';
export type Octave = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8';
export type AcceptableNote = keyof typeof frequencyMap;
type Constructor<T = any> = new (...args: any[]) => T;
export interface IMusicallyAware {
letter: NoteLetter;
accidental: Accidental;
octave: Octave;
name: string;
frequency: number;
identifier: AcceptableNote;
}
export declare function MusicallyAware<TBase extends Constructor>(Base: TBase): {
new (...args: any[]): {
[x: string]: any;
/**
* @property letter For note `Ab5`, this would be `A`.
*/
letter: NoteLetter;
/**
* @property accidental For note `Ab5`, this would be `b`.
*/
accidental: Accidental;
/**
* @property octave For note `Ab5`, this would be `5`.
*/
octave: Octave;
/**
* @property name Computed property. Value is `${letter}` or `${letter}${accidental}` if accidental exists.
* @todo 'type' letter + accidental
*/
readonly name: string;
/**
* @property frequency Computed property. The frequency of the note in hertz. Calculated by
* comparing western musical standards (a standard piano) and the note
* identifier (i.e. `Ab1`). If this property is set directly, all other
* properties are updated to reflect the provided frequency.
*/
frequency: number;
/**
* @property identifier Computed property. Value is `${letter}${octave}` or
* `${letter}${accidental}${octave}` if accidental exists. If this property
* is set directly, all other properties are updated to reflect the provided
* identifier.
*/
identifier: "C0" | "Db0" | "D0" | "Eb0" | "E0" | "F0" | "Gb0" | "G0" | "Ab0" | "A0" | "Bb0" | "B0" | "C1" | "Db1" | "D1" | "Eb1" | "E1" | "F1" | "Gb1" | "G1" | "Ab1" | "A1" | "Bb1" | "B1" | "C2" | "Db2" | "D2" | "Eb2" | "E2" | "F2" | "Gb2" | "G2" | "Ab2" | "A2" | "Bb2" | "B2" | "C3" | "Db3" | "D3" | "Eb3" | "E3" | "F3" | "Gb3" | "G3" | "Ab3" | "A3" | "Bb3" | "B3" | "C4" | "Db4" | "D4" | "Eb4" | "E4" | "F4" | "Gb4" | "G4" | "Ab4" | "A4" | "Bb4" | "B4" | "C5" | "Db5" | "D5" | "Eb5" | "E5" | "F5" | "Gb5" | "G5" | "Ab5" | "A5" | "Bb5" | "B5" | "C6" | "Db6" | "D6" | "Eb6" | "E6" | "F6" | "Gb6" | "G6" | "Ab6" | "A6" | "Bb6" | "B6" | "C7" | "Db7" | "D7" | "Eb7" | "E7" | "F7" | "Gb7" | "G7" | "Ab7" | "A7" | "Bb7" | "B7" | "C8" | "Db8" | "D8" | "Eb8";
};
} & TBase;
export {};
//# sourceMappingURL=musical-identity.d.ts.map