From 866716676f5be34262d1ca81add5047f55d16ede Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Tue, 20 Sep 2016 13:46:49 -0400 Subject: handle negative notes and non-octave scales --- intonation.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'intonation.js') diff --git a/intonation.js b/intonation.js index 8c12847..fe2fa37 100644 --- a/intonation.js +++ b/intonation.js @@ -28,7 +28,7 @@ var Intonation = (function(){ interval_list = interval_list.split(" ") } this.intervals = interval_list - this.opt.interval = parseInterval.call(this, interval_list.pop() ) + this.interval = this.opt.interval = parseInterval.call(this, interval_list.pop() ) this.scale = interval_list.map( parseIntervalString.bind(this) ).filter(function(v){ return !! v }) @@ -37,7 +37,7 @@ var Intonation = (function(){ var scale = this.scale = [] var root = this.opt.root var tet = this.opt.tet - var interval = this.opt.interval + var interval = this.interval = this.opt.interval var ratio = Math.pow( interval, 1/tet ) var n = root scale.push(n) @@ -83,7 +83,6 @@ var Intonation = (function(){ note = Math.pow( 2, (parseFloat(note) / 1200) ) } else { - console.log("note", line, note) note = parseInterval(note) } if (note) { @@ -97,7 +96,7 @@ var Intonation = (function(){ octave = octave || this.opt.octave var f = this.scale[ mod(i, this.scale.length)|0 ] var pow = Math.floor(norm(i, 0, this.scale.length)) + octave - f *= Math.pow(this.opt.interval, pow) + f *= Math.pow(this.interval, pow) return f } Intonation.prototype.range = function(min, max){ @@ -115,7 +114,7 @@ var Intonation = (function(){ if (f == 0) return 0 var scale_f = f var pow = 0 - var interval = this.opt.interval + var interval = this.interval var scale = this.scale while (scale_f < root) { scale_f *= interval -- cgit v1.2.3-70-g09d2