title: Playing two notes in tone.js on one button click
body: <p>I am developing a web game where clicking on one button should play two notes consecutively. I am able to do it using uploaded audio files and audio.onended callback.</p>
  
  <pre><code>function playMusic(){
      audio.src = music_array[music_counter++];
      audio.play();
      audio.onended = function(){
          playMusic();
      };
  }
  </code></pre>
  
  <p>I can use the above code block to play an entire song. However, using this approach I would need to upload all the audio files to the html beforehand and I don't think that is a good approach. So, I was looking into <a href="https://tonejs.github.io/" rel="nofollow noreferrer">tone.js</a> for the same purpose, but I am not able to play notes one after the other. I have tried using for loop like this:</p>
  
  <pre><code>music = ["C4;4n", "D4;4n", ...... , "G5;8n"];
  for(var i=0; i&lt;range; i++){
      parts = music[music_counter++].split(';');
      synth.triggerAttackRelease(parts[0], parts[1]);
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>for(var i=0; i&lt;range; i++){
      playNote();
  }
  
  playNote(){
      parts = music[music_counter++].split(';');
      synth.triggerAttackRelease(parts[0], parts[1]);
  }
  </code></pre>
  
  <p>with no luck. I have looked into their documentation and other stackoverflow posts as well. I haven't been able to figure out the solution. Does anybody have any ideas how to achieve this?</p>