fixes not connected to destination issue
This commit is contained in:
parent
3cb0784e39
commit
dc1bc9df2d
|
@ -3,6 +3,7 @@ class Synth {
|
|||
this.audioContext = audioContext;
|
||||
this.oscWaveType = waveType;
|
||||
this.oscFrequency = frequency;
|
||||
this.isPlaying = false;
|
||||
|
||||
// osc setup
|
||||
this.osc = this.audioContext.createOscillator();
|
||||
|
@ -18,6 +19,7 @@ class Synth {
|
|||
|
||||
startOsc() {
|
||||
this.osc.start();
|
||||
this.isPlaying = true;
|
||||
}
|
||||
|
||||
stopOsc() {
|
||||
|
@ -30,6 +32,17 @@ class Synth {
|
|||
console.log(this.osc);
|
||||
this.osc.type = currentType;
|
||||
this.osc.frequency.setValueAtTime(currentFreq, this.audioContext.currentTime);
|
||||
this.osc.connect(this.audioContext.destination);
|
||||
this.isPlaying = false;
|
||||
}
|
||||
|
||||
toggleOsc() {
|
||||
|
||||
if (this.isPlaying === false) {
|
||||
this.startOsc();
|
||||
} else {
|
||||
this.stopOsc();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue