2014-04-05 00:24:19 +00:00
|
|
|
<html>
|
|
|
|
<head>
|
2014-04-16 00:05:11 +00:00
|
|
|
<title>USING WITH REQUIRE</title>
|
2014-04-05 00:24:19 +00:00
|
|
|
|
2014-09-04 19:20:25 +00:00
|
|
|
<script type="text/javascript" src="./deps/require.js"></script>
|
2014-04-16 00:05:11 +00:00
|
|
|
|
2014-04-05 00:24:19 +00:00
|
|
|
</head>
|
|
|
|
<body>
|
2014-04-16 23:56:18 +00:00
|
|
|
<div id='meter'></div>
|
2014-04-05 00:24:19 +00:00
|
|
|
<script type="text/javascript">
|
2014-04-16 00:05:11 +00:00
|
|
|
//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){
|
2014-04-16 23:56:18 +00:00
|
|
|
|
|
|
|
var meter = new Meter();
|
2014-04-16 00:05:11 +00:00
|
|
|
|
2014-09-05 04:58:26 +00:00
|
|
|
var osc = new Oscillator(0.5);
|
|
|
|
var scale = new Scale(-1, 1, 10, 100);
|
2014-04-16 23:56:18 +00:00
|
|
|
|
2014-09-05 04:58:26 +00:00
|
|
|
osc.connect(scale);
|
2014-04-16 23:56:18 +00:00
|
|
|
scale.connect(meter);
|
|
|
|
|
2014-09-05 04:58:26 +00:00
|
|
|
osc.start();
|
|
|
|
|
2014-04-16 23:56:18 +00:00
|
|
|
var meterEl = document.querySelector("#meter");
|
|
|
|
|
|
|
|
setInterval(function(){
|
2014-09-05 04:58:26 +00:00
|
|
|
meterEl.textContent = meter.getValue().toFixed(2);
|
2014-04-16 23:56:18 +00:00
|
|
|
}, 100);
|
2014-04-16 04:23:58 +00:00
|
|
|
});
|
2014-04-11 23:17:01 +00:00
|
|
|
|
2014-04-05 00:24:19 +00:00
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|