summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2016-09-20 15:10:59 -0400
committerJules Laplace <jules@okfoc.us>2016-09-20 15:10:59 -0400
commitfbce4aa9cffd11738fca6d48e9a3adb8fa8ae2e0 (patch)
tree18a4fca53fc2b848b3e3fc8fa68bfcfea48877c2
parenta7c9044a3139c517818d273bdb3e68d24704ceb0 (diff)
scales work fine with negative indicies
-rw-r--r--index.html21
-rw-r--r--intonation.js2
2 files changed, 12 insertions, 11 deletions
diff --git a/index.html b/index.html
index 3876db0..78cd4e6 100644
--- a/index.html
+++ b/index.html
@@ -41,7 +41,7 @@ pre {
<script type="text/scale" id="twelveet-scl">
! 12et.scl
!
-12 equal temperament
+12-edo equal temperament (scl)
12
!
100.
@@ -109,14 +109,6 @@ Wendy Carlos' Alpha scale with perfect fifth divided in nine
<script src="intonation.js"></script>
<div id="scale_list"></div>
<script>
-var delim = "</span> <span>"
-function write(s){
- var div = document.createElement("div")
- div.innerHTML = s
- scale_list.appendChild(div)
- return div
-}
-
var opts = [
{
intervals: '1/1 9/8 5/4 4/3 3/2 5/3 15/8 2/1',
@@ -156,6 +148,7 @@ var opts = [
scl: document.querySelector("#carlos_alpha-scl").innerHTML,
},
]
+
var scale
var scale_list = document.querySelector("#scale_list")
@@ -163,12 +156,13 @@ opts.forEach(function(opt){
var s = new Intonation(opt)
var heading = write( s.name )
var limit = s.interval == 2 ? s.scale.length : s.scale.length*2
- write( "<span>" + s.range(0, limit+1).map(function(i){ return i.toFixed(0) }).join(delim) + "</span>" )
+ write( "<span>" + s.range( 0, limit+1).map(function(i){ return i.toFixed(0) }).join("</span> <span>") + "</span>" )
write("&nbsp;")
if (! scale) {
scale = s
heading.classList.add("active")
+ console.log(s)
console.log("scale:", s.name)
}
@@ -178,6 +172,7 @@ opts.forEach(function(opt){
active && active.classList.remove("active")
scale = s
heading.classList.add("active")
+ console.log(s)
console.log("scale:", s.name)
})
})
@@ -230,6 +225,12 @@ function keydown (e){
play(freq)
}
+function write(s){
+ var div = document.createElement("div")
+ div.innerHTML = s
+ scale_list.appendChild(div)
+ return div
+}
function play (freq) {
console.log(freq.toFixed(0))
polysynth.triggerAttackRelease(freq, 1.5)
diff --git a/intonation.js b/intonation.js
index a0cbedf..b660fee 100644
--- a/intonation.js
+++ b/intonation.js
@@ -43,7 +43,7 @@ var Intonation = (function(){
var ratio = Math.pow( interval, 1/tet )
var n = root
scale.push(n)
- for (var i = 0; i < tet; i++) {
+ for (var i = 0; i < tet-1; i++) {
n *= ratio
scale.push(n)
}