title: How to change oscillator frequency?
body: <p>I started to experiment with the <strong>Web Audio API</strong>, trying to create different oscillators to produce acoustic waves.</p>
  
  <p>Since I'm kinda new to the whole process, I'm wondering if there's a way to play tones, not with a constant frequency, but changing them midways.</p>
  
  <p><strong><em>Example:</em></strong>
  I want a tone, that starts at <strong>300 Hz</strong> for <strong>3 seconds</strong>, and then <strong>raise linearly</strong> to <strong>400 Hz</strong> over the next <strong>4 seconds</strong>.</p>
  
  <p>I fount this, but I'm not really sure if it is what I'm looking for:</p>
  
  <pre><code>osc.setPeriodicWave(wave);
  </code></pre>
  
  <p>My JavaScript so far:</p>
  
  <pre><code>$(document).ready(function() {
  
  // Function that plays the tone.
  var playTone = function(duration, frequency) {
  var context = new(window.AudioContext || window.webkitAudioContext)();
  var osc = context.createOscillator(); 
  // Sine is the default type. Also available: square, sawtooth and triangle waveforms.
  osc.type = 'sine'; 
  // Frequency in Hz.
  osc.frequency.value = frequency; // Frequency in Hz
  osc.connect(context.destination); 
  osc.start(context.currentTime);
  osc.stop(context.currentTime + duration);
  }
  
  // Button and input functionality.
  $("button").on("click", function() {
  
  var whichButton = $(this).text()
  var duration = document.getElementById("durationInput").value;
  var frequency = document.getElementById("f1Input").value;
  if (whichButton == "  Play") {
    playTone(duration, frequency); 
  }
  
  });
  
  });
  </code></pre>
  
  <p><em>My codepen with the work so far:</em>  <a href="http://codepen.io/KonSal/pen/PGLEvK?editors=1010" rel="nofollow">Codepen.io - Acoustic wave generator</a></p>