Skip to content

Commit

Permalink
add oan
Browse files Browse the repository at this point in the history
  • Loading branch information
EdricCantu committed Mar 22, 2024
1 parent 4944883 commit 5d4f12c
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions i.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Math.blog = (b,y)=>(Math.log(y)/Math.log(b))
modc = (f,c)=>(f/(2**(c/-1200)))
cdiff = (f1,f2)=>(1200*Math.blog(2, f2/f1));
var context, oscillator, gain;
var context, oscillator, gain, panner;
var x = 0;
// o s c f f c s o
var ids = "freq waves octvDown semiDown centDown freqDown playPause freqUp centUp semiUp octvUp volume volumeLabel".split(" ")
var ids = "pan freq waves octvDown semiDown centDown freqDown playPause freqUp centUp semiUp octvUp volume volumeLabel".split(" ")
for(const id of ids){
window[id] = document.getElementById(id);
}
Expand Down Expand Up @@ -33,7 +33,9 @@ function initOsc(){
if(!(x++)){
context = new AudioContext();
gain = context.createGain();
gain.connect(context.destination);
panner = context.createStereoPanner();
panner.connect(context.destination);
gain.connect(panner);
}
gain.gain.value = 0;//nvm, starting wo popping
oscillator = context.createOscillator();
Expand Down Expand Up @@ -268,6 +270,11 @@ volume.addEventListener("input", ()=>{
if(gain) gain.gain.value = volume.value;
});

pan.addEventListener("input", ()=>{

if(panner) panner.pan.value = pan.value;
});

freqRange.addEventListener("input", ()=>{
changeFreq(
Math.round(modc(1,freqRange.value) * 1000) / 1000
Expand Down

0 comments on commit 5d4f12c

Please sign in to comment.