<html>
<head>
<meta charset="utf-8"/>
<title>timbre - oscillators</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" src="../timbre.js"></script>
</head>
<body>
<selction id="body">
<h2>Timbre</h2>
<div>
<button id="play0">play</button>
<button id="pause0">pause</button>
</div>
<hr/>
<div id="main">
<h2>Serial Port</h2>
<div>
<input type="text" value="http://localhost:8783" id="addr" size="40" />
</div>
<h3>LED</h3>
<div class="led">
<input type="button" class="btn on" value="ON" />
<input type="button" class="btn off" value="OFF" />
</div>
<h3>CdS</h3>
<div class="cds">
<input type="range" value="500" min="0" max="1024" class="slider" />
<input type="text" id="cdsvalue" value="500" disabled="disabled" size="5" />
</div>
</div>
</section>
</body>
<script type="text/javascript">
$(function() {
$('.led .on').click(function(){
$.post($('#addr').val(), 'o', function(){
//alert('led on');
});
});
$('.led .off').click(function(){
$.post($('#addr').val(), 'x', function(){
//alert('led off');
});
});
setInterval(function(){
$.getJSON($('#addr').val(), {}, function(data){
$('.cds input').val( data[0].data );
});
}, 100);
function getCdsValue() {
var value= parseInt($("#cdsvalue")[0].value);
if (isNaN(value)) {
value= 880;
}
return value;
}
dac0= T("dac", fami= T("fami", getCdsValue()));
var timerId;
dac0.addEventListener("on", function() {
timerId = setInterval(function() {
fami.freq = getCdsValue();
}, 50);
});
dac0.addEventListener("on" , function() {timbre.on();});
dac0.addEventListener("off", function() {
if (dac0.isOff) timbre.off();
});
$("#play0").on("click", function() { dac0.on(); });
$("#pause0").on("click", function() { dac0.off(); });
});
</script>
</html>
0 件のコメント:
コメントを投稿