-
Notifications
You must be signed in to change notification settings - Fork 113
Simpler value() function #125
Copy link
Copy link
Open
Description
Hey, I love your project and try to understand how things work (just for fun).
I think the Interval.prototype.value() function can be a lot simplified. An octave has 7 key steps, a fifths has 4. So why not simplify the function like this:
let steps = vector.sum(vector.mul(this.coord, [7, 4]));
return steps + (steps < 0 ? -1 : 1);I tried it with a small test and it seems to work:
['P1', 'M3', 'm13', 'P15', 'd12', 'AA3', 'AA-1', 'M-14', 'm-6', 'P-15', 'd-12', 'AA-10'].forEach((name) => {
let interval = teoria.interval(name);
let steps = interval.coord[0] * 7 + interval.coord[1] * 4;
let value = steps + (steps < 0 ? -1 : 1);
console.log(name, value === interval.value());
});I hope I have not overlooked something...
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels