mirror of
https://github.com/Tonejs/Tone.js
synced 2024-11-16 08:38:00 +00:00
37 lines
No EOL
770 B
HTML
37 lines
No EOL
770 B
HTML
<html>
|
|
<head>
|
|
<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> |