feature: add volume control to signal tone (#353)

This commit is contained in:
dman776 2019-02-02 21:49:49 -06:00 committed by GitHub
parent 3abc82f529
commit 4eda661962
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 2 deletions

View File

@ -183,6 +183,8 @@ $header = <<EOF;
function toneFreq(snr) {
var p = document.getElementById("tonePitch").value;
oscillator.frequency.value = snr * p;
var v = document.getElementById("toneVol").value;
gainNode.gain.value = v;
}
function toneOn() {
@ -191,7 +193,7 @@ $header = <<EOF;
oscillator.connect(gainNode);
oscillator.type = 'sine';
gainNode.connect(audioCtx.destination);
gainNode.gain.value = 1;
gainNode.gain.value = .5;
oscillator.start();
document.getElementById("toneOff").disabled = false;
document.getElementById("toneOn").disabled = true;
@ -265,7 +267,14 @@ $page = $page . <<EOF;
<div id="snrValues" style="float: left;">
EOF
$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 id='toneOn' onclick='toneOn();'>On</button>&nbsp;<button id='toneOff' disabled onclick='toneOff();'>Off</button><br /><br />Pitch:&nbsp;<input type='range' id='tonePitch' name='tonePitch' min='5' max='100'></input></div>" if($parms{"realtime"} eq "1");
if($parms{"realtime"} eq "1") {
$page = $page . "<div style='float: right;'>Sound: <button id='toneOn' onclick='toneOn();'>On</button>&nbsp;";
$page = $page . "<button id='toneOff' disabled onclick='toneOff();'>Off</button><br /><br />";
$page = $page . "Pitch:&nbsp;<input type='range' id='tonePitch' name='tonePitch' min='5' max='100'></input><br /><br />";
$page = $page . "Volume:&nbsp;<input type='range' id='toneVol' name='toneVol' min='0' max='10'></input><br /><br />";
$page = $page . "</div>";
}
$page = $page . <<EOF;
</div>
<div id="chartContainer" style="width: 80%; height: 60%;"></div>