Skip to content

Commit

Permalink
review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
rvilarl committed Mar 31, 2021
1 parent 850db00 commit fc24e2a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
8 changes: 3 additions & 5 deletions src/fraction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ export class Fraction {
return Math.floor(this.numerator / this.denominator);
}

/** Returns the fraction component when reduced to a mixed number */
fraction(): number {
/** Returns the remainder component when reduced to a mixed number */
remainder(): number {
return this.numerator % this.denominator;
}

Expand Down Expand Up @@ -250,9 +250,7 @@ export class Fraction {
const f = Fraction.__staticFractionTmp.copy(this);

if (q < 0) {
f.makeAbs().fraction();
} else {
f.fraction();
f.makeAbs();
}

if (q !== 0) {
Expand Down
18 changes: 12 additions & 6 deletions src/tuning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,31 +31,35 @@ export class Tuning {
this.setTuning(tuningString);
}

static noteToInteger(noteString: string): number {
noteToInteger(noteString: string): number {
return Flow.keyProperties(noteString).int_value;
}

/**
* Set tuning identified by tuning name (ie.: 'dagdad')
* or comma separated notes string (ie.: 'D/5,A/4,G/4,D/4,A/3,D/3')
* */
setTuning(noteString: string): void {
let noteName = noteString;
if (Tuning.names[noteString]) {
noteName = Tuning.names[noteString];
noteString = Tuning.names[noteString];
}

this.tuningString = noteName;
this.tuningString = noteString;
this.tuningValues = [];
this.numStrings = 0;

const keys = noteName.split(/\s*,\s*/);
const keys = noteString.split(/\s*,\s*/);
if (keys.length === 0) {
throw new Vex.RERR('BadArguments', `Invalid tuning string: ${noteString}`);
}

this.numStrings = keys.length;
for (let i = 0; i < this.numStrings; i += 1) {
this.tuningValues[i] = Tuning.noteToInteger(keys[i]);
this.tuningValues[i] = this.noteToInteger(keys[i]);
}
}

/** Returns the number representing the note associated with a string */
getValueForString(stringNum: string | number): number {
const s = typeof stringNum === 'string' ? parseInt(stringNum, 10) : stringNum;
if (s < 1 || s > this.numStrings) {
Expand All @@ -65,6 +69,7 @@ export class Tuning {
return this.tuningValues[s - 1];
}

/** Returns the number representing the note associated with a string and a fret */
getValueForFret(fretNum: string | number, stringNum: string | number): number {
const stringValue = this.getValueForString(stringNum);
const f = typeof fretNum === 'string' ? parseInt(fretNum, 10) : fretNum;
Expand All @@ -76,6 +81,7 @@ export class Tuning {
return stringValue + f;
}

/** Returns the string representing the note associated with a string and a fret */
getNoteForFret(fretNum: string | number, stringNum: string | number): string {
const noteValue = this.getValueForFret(fretNum, stringNum);

Expand Down

0 comments on commit fc24e2a

Please sign in to comment.