import EtudeError from "../error/EtudeError"; import Value from "./Value"; export default class Tempo { /* * Values based on the mean of the values given in * https://en.wikipedia.org/wiki/Tempo */ public static LARGHISSIMO = new Tempo(24, "Larghissimo"); public static GRAVE = new Tempo(35, "Grave"); public static LARGO = new Tempo(50, "Largo"); public static LENTO = new Tempo(53, "Lento"); public static LARGHETTO = new Tempo(63, "Larghetto"); public static ADAGIO = new Tempo(71, "Adagio"); public static ADAGIETTO = new Tempo(74, "Adagietto"); public static ANDANTE = new Tempo(92, "Andante"); public static ANDANTINO = new Tempo(94, "Andantino"); public static MARCIA_MODERATO = new Tempo(84, "Marcia Moderato"); public static ANDANTE_MODERATO = new Tempo(102, "Andante Moderato"); public static MODERATO = new Tempo(114, "Moderato"); public static ALLEGRETTO = new Tempo(116, "Allegretto"); public static ALLEGRO_MODERATO = new Tempo(118, "Allegro Moderato"); public static ALLEGRO = new Tempo(144, "Allegro"); public static VIVACE = new Tempo(172, "Vivace"); public static VIVACISSIMO = new Tempo(174, "Vivacissimo"); public static ALLEGRISSIMO = new Tempo(174, "Allegrissimo"); public static ALLEGRO_VIVACE = new Tempo(174, "Allegro Vivace"); public static PRESTO = new Tempo(184, "Presto"); public static PRESTISSIMO = new Tempo(200, "Prestissimo"); private beatValue: Value; private tempoMarking: string; constructor(private bpm: number, parameterA: Value | string = Value.QUARTER, parameterB: string = (`[${parameterA}] = ${bpm}`)) { if (parameterA instanceof Value) { this.beatValue = parameterA as Value; this.tempoMarking = parameterB; } else if (typeof parameterA === "string") { if (arguments.length !== 2) { throw EtudeError.forIllegalArgument(Tempo, parameterA, "Invalid number of arguments"); } this.beatValue = Value.QUARTER; this.tempoMarking = parameterA as string; } } public getBPM(): number { return this.bpm; } public getBeatValue(): Value { return this.beatValue; } public getTempoMarking(): string { return this.tempoMarking; } }