Andrea Condoluci 9 rokov pred
rodič
commit
31687c30c6

+ 2 - 1
Gruntfile.js

@@ -27,7 +27,8 @@ module.exports = function (grunt) {
             debug: {
                 src: [
                     'typings/browser.d.ts', 'typings/vexflow.d.ts',
-                    'src/**/*.ts', 'test/**/*.ts'
+                    //'src/**/*.ts', 'test/**/*.ts'
+                    'src/Common/**/*.ts', 'test/Common/**/*.ts'
                 ],
                 dest: '<%= outputDir.build %>/osmd-debug.js',
                 options: {

+ 9 - 8
src/Common/DataObjects/fraction.ts

@@ -37,7 +37,7 @@ export class Fraction /*implements IComparable, IComparer<Fraction> */{
         return sum;
     }
 
-    public static minus (f1: Fraction , f2: Fraction): Fraction {
+    public static minus(f1: Fraction , f2: Fraction): Fraction {
         let sum: Fraction = Fraction.CreateFractionFromFraction(f1);
         sum.Sub(f2);
         return sum;
@@ -156,12 +156,13 @@ export class Fraction /*implements IComparable, IComparer<Fraction> */{
     }
 
     public CompareTo(obj: Fraction): number {
-        if (this.RealValue > obj.RealValue) {
-            return 1;
-        } else if (this.RealValue < obj.RealValue) {
-            return -1;
-        }
-        return 0;
+        let diff: number = this.numerator * obj.Denominator - this.denominator * obj.Numerator;
+        // Return the sign of diff
+        return diff ? diff < 0 ? -1 : 1 : 0;
+    }
+
+    public lt(frac: Fraction): boolean {
+        return (this.numerator * frac.Denominator - this.denominator * frac.Numerator) < 0;
     }
 
     //public Equals(f: Fraction): boolean {
@@ -173,7 +174,7 @@ export class Fraction /*implements IComparable, IComparer<Fraction> */{
     //}
 
     public GetInversion(): Fraction {
-        return new Fraction(this.Denominator, this.Numerator);
+        return new Fraction(this.denominator, this.numerator);
     }
 
     private setRealValue(): void {

+ 9 - 2
src/Common/DataObjects/osmdColor.ts

@@ -4,12 +4,13 @@ export class OSMDColor {
     public green: number;
     public blue: number;
 
-    constructor(alpha: number, red: number, green: number, blue: number) {
+    // FIXME:
+    /*constructor(alpha: number, red: number, green: number, blue: number) {
         this.alpha = alpha;
         this.red = red;
         this.green = green;
         this.blue = blue;
-    }
+    }*/
     constructor(red: number, green: number, blue: number) {
         this.alpha = 255;
         this.red = red;
@@ -40,6 +41,7 @@ export class OSMDColor {
     public static get DarkBlue(): OSMDColor {
         return new OSMDColor(0, 0, 140);
     }
+    // For debugging:
     public static get Debug1(): OSMDColor {
         return new OSMDColor(200, 0, 140);
     }
@@ -49,4 +51,9 @@ export class OSMDColor {
     public static get Debug3(): OSMDColor {
         return new OSMDColor(0, 50, 140);
     }
+
+    public toString(): string {
+        // FIXME RGBA
+        return "rgb(" + this.red + "," + this.green + "," + this.blue + ")";
+    }
 }

+ 46 - 52
src/Common/DataObjects/pitch.ts

@@ -1,4 +1,3 @@
-import {PSMath} from "../..//Util/psMath";
 import {CollectionUtil} from "../../Util/collectionUtil";
 
 export enum NoteEnum {
@@ -29,10 +28,12 @@ export class Pitch {
         this.frequency = Pitch.calcFrequency(this);
     }
 
-    public static pitchEnumValues: NoteEnum[] = [NoteEnum.C, NoteEnum.D, NoteEnum.E, NoteEnum.F, NoteEnum.G, NoteEnum.A, NoteEnum.B];
+    public static pitchEnumValues: NoteEnum[] = [
+        NoteEnum.C, NoteEnum.D, NoteEnum.E, NoteEnum.F, NoteEnum.G, NoteEnum.A, NoteEnum.B
+    ];
 
-    private static halftoneFactor: number = 12 / PSMath.log10(2);
-    private static octXmlDiff: number = 3;  // Pitch.octXmlDiff
+    private static halftoneFactor: number = 12 / (Math.LN2 / Math.LN10);
+    private static octXmlDiff: number = 3;
 
     // private _sourceOctave: number;
     // private _sourceFundamentalNote: NoteEnum;
@@ -50,12 +51,12 @@ export class Pitch {
      *          ret[1] = the octave shift (not the new octave!)
      * @constructor
      */
-    public static CalculateTransposedHalfTone(pitch: Pitch, transpose: number): number[] {
+    public static CalculateTransposedHalfTone(pitch: Pitch, transpose: number): { value: number; overflow: number; } {
         let newHalfTone: number = <number>pitch.fundamentalNote + <number>pitch.accidental + transpose;
         return Pitch.WrapAroundCheck(newHalfTone, 12);
     }
 
-    public static WrapAroundCheck(value: number, limit: number): number[] {
+    public static WrapAroundCheck(value: number, limit: number): { value: number; overflow: number; } {
         let overflow: number = 0;
 
         while (value < 0) {
@@ -66,50 +67,55 @@ export class Pitch {
             value -= limit;
             overflow++; // the octave change
         }
-        return [value, overflow];
+        return {value: value, overflow: overflow};
     }
 
-    public static calcFrequency(pitch: Pitch): number;
-
-    public static calcFrequency(fractionalKey: number): number;
-
-    public static calcFrequency(pitch: any): number {
-        if (pitch instanceof Pitch) {
-            let octaveSteps: number = pitch.octave - 1;
-            let halftoneSteps: number = <number>pitch.fundamentalNote - <number>NoteEnum.A + <number>pitch.accidental;
-            let frequency: number = <number>(440.0 * Math.pow(2, octaveSteps) * Math.pow(2, halftoneSteps / 12.0));
-            return frequency;
-        } else if (typeof pitch === "number") {
-            let fractionalKey: number = pitch;
-            let frequency: number = <number>(440.0 * Math.pow(2, (fractionalKey - 57.0) / 12));
-            return frequency;
+    //public static calcFrequency(pitch: Pitch): number;
+
+    //public static calcFrequency(fractionalKey: number): number;
+
+    public static calcFrequency(obj: Pitch|number): number {
+        let frequency: number;
+        let octaveSteps: number = 0;
+        let halftoneSteps: number;
+        if (obj instanceof Pitch) {
+            // obj is a pitch
+            let pitch: Pitch = obj;
+            octaveSteps = pitch.octave - 1;
+            halftoneSteps = <number>pitch.fundamentalNote - <number>NoteEnum.A + <number>pitch.accidental;
+        } else if (typeof obj === "number") {
+            // obj is a fractional key
+            let fractionalKey: number = obj;
+            halftoneSteps = fractionalKey - 57.0;
         }
+        // Return frequency:
+        return 440.0 * Math.pow(2, octaveSteps) * Math.pow(2, halftoneSteps / 12.0);
     }
 
     public static calcFractionalKey(frequency: number): number {
-        let halftoneFrequency: number = <number>((PSMath.log10(frequency / 440.0) * Pitch.halftoneFactor) + 57.0);
-        return halftoneFrequency;
+        // Return half-tone frequency:
+        return Math.log(frequency / 440.0) / Math.LN10 * Pitch.halftoneFactor + 57.0;
     }
 
-    public static getPitchFromFrequency(frequency: number): Pitch {
+    public static fromFrequency(frequency: number): Pitch {
         let key: number = Pitch.calcFractionalKey(frequency) + 0.5;
-        let octave: number = <number>Math.floor(key / 12) - Pitch.octXmlDiff;
-        let halftone: number = Math.floor(<number>(key)) % 12;
+        let octave: number = Math.floor(key / 12) - Pitch.octXmlDiff;
+        let halftone: number = Math.floor(key) % 12;
         let fundamentalNote: NoteEnum = <NoteEnum>halftone;
         let accidental: AccidentalEnum = AccidentalEnum.NONE;
-        if (!CollectionUtil.contains(this.pitchEnumValues, fundamentalNote)) {
+        if (this.pitchEnumValues.indexOf(fundamentalNote) === -1) {
             fundamentalNote = <NoteEnum>(halftone - 1);
             accidental = AccidentalEnum.SHARP;
         }
-        return new Pitch(fundamentalNote, <number>octave, accidental);
+        return new Pitch(fundamentalNote, octave, accidental);
     }
 
-    public static getPitchFromHalftone(halftone: number): Pitch {
+    public static fromHalftone(halftone: number): Pitch {
         let octave: number = <number>Math.floor(<number>halftone / 12) - Pitch.octXmlDiff;
         let halftoneInOctave: number = halftone % 12;
         let fundamentalNote: NoteEnum = <NoteEnum>halftoneInOctave;
         let accidental: AccidentalEnum = AccidentalEnum.NONE;
-        if (!CollectionUtil.contains(this.pitchEnumValues, fundamentalNote)) {
+        if (this.pitchEnumValues.indexOf(fundamentalNote) === -1) {
             fundamentalNote = <NoteEnum>(halftoneInOctave - 1);
             accidental = AccidentalEnum.SHARP;
         }
@@ -119,16 +125,16 @@ export class Pitch {
     public static ceiling(halftone: number): NoteEnum {
         halftone = <number>(halftone) % 12;
         let fundamentalNote: NoteEnum = <NoteEnum>halftone;
-        if (!CollectionUtil.contains(this.pitchEnumValues, fundamentalNote)) {
+        if (this.pitchEnumValues.indexOf(fundamentalNote) === -1) {
             fundamentalNote = <NoteEnum>(halftone + 1);
         }
         return fundamentalNote;
     }
 
     public static floor(halftone: number): NoteEnum {
-        halftone = <number>(halftone) % 12;
+        halftone = halftone % 12;
         let fundamentalNote: NoteEnum = <NoteEnum>halftone;
-        if (!CollectionUtil.contains(this.pitchEnumValues, fundamentalNote)) {
+        if (this.pitchEnumValues.indexOf(fundamentalNote) === -1) {
             fundamentalNote = <NoteEnum>(halftone - 1);
         }
         return fundamentalNote;
@@ -238,30 +244,18 @@ export class Pitch {
     }
 
     private getNextFundamentalNote(fundamental: NoteEnum): NoteEnum {
-        let i: number = 0;
-        for (; i < Pitch.pitchEnumValues.length; i++) {
-            let note: NoteEnum = Pitch.pitchEnumValues[i];
-            if (note === fundamental) {
-                break;
-            }
-        }
-        i = ++i % Pitch.pitchEnumValues.length;
+        let i = Pitch.pitchEnumValues.indexOf(fundamental);
+        i = (i + 1) % Pitch.pitchEnumValues.length;
         return Pitch.pitchEnumValues[i];
     }
 
     private getPreviousFundamentalNote(fundamental: NoteEnum): NoteEnum {
-        let i: number = 0;
-        for (; i < Pitch.pitchEnumValues.length; i++) {
-            let note: NoteEnum = Pitch.pitchEnumValues[i];
-            if (note === fundamental) {
-                break;
-            }
-        }
-        i--;
-        if (i < 0) {
-            i += Pitch.pitchEnumValues.length;
+        let i = Pitch.pitchEnumValues.indexOf(fundamental);
+        if (i > 0) {
+            return Pitch.pitchEnumValues[i - 1];
+        } else {
+            return Pitch.pitchEnumValues[Pitch.pitchEnumValues.length - 1];
         }
-        return Pitch.pitchEnumValues[i];
     }
 }
 

+ 5 - 5
src/MusicalScore/Label.ts

@@ -18,10 +18,10 @@ export class Label {
     }
 
     private text: string; // FIXME:
-    private color: OSMDColor; //= PSColor.Black;
-    private font: OSMDFonts; // = PSFonts.TimesNewRoman;
-    private fontStyle: OSMDFontStyles; // = PSFontStyles.Regular;
-    private textAlignment: OSMDTextAlignment; // = PSTextAlignment.LeftBottom;
+    private color: OSMDColor = OSMDColor.Black;
+    private font: OSMDFonts = OSMDFonts.TimesNewRoman;
+    private fontStyle: OSMDFontStyles = OSMDFontStyles.Regular;
+    private textAlignment: OSMDTextAlignment = OSMDTextAlignment.LeftBottom;
     private fontHeight: number = 2;
 
     public get Text(): string {
@@ -61,6 +61,6 @@ export class Label {
         this.textAlignment = value;
     }
     public ToString(): string {
-        return this.Text;
+        return this.text;
     }
 }

+ 3 - 4
src/MusicalScore/MusicParts/MusicPartManagerIterator.ts

@@ -32,10 +32,9 @@ export class MusicPartManagerIterator {
             if (startTimestamp === undefined) { return; }
             do {
                 this.moveToNext();
-            } while ((this.currentVoiceEntries === undefined || this.currentTimeStamp < startTimestamp) && !this.endReached);
+            } while ((this.currentVoiceEntries === undefined || this.currentTimeStamp.lt(startTimestamp)) && !this.endReached);
             for (let staffIndex: number = 0; staffIndex < this.activeDynamicExpressions.length; staffIndex++) {
                 if (this.activeDynamicExpressions[staffIndex] !== undefined) {
-                    /*
                     if (this.activeDynamicExpressions[staffIndex] instanceof ContinuousDynamicExpression) {
                         let continuousDynamic: ContinuousDynamicExpression =
                             <ContinuousDynamicExpression>this.activeDynamicExpressions[staffIndex];
@@ -45,12 +44,11 @@ export class MusicPartManagerIterator {
                             <InstantaniousDynamicExpression>this.activeDynamicExpressions[staffIndex];
                         this.currentDynamicChangingExpressions.push(new DynamicsContainer(instantaniousDynamic, staffIndex));
                     }
-                    */ // FIXME TODO DynamicExpression problems!
                 }
             }
             this.currentTempoChangingExpression = this.activeTempoExpression;
         } catch (err) {
-            console.log("MusicPartManagerIterator: Exception."); // FIXME
+            console.log("MusicPartManagerIterator: Exception." + err); // FIXME
         }
 
     }
@@ -79,6 +77,7 @@ export class MusicPartManagerIterator {
     private jumpResponsibleRepetition: Repetition = undefined;
     private activeDynamicExpressions: AbstractExpression[] = [];
     private activeTempoExpression: MultiTempoExpression;
+
     public get EndReached(): boolean {
         return this.endReached;
     }

+ 4 - 1
src/MusicalScore/VoiceData/ChordSymbolContainer.ts

@@ -1,5 +1,6 @@
 import {Pitch, AccidentalEnum} from "../../Common/DataObjects/pitch";
 import {KeyInstruction} from "./Instructions/KeyInstruction";
+
 export class ChordSymbolContainer {
     constructor(rootPitch: Pitch, chordKind: ChordSymbolEnum, bassPitch: Pitch, chordDegree: Degree, keyInstruction: KeyInstruction) {
         this.rootPitch = rootPitch;
@@ -29,6 +30,7 @@ export class ChordSymbolContainer {
         return this.keyInstruction;
     }
 }
+
 export class Degree {
     constructor(value: number, alteration: AccidentalEnum, text: ChordDegreeText) {
         this.Value = value;
@@ -39,6 +41,7 @@ export class Degree {
     public Alteration: AccidentalEnum;
     public Text: ChordDegreeText;
 }
+
 export enum ChordDegreeText {
     add,
     alter,
@@ -76,4 +79,4 @@ export enum ChordSymbolEnum {
     pedal,
     power,
     Tristan
-}
+}

+ 28 - 14
src/MusicalScore/VoiceData/Expressions/ContinuousExpressions/Slur.ts

@@ -1,11 +1,14 @@
 import {Note} from "../../Note";
 import {Fraction} from "../../../../Common/DataObjects/fraction";
+
 export class Slur {
     constructor() {
-
+        // ?
     }
+
     private startNote: Note;
     private endNote: Note;
+
     public get StartNote(): Note {
         return this.startNote;
     }
@@ -19,43 +22,54 @@ export class Slur {
         this.endNote = value;
     }
     public startNoteHasMoreStartingSlurs(): boolean {
-        if (this.startNote == null)
-            return false;
+        if (this.startNote == null) { return false; }
         for (var idx: number = 0, len = this.startNote.NoteSlurs.length; idx < len; ++idx) {
             var slur: Slur = this.startNote.NoteSlurs[idx];
-            if (slur != this && slur.StartNote == this.startNote)
+            if (slur != this && slur.StartNote == this.startNote) {
                 return true;
+            }
         }
         return false;
     }
     public endNoteHasMoreEndingSlurs(): boolean {
-        if (this.endNote == null)
-            return false;
+        if (this.endNote == null) { return false; }
         for (var idx: number = 0, len = this.endNote.NoteSlurs.length; idx < len; ++idx) {
             var slur: Slur = this.endNote.NoteSlurs[idx];
-            if (slur != this && slur.EndNote == this.endNote)
+            if (slur != this && slur.EndNote == this.endNote) {
                 return true;
+            }
         }
         return false;
     }
     public isCrossed(): boolean {
-        if (this.startNote.ParentStaffEntry.ParentStaff != this.endNote.ParentStaffEntry.ParentStaff)
-            return true;
-        return false;
+        return (this.startNote.ParentStaffEntry.ParentStaff !== this.endNote.ParentStaffEntry.ParentStaff);
     }
     public isSlurLonger(): boolean {
-        if (this.endNote == null || this.startNote == null)
+        if (this.endNote === null || this.startNote === null) {
             return false;
-        var length: Fraction = this.endNote.getAbsoluteTimestamp() - this.startNote.getAbsoluteTimestamp();
+        }
+        var length: Fraction = Fraction.minus(this.endNote.getAbsoluteTimestamp(), this.startNote.getAbsoluteTimestamp());
         for (var idx: number = 0, len = this.startNote.NoteSlurs.length; idx < len; ++idx) {
             var slur: Slur = this.startNote.NoteSlurs[idx];
-            if (slur != this && slur.EndNote != null && slur.StartNote != null && (slur.EndNote.getAbsoluteTimestamp() - slur.StartNote.getAbsoluteTimestamp() < length))
+            if (
+                slur != this
+                && slur.EndNote != null
+                && slur.StartNote != null
+                && Fraction.minus(slur.EndNote.getAbsoluteTimestamp(), slur.StartNote.getAbsoluteTimestamp()).CompareTo(length) == -1
+            ) {
                 return true;
+            }
         }
         for (var idx: number = 0, len = this.endNote.NoteSlurs.length; idx < len; ++idx) {
             var slur: Slur = this.endNote.NoteSlurs[idx];
-            if (slur != this && slur.EndNote != null && slur.StartNote != null && (slur.EndNote.getAbsoluteTimestamp() - slur.StartNote.getAbsoluteTimestamp() < length))
+            if (
+                slur != this
+                && slur.EndNote != null
+                && slur.StartNote != null
+                && Fraction.minus(slur.EndNote.getAbsoluteTimestamp(), slur.StartNote.getAbsoluteTimestamp()).CompareTo(length)
+            ) {
                 return true;
+            }
         }
         return false;
     }

+ 13 - 23
src/MusicalScore/VoiceData/Note.ts

@@ -29,7 +29,7 @@ export class Note {
     private beam: Beam;
     private tuplet: Tuplet;
     private tie: Tie;
-    private slurs: Slur[] = new Array();
+    private slurs: Slur[] = [];
     private graceNoteSlash: boolean = false;
     private playbackInstrumentId: string = undefined;
     public get GraceNoteSlash(): boolean {
@@ -90,21 +90,16 @@ export class Note {
         this.playbackInstrumentId = value;
     }
     public calculateNoteLengthWithoutTie(): Fraction {
-        let withoutTieLength: Fraction = Fraction.CreateFractionFromFraction(this.length);
+        let withoutTieLength: Fraction = this.length.clone();
         if (this.tie !== undefined) {
-            let tempLength: Fraction = Fraction.CreateFractionFromFraction(this.length);
             for (let idx: number = 0, len: number = this.tie.Fractions.length; idx < len; ++idx) {
                 let fraction: Fraction = this.tie.Fractions[idx];
-                tempLength.Sub(fraction);
+                withoutTieLength.Sub(fraction);
             }
-            withoutTieLength = tempLength;
         }
         return withoutTieLength;
     }
-    public calculateNoteOriginalLength(): Fraction {
-        return this.calculateNoteOriginalLength(Fraction.CreateFractionFromFraction(this.length));
-    }
-    public calculateNoteOriginalLength(originalLength: Fraction): Fraction {
+    public calculateNoteOriginalLength(originalLength: Fraction = this.length): Fraction {
         if (this.tie !== undefined) {
             originalLength = this.calculateNoteLengthWithoutTie();
         }
@@ -124,19 +119,13 @@ export class Note {
         }
         return this.length;
     }
-    public calculateNumberOfNeededDots(): number {
-        return this.calculateNumberOfNeededDots(this.length);
-    }
-    public calculateNumberOfNeededDots(fraction: Fraction): number {
-        let num: number = 1;
-        let product: number = 2;
+    public calculateNumberOfNeededDots(fraction: Fraction = this.length): number {
+        // FIXME (Andrea) Test if correct
         if (this.tuplet === undefined) {
-            while (product < fraction.Numerator) {
-                num++;
-                product = 1 << num; // FIXME some logarithm
-            }
+            return Math.floor(Math.log(fraction.Numerator) / Math.LN2);
+        } else {
+            return 0;
         }
-        return num - 1;
     }
     public ToString(): string {
         if (this.pitch !== undefined) {
@@ -146,9 +135,10 @@ export class Note {
         }
     }
     public getAbsoluteTimestamp(): Fraction {
-        let absolute: Fraction = Fraction.CreateFractionFromFraction(this.voiceEntry.Timestamp);
-        absolute += this.parentStaffEntry.VerticalContainerParent.ParentMeasure.AbsoluteTimestamp;
-        return absolute;
+        return Fraction.plus(
+            this.voiceEntry.Timestamp,
+            this.parentStaffEntry.VerticalContainerParent.ParentMeasure.AbsoluteTimestamp
+        );
     }
     public checkForDoubleSlur(slur: Slur): boolean {
         for (let idx: number = 0, len: number = this.slurs.length; idx < len; ++idx) {

+ 1 - 1
src/Util/collectionUtil.ts

@@ -1,6 +1,6 @@
 export class CollectionUtil {
 
-    public static contains(array: any[], object: any): boolean {
+    public static contains2(array: any[], object: any): boolean {
         for (let i: number = 0; i < array.length; i++) {
             if (array[i] === object) {
                 return true;

+ 10 - 8
test/Common/DataObjects/Pitch_Test.ts

@@ -3,14 +3,16 @@ import { Pitch, NoteEnum, AccidentalEnum } from "../../../src/Common/DataObjects
 describe("Pitch Unit Tests:", () => {
     describe("transpose Pitch", () => {
         let pitch: Pitch = new Pitch(NoteEnum.A, 1, AccidentalEnum.NONE);
-        let transposedFundamentalAndOctave: number[] = Pitch.CalculateTransposedHalfTone(pitch, 12);
-        let higherTransposedFundamentalAndOctave: number[] = Pitch.CalculateTransposedHalfTone(pitch, 26);
+        let transposedFundamentalAndOctave: {value: number; overflow: number; } =
+          Pitch.CalculateTransposedHalfTone(pitch, 12);
+        let higherTransposedFundamentalAndOctave: {value: number; overflow: number; } =
+          Pitch.CalculateTransposedHalfTone(pitch, 26);
 
         it("should be 1 octave higher and same fundamental", (done: MochaDone) => {
-            chai.expect(transposedFundamentalAndOctave[1]).to.equal(1);
-            chai.expect(transposedFundamentalAndOctave[0]).to.equal(pitch.FundamentalNote);
-            chai.expect(higherTransposedFundamentalAndOctave[1]).to.equal(2);
-            chai.expect(higherTransposedFundamentalAndOctave[0]).to.equal(pitch.FundamentalNote + 2);
+            chai.expect(transposedFundamentalAndOctave.overflow).to.equal(1);
+            chai.expect(transposedFundamentalAndOctave.value).to.equal(pitch.FundamentalNote);
+            chai.expect(higherTransposedFundamentalAndOctave.overflow).to.equal(2);
+            chai.expect(higherTransposedFundamentalAndOctave.value).to.equal(pitch.FundamentalNote + 2);
             done();
         });
     });
@@ -74,7 +76,7 @@ describe("Pitch Unit Tests:", () => {
         for (let i: number = 0; i < Pitch.pitchEnumValues.length; i++) {
             for (let j: number = 0; j < accidentals.length; j++) {
                 pitch = new Pitch(Pitch.pitchEnumValues[i], octave, accidentals[j]);
-                calcedPitch = Pitch.getPitchFromFrequency(pitch.Frequency);
+                calcedPitch = Pitch.fromFrequency(pitch.Frequency);
 
                 it( "calcedPitch equals original, " +
                     `note: ${pitch.FundamentalNote}, octave: ${pitch.Octave}, accidental; ${pitch.Accidental}`,
@@ -103,7 +105,7 @@ describe("Pitch Unit Tests:", () => {
             for (let j: number = 0; j < accidentals.length; j++) {
                 pitch = new Pitch(Pitch.pitchEnumValues[i], octave, accidentals[j]);
                 let halftone: number = pitch.getHalfTone();
-                calcedPitch = Pitch.getPitchFromHalftone(halftone);
+                calcedPitch = Pitch.fromHalftone(halftone);
 
                 it( "calcedPitch equals original, " +
                     `note: ${pitch.FundamentalNote}, octave: ${pitch.Octave}, accidental; ${pitch.Accidental}`,

+ 21 - 1
test/Common/DataObjects/fraction_Test.ts

@@ -4,7 +4,7 @@
 import { Fraction } from "../../../src/Common/DataObjects/fraction";
 
 describe("Fraction Unit Tests:", () => {
-    describe("Construct Fraction, check Properties", () => {
+    describe("Construct Fraction, check properties", () => {
         let f1: Fraction = new Fraction(2, 6);
 
         it("Numerator and Denominator", (done: MochaDone) => {
@@ -12,5 +12,25 @@ describe("Fraction Unit Tests:", () => {
             chai.expect(f1.Denominator).to.equal(3);
             done();
         });
+
+        it("Real value", (done: MochaDone) => {
+            chai.expect(f1.RealValue).to.equal(1 / 3);
+            done();
+        });
+    });
+    describe("Compare fractions", () => {
+      let f1: Fraction;
+      let f2: Fraction;
+      let rand: () => number = function(): number {
+        return Math.floor(Math.random() * 500) + 1;
+      };
+      it("lt attribute", (done: MochaDone) => {
+        for (let i = 0; i < 10; i += 1) {
+          let f1: Fraction = new Fraction(rand(), rand());
+          let f2: Fraction = new Fraction(rand(), rand());
+          chai.expect(f1.lt(f2)).to.equal(f1.RealValue < f2.RealValue);
+        }
+        done();
+      });
     });
 });