Tone.js/examples/require.html

39 lines
811 B
HTML
Raw Normal View History

<!DOCTYPE html>
2014-04-05 00:24:19 +00:00
<html>
<head>
<meta charset="utf-8">
<title>USING WITH REQUIRE</title>
2014-04-05 00:24:19 +00:00
<script type="text/javascript" src="./deps/require.js"></script>
2014-04-05 00:24:19 +00:00
</head>
<body>
<div id='meter'></div>
2014-04-05 00:24:19 +00:00
<script type="text/javascript">
//minimal example using requirejs
2014-04-06 20:51:30 +00:00
require.config({
baseUrl : "../"
});
2014-09-05 04:58:26 +00:00
require(["Tone/core/Tone", "Tone/source/Oscillator", "Tone/signal/Scale", "Tone/component/Meter"],
function(Tone, Oscillator, Scale, Meter){
var meter = new Meter();
2014-09-05 04:58:26 +00:00
var osc = new Oscillator(0.5);
var scale = new Scale(-1, 1, 10, 100);
2014-09-05 04:58:26 +00:00
osc.connect(scale);
scale.connect(meter);
2014-09-05 04:58:26 +00:00
osc.start();
var meterEl = document.querySelector("#meter");
setInterval(function(){
2014-09-05 04:58:26 +00:00
meterEl.textContent = meter.getValue().toFixed(2);
}, 100);
2014-04-16 04:23:58 +00:00
});
2014-04-05 00:24:19 +00:00
</script>
</body>
</html>