more work
This commit is contained in:
parent
1ac8df3a3f
commit
3d85edfc98
|
@ -57,10 +57,19 @@ class Synth {
|
||||||
let globalAudioContext = new AudioContext();
|
let globalAudioContext = new AudioContext();
|
||||||
let synth = new Synth(globalAudioContext);
|
let synth = new Synth(globalAudioContext);
|
||||||
|
|
||||||
|
function toggleOscillator() {
|
||||||
|
synth.toggleOsc();
|
||||||
|
}
|
||||||
window.onload = function() {
|
window.onload = function() {
|
||||||
console.log("hello world!");
|
console.log("hello world!");
|
||||||
console.log(synth);
|
console.log(synth);
|
||||||
|
|
||||||
|
var selectedWaveType = document.querySelector("input[name='wave']");
|
||||||
|
selectedWaveType.addEventListener("change", () => {
|
||||||
|
let selectedWaveTypeValue = document.querySelector("input[name='wave']:checked").value;
|
||||||
|
console.log("the value of the wave has changed to" + selectedWaveTypeValue);
|
||||||
|
synth.setOscWaveType(selectedWaveTypeValue);
|
||||||
|
})
|
||||||
var detune = document.getElementById("detune");
|
var detune = document.getElementById("detune");
|
||||||
detune.addEventListener("input", () => {
|
detune.addEventListener("input", () => {
|
||||||
synth.setOscDetune(parseFloat(detune.value))
|
synth.setOscDetune(parseFloat(detune.value))
|
||||||
|
|
|
@ -10,7 +10,19 @@
|
||||||
|
|
||||||
|
|
||||||
<body class="bg-gray-900 p-10 mb-5">
|
<body class="bg-gray-900 p-10 mb-5">
|
||||||
|
|
||||||
<script src="single-voice-synth.js"></script>
|
<script src="single-voice-synth.js"></script>
|
||||||
<div class="flex justify-between"></div>
|
<div class="flex justify-between"></div>
|
||||||
|
<button onclick="toggleOscillator()">Start/Stop</button>
|
||||||
<input type="range" min="-40" max="40" value="0" class="slider" id="detune">
|
<input type="range" min="-40" max="40" value="0" class="slider" id="detune">
|
||||||
|
<form>
|
||||||
|
<input type="radio" id="sine" name="wave" value="sine" checked>
|
||||||
|
<label for="sine">Sine</label><br>
|
||||||
|
<input type="radio" id="triangle" name="wave" value="triangle">
|
||||||
|
<label for="triangle">Triangle</label><br>
|
||||||
|
<input type="radio" id="square" name="wave" value="square">
|
||||||
|
<label for="square">Square</label><br>
|
||||||
|
<input type="radio" id="sawtooth" name="wave" value="sawtooth">
|
||||||
|
<label for="sawtooth">Sawtooth</label>
|
||||||
|
</form>
|
||||||
</body>
|
</body>
|
||||||
|
|
Loading…
Reference in New Issue