import { Note } from '../types.js'; export interface MeasureData { notes: Array; duration: string; name?: string; } export interface NormalizedMeasureData { notes: Set; duration: string; name?: string; } /** * @class Measure * @description Represents a single measure as part of a musical score in musical notation.ds * @param {Number} maxDuration=0 Max duration of the measure(determined by time signature) */ export declare class Measure { _duration: string; constructor(maxDuration?: number); _maxDuration: number; /** * Returns the maximum sum of durations for the measure as a number, * where each unit is 1/64 bit. * @returns {number} * @readonly */ get maxDuration(): number; _data: Array; /** * Returns the data of the measure - an array of objects where each * object has a set of notes and the duration for those notes. * @returns {Array} */ get data(): Array; /** * Returns the number of sixteenth notes in the measure. * @returns {number} */ get length(): number; static measureDataToString(notesMember: NormalizedMeasureData): string; static parseMeasureNoteMemberString(str: string): MeasureData; static stringToMeasure({ str, maxDuration }: { str: string; maxDuration: number; }): Measure; /** * Returns a deep clone of the measure. * @returns {Measure} */ clone(): Measure; /** * Returns the duration left for notes in the measure. * @param {number} position=this.data.length * @returns {number} */ durationLeft(position?: number): number; /** * Adds a note to the measure at some position. * @param {Object} data * @param {string} data.note raw note representation. * @param {string} data.duration * @param {number} position The position in the data to add the note to. * @returns {boolean} */ addNote({ note, duration }: { note: Note; duration: string; }, position: number): boolean; /** * Adds notes to the note set at the position. * @param {Array} notes An array of raw notes. * @param {string} duration * @param {number} position The position in the data to add the notes to. * @returns {*} */ addNotes({ notes, duration }: MeasureData, position: number): boolean; /** * Adds notes to the measure plus a name that represents the chord and is saved in * the data at the position as name * @param notes * @param name * @param duration * @param position * @return {boolean} * @example * measure.addChord({ * notes: ['C3', 'E3', 'G3'], * name: 'C Major', * duration: '4n' * }, 0) // Adds a C major chord at the start of the measure. */ addChord({ notes, name, duration }: MeasureData, position: number): boolean; /** * Delete note at the position. * @param {string} note raw note. * @param {number} position The position in the data to delete the note at. * @returns {boolean} */ deleteNote(note: string, position: number): boolean; /** * Deletes notes from the noteset at the position. * @param {Array} notes An array of raw notes. * @param {number} position The position in the data to delete the notes at. * @returns {*} */ deleteNotes(notes: Array, position: number): boolean; /** * Delete member from the measure's data - removes all the notes from it * and initializes a new data member with the measure's duration. * @param {number} position Position of the member to delete. * @return {boolean} */ deleteMember(position: number): boolean; /** * Returns true if the duration has space, else false. * @param duration * @returns {boolean} */ isFull(duration: string): boolean; /** * Returns a new measure where all the notes are transposed by the interval. * @param {number} interval Interval to transpose by. * @returns {Measure} */ transpose(interval: number): Measure; /** * Removes all the data from the measure. * @returns {boolean} */ clear(): boolean; toString(): string; /** * Creates a slot for the next notes that will be added in the measure if there is space. * Should not be called as it's called automatically when needed. * @param {number} position Position to initialize the next notes to. * @param {string} duration duration to create for the notes * @private */ private initNext; /** * Checks whether a new data member can be added at a certain position in the measure. * @param {number} position The position to check for. * @param {string} duration duration of new notes * @returns {boolean} */ private canInsertToMeasure; }