mirror of https://github.com/aredn/aredn.git
feature: add sounds to realtime signal page (#342)
This commit is contained in:
parent
07aa305e29
commit
d9acfa2ea7
|
@ -155,6 +155,7 @@ $header = <<EOF;
|
||||||
dps[0].push(result[0][0]);
|
dps[0].push(result[0][0]);
|
||||||
chart.render();
|
chart.render();
|
||||||
var snr = (result[0][0].y[1] * -1) - (result[0][0].y[0] * -1);
|
var snr = (result[0][0].y[1] * -1) - (result[0][0].y[0] * -1);
|
||||||
|
toneFreq(snr);
|
||||||
\$('#snr').html(snr);
|
\$('#snr').html(snr);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -170,6 +171,33 @@ $header = <<EOF;
|
||||||
}
|
}
|
||||||
chart.render();
|
chart.render();
|
||||||
}); // --- document.ready
|
}); // --- document.ready
|
||||||
|
|
||||||
|
var audioCtx = new(window.AudioContext || window.webkitAudioContext)();
|
||||||
|
var oscillator = audioCtx.createOscillator();
|
||||||
|
var gainNode = audioCtx.createGain();
|
||||||
|
oscillator.connect(gainNode);
|
||||||
|
oscillator.type = 'sine';
|
||||||
|
gainNode.connect(audioCtx.destination);
|
||||||
|
gainNode.gain.value = 1;
|
||||||
|
|
||||||
|
function toneFreq(snr) {
|
||||||
|
oscillator.frequency.value = snr * 20;
|
||||||
|
}
|
||||||
|
|
||||||
|
function toneOn() {
|
||||||
|
oscillator = audioCtx.createOscillator();
|
||||||
|
gainNode = audioCtx.createGain();
|
||||||
|
oscillator.connect(gainNode);
|
||||||
|
oscillator.type = 'sine';
|
||||||
|
gainNode.connect(audioCtx.destination);
|
||||||
|
gainNode.gain.value = 1;
|
||||||
|
oscillator.start();
|
||||||
|
};
|
||||||
|
|
||||||
|
function toneOff() {
|
||||||
|
oscillator.stop();
|
||||||
|
};
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
EOF
|
EOF
|
||||||
|
@ -229,12 +257,11 @@ $page = $page . "<input type='hidden' name='realtime' value='1'></input>\n" if($
|
||||||
$page = $page . <<EOF;
|
$page = $page . <<EOF;
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div id="snrValues">
|
<div id="snrValues" style="float: left;">
|
||||||
<h2>
|
|
||||||
EOF
|
EOF
|
||||||
$page = $page . "SNR: <span id='snr'>0</span>dB" if($parms{"realtime"} eq "1");
|
$page = $page . "<div><h3>SNR: <span id='snr'>0</span>dB</h3></div>" if($parms{"realtime"} eq "1");
|
||||||
|
$page = $page . "<div style='float: right;'>Sound: <button onclick='toneOn();'>On</button> <button onclick='toneOff();'>Off</button></div>" if($parms{"realtime"} eq "1");
|
||||||
$page = $page . <<EOF;
|
$page = $page . <<EOF;
|
||||||
</h2>
|
|
||||||
</div>
|
</div>
|
||||||
<div id="chartContainer" style="width: 80%; height: 60%;"></div>
|
<div id="chartContainer" style="width: 80%; height: 60%;"></div>
|
||||||
</center>
|
</center>
|
||||||
|
|
Loading…
Reference in New Issue