summaryrefslogtreecommitdiff
path: root/index.html
blob: ccb16d72e858fd26a8732bcb38ee6cd8451f3a7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<style>
.note {
  color: #339;
  text-decoration: underline;
  cursor: pointer;
}
* {
  cursor: default;
}
pre {
  white-space: pre-line;
}
</style>
<pre>
<script src="intonation.js"></script>
<script>
var delim = "</span> <span>"
function write(s){ document.write("<span>" + (s || "") + "</span>\n") }

s = new Intonation({
  intervals: '1/1 9/8 5/4 4/3 3/2 5/3 15/8 2/1',
})
write("original scale:")
write( s.range(0, 10).map(function(i){ return i.toFixed(0) }).join(delim) )
write("")

s = new Intonation({
  root: 450,
  intervals: '1/1 9/8 5/4 4/3 3/2 5/3 15/8 2/1',
})
write("root @ 450:")
write( s.range(0, 10).map(function(i){ return i.toFixed(0) }).join(delim) )
write("")

s = new Intonation({
  tet: 5,
})
write("5-tet")
write( s.range(0, 6).map(function(i){ return i.toFixed(0) }).join(delim) )
write("")

s = new Intonation({
  tet: 12,
})
write("12-tet")
write( s.range(0, 13).map(function(i){ return i.toFixed(0) }).join(delim) )
write("")

s = new Intonation({
  tet: 17,
})
write("17-tet")
write( s.range(0, 18).map(function(i){ return i.toFixed(0) }).join(delim) )
write("")

s = new Intonation({
  intervals: '1/1 12/11 11/10 10/9 9/8 8/7 7/6 6/5 11/9 5/4 14/11 9/7 4/3 11/8 7/5 10/7 16/11 3/2 14/9 11/7 8/5 18/11 5/3 12/7 7/4 16/9 9/5 20/11 11/6 2/1',
})
write("partch:")
write( s.range(0, 31).map(function(i){ return i.toFixed(0) }).join(delim) )
write("")

</script>
<script src="http://asdf.us/harp/js/vendor/Tone.min.js"></script>
<script>
polysynth = new Tone.PolySynth(8, Tone.synth)
polysynth.set({
  oscillator: { type: "sine" },
  envelope:{
    attack: 0.01,
    decay: 2.5,
    sustain: 0.0,
    release: 0.1,
  }
})
var comp = new Tone.Compressor(-30, 3).toMaster()
polysynth.connect(comp)
Array.prototype.slice.apply( document.querySelectorAll("span") ).forEach(function(span){
  if (! span.innerHTML.match(/[^0-9]/)) {
    var f = parseInt(span.innerHTML)
    span.classList.add("note")
    span.addEventListener("click", function(){
       polysynth.triggerAttackRelease(f, 1.5)
    })
  }
})
</script>