function Oscillator(freq, type) {
    oscillator_classCallCheck(this, Oscillator);
    if (typeof freq === 'string') {
      var f = type;
      type = freq;
      freq = f;
    }
    if (typeof type === 'number') {
      var _f = type;
      type = freq;
      freq = _f;
    }
    this.started = false;

    this.phaseAmount = undefined;
    this.oscillator = main.audiocontext.createOscillator();
    this.f = freq || 440.0; 
    this.oscillator.type = type || 'sine';
    this.oscillator.frequency.setValueAtTime(this.f, main.audiocontext.currentTime);

    this.output = main.audiocontext.createGain();
    this._freqMods = []; 

    this.output.gain.value = 0.5;
    this.output.gain.setValueAtTime(0.5, main.audiocontext.currentTime);
    this.oscillator.connect(this.output);
    this.connection = main.input; 

    this.panner = new panner_0();
    this.output.connect(this.panner);

    this.mathOps = [];

    main.soundArray.push(this);

    this.fade = this.amp;
  }
<p>Creates a signal that oscillates between -1.0 and 1.0.
 By default, the oscillation takes the form of a sinusoidal
 shape ('sine'). Additional types include 'triangle',
 'sawtooth' and 'square'. The frequency defaults to
 440 oscillations per second (440Hz, equal to the pitch of an
 'A' note).</p>

 <p>Set the type of oscillation with setType(), or by instantiating a
 specific oscillator: <a href="/reference/#/p5.SinOsc">p5.SinOsc</a>, <a
 href="/reference/#/p5.TriOsc">p5.TriOsc</a>, <a
 href="/reference/#/p5.SqrOsc">p5.SqrOsc</a>, or <a
 href="/reference/#/p5.SawOsc">p5.SawOsc</a>.
 </p>

 @class p5.Oscillator
 @constructor
 @param {Number} [freq] frequency defaults to 440Hz
 @param {String} [type] type of oscillator. Options:
                        'sine' (default), 'triangle',
                        'sawtooth', 'square'
 @example
 <div><code>
 let osc, playing, freq, amp;

 function setup() {
   let cnv = createCanvas(100, 100);
   cnv.mousePressed(playOscillator);
   osc = new p5.Oscillator('sine');
 }

 function draw() {
   background(220)
   freq = constrain(map(mouseX, 0, width, 100, 500), 100, 500);
   amp = constrain(map(mouseY, height, 0, 0, 1), 0, 1);

   text('tap to play', 20, 20);
   text('freq: ' + freq, 20, 40);
   text('amp: ' + amp, 20, 60);

   if (playing) {
     // smooth the transitions by 0.1 seconds
     osc.freq(freq, 0.1);
     osc.amp(amp, 0.1);
   }
 }

 function playOscillator() {
   // starting an oscillator on a user gesture will enable audio
   // in browsers that have a strict autoplay policy.
   // See also: userStartAudio();
   osc.start();
   playing = true;
 }

 function mouseReleased() {
   // ramp amplitude to 0 over 0.5 seconds
   osc.amp(0, 0.5);
   playing = false;
 }
 </code> </div>