UNPKG

ez-web-audio

Version:

Making the Web Audio API super EZ since 2024.

68 lines 3.02 kB
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; /** * The note letter (A-G). For note "Ab5", this would be "A". */ letter: NoteLetter; /** * The accidental: "" (natural), "b" (flat), or "#" (sharp). * For note "Ab5", this would be "b". */ accidental: Accidental; /** * The octave (0-8). For note "Ab5", this would be "5". */ octave: Octave; /** * The note name without octave (e.g., "A" or "Ab"). * Computed from letter and accidental. */ readonly name: string; /** * The frequency of the note in hertz. * * Computed from the note identifier using standard piano frequencies. * Setting this value updates all other properties to match. * * @example * ```typescript * note.frequency = 440 // Sets to A4 * console.log(note.identifier) // "A4" * ``` */ frequency: number; /** * The full note identifier (e.g., "A4", "Bb3", "C#5"). * * Computed from letter, accidental, and octave. * Setting this value updates all other properties to match. * * @example * ```typescript * note.identifier = 'Bb3' * console.log(note.letter) // "B" * console.log(note.accidental) // "b" * console.log(note.octave) // "3" * console.log(note.frequency) // 233.08 * ``` */ 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