Tone.js/examples/require.html

39 lines
No EOL
811 B
HTML

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