work on a simpler version of synth that works and then try to expand that
This commit is contained in:
24
single-voice-synth.js
Normal file
24
single-voice-synth.js
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user