Tone.js/examples/require.html
Yotam Mann 0643cdd765 scale takes an input min/max
removed normalize and subtract.
2014-04-16 19:56:18 -04:00

41 lines
No EOL
966 B
HTML

<html>
<head>
<title>USING WITH REQUIRE</title>
<script src="http://code.jquery.com/jquery-2.1.0.min.js"></script>
<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/signal/Signal", "Tone/signal/Scale", "Tone/component/Meter"],
function(Tone, Signal, Scale, Meter){
var meter = new Meter();
var sig1 = new Signal(.5);
var scale = new Scale(0, 1, 10, 100);
sig1.connect(scale)
scale.connect(meter);
var meterEl = document.querySelector("#meter");
setInterval(function(){
meterEl.textContent = meter.getValue();
}, 100);
window.scale = scale;
});
var scaleVal = function(input, inmin, inmax, outmin, outmax){
return (input - inmin)*((outmax - outmin) / (inmax - inmin)) + outmin;
}
</script>
</body>
</html>