diff options
| author | Jules Laplace <jules@okfoc.us> | 2016-07-12 21:58:47 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2016-07-12 21:58:47 -0400 |
| commit | f76ca31d4d97f0d37ad3d2c61ef0c68aab5e40fb (patch) | |
| tree | 0a8f348eabb40c74ac9cf049d86e747f7b23a74b /theremin.html | |
tonejs colundi experiment
Diffstat (limited to 'theremin.html')
| -rw-r--r-- | theremin.html | 26 |
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> + + |
