work on a simpler version of synth that works and then try to expand that

This commit is contained in:
2024-02-07 23:02:03 -08:00
parent 80052bb864
commit 37eabc79ca
4 changed files with 55 additions and 15 deletions

24
single-voice-synth.js Normal file
View File

@@ -0,0 +1,24 @@
class Synth {
constructor(audioContext, waveType = "sine", frequency = 400) {
this.audioContext = audioContext;
this.oscWaveType = waveType;
this.oscFrequency = frequency;
this.osc = this.audioContext.createOscillator();
this.osc.type = this.oscWaveType;
this.osc.frequency.setValueAtTime(this.oscFrequency, this.audioContext.currentTime);
}
setOscWaveType(type) {
this.oscWaveType = type;
this.osc.type = this.oscWaveType;
}
}
let globalAudioContext = new AudioContext();
let synth = new Synth(globalAudioContext);
window.onload = function() {
console.log("hello world!");
console.log(synth);
}