summaryrefslogtreecommitdiff
path: root/theremin.html
diff options
context:
space:
mode:
Diffstat (limited to 'theremin.html')
-rw-r--r--theremin.html26
1 files changed, 26 insertions, 0 deletions
diff --git a/theremin.html b/theremin.html
new file mode 100644
index 0000000..82e627e
--- /dev/null
+++ b/theremin.html
@@ -0,0 +1,26 @@
+<script src="Tone.min.js"></script>
+<script>
+var Frequency = "10.8 33 33.8 55 62.64 63 70 73.6 83 98.4 105 110 111 147 147.85 172.06 210.42 221.23 264 293 342 396 404 408 410 413 416 417 420.82 440 448 528 630 639 685 852 880 1052 12000".split(" ").map(function(n){ return parseFloat(n) }).reverse()
+
+var audioCtx = new (window.AudioContext || window.webkitAudioContext)()
+
+var oscillator = audioCtx.createOscillator()
+var gainNode = audioCtx.createGain()
+
+oscillator.connect(gainNode)
+gainNode.connect(audioCtx.destination)
+
+oscillator.type = 'sine'
+oscillator.frequency.value = 2500
+oscillator.start()
+
+document.addEventListener("mousemove", function(e){
+ var x = e.pageX/window.innerWidth
+ var f = Frequency[ Math.floor( x * Frequency.length ) ]
+console.log(f)
+ oscillator.frequency.value = f
+})
+
+</script>
+
+