//*description: Synthesize sound and play frequencies / notes.
 ///maybe also check out: https://www.youtube.com/watch?v=Bk8rLzzSink
 

let wave;
let button;
let playing;

function setup() {
     let canvas;
     if (windowWidth > 1200) {
         img = loadImage("assets/studio.png");
         canvas = createCanvas(1920, 630);
     } else if (windowWidth > 900) {
         img = loadImage("assets/studio-tablet-wide.png");
         canvas = createCanvas(1200, 394);
     } else {
         img = loadImage("assets/studio-tablet-tall.png");
         canvas = createCanvas(700, 230);
     }
     canvas.parent('header'); //keep everything up to this

     button = createButton('-_-_-_-_Steam Button-_-_-_-_-');
     button.mousePressed(turnOn);
     button.position (100,300);
     
     slider = createSlider(100, 1000, 30);
     slider.position (100,400);
     
     wave = new p5.Oscillator('sine'); }





draw = () => {  
if (playing){
    wave.amp(3);
    wave.freq(slider.value()); 
    } 
}

turnOn = () => {
   if (!playing){
        playing = true;
        wave.start();
        background(25,156,200);
   
   } else {
        playing = false
        wave.stop();
        background(211,192,50);
   }
}
