title: How To Play Multiple Sounds in Unity 3D
body: <p>I´m developing an Augmented Reality piano with Vuforia and Unity 4.6. The app will be a game where the mobile phone will say a note, for example :"C" and the user will have 5 seconds to play the note in a paper piano with virtual buttons. </p>
  
  <p>The problem I´m having is that I´m not getting the sounds of the piano keys when I press a button. I do enter the desired case in the switch statement, but no sound is played.Neither the play() methods on the Update function or the OnButtonPressed() are playing. However on the method generarNota(). I always listen the sound of the phone saying the note.</p>
  
  <p>This is my code:</p>
  
  <pre><code>public class ButtonControl : MonoBehaviour,IVirtualButtonEventHandler {
      public AudioSource c;
      public AudioSource cSharp;
      public AudioSource d;
      public AudioSource dSharp;
      public AudioSource e;
      public AudioSource f;
      public AudioSource fSharp;
      public AudioSource g;
      public AudioSource gSharp;
      public AudioSource a;
      public AudioSource aSharp;
      public AudioSource b;
      public AudioSource correctSound;
      public AudioSource incorrectSound;
      public AudioClip cv;
      public AudioClip cSharpv;
      public AudioClip dv;
      public AudioClip dSharpv;
      public AudioClip ev;
      public AudioClip fv;
      public AudioClip fSharpv;
      public AudioClip gv;
      public AudioClip gSharpv;
      public AudioClip av;
      public AudioClip aSharpv;
      public AudioClip bv;
      public AudioSource c2;
      public bool gameOn;
      string currentNote; //Nota genereada por el sistema
      string inputNote; //Nota presionada por el usuario
      public float waitTime; //Tiempo de espera entre notas
      public float resetWait; // Para reiniciar el tiempo de espera
      public int totalNotes;
      public int correctNotes;
      public int incorrectNotes;
      bool firstNote;
      bool beingHandled;
      public bool blackNotes;
      bool notePressed;
      //Use this for initialization
      void Start () {
          c.PlayOneShot(c.clip);
          blackNotes = false;
          this.notePressed = false;
          beingHandled = false;
          currentNote="NONE";
          waitTime = 0;
          firstNote = true;
          VirtualButtonBehaviour[] vbs = GetComponentsInChildren&lt;VirtualButtonBehaviour&gt;();
          for (int i = 0; i &lt; vbs.Length; ++i) {
              // Register with the virtual buttons TrackableBehaviour
              vbs[i].RegisterEventHandler(this);
          }
  
      }
      void generarNota(){
          if (blackNotes) {
                          int num = Random.Range (1, 13);
                          //StartCoroutine ("waitTimeDelay");
                          switch (num) {
                          case 1:
                                  Debug.Log ("Se genero C");
                                  int a = 0;
                                  currentNote = "C";
                                  audio.clip = this.cv;
                                  audio.PlayDelayed (0.5f);
      //this.aSource.PlayOneShot(this.cv);
                                  break;
                          case 2:
                                  Debug.Log ("Se genero C#");
                                  currentNote = "C#";
                                  audio.clip = this.cSharpv;
                                  audio.PlayDelayed (0.5f);
                                  break;
                          case 3:
                                  Debug.Log ("Se genero D");
                                  currentNote = "D";
                                  audio.clip = this.dv;
                                  audio.PlayDelayed (0.5f);
                                  break;
                          case 4:
                                  Debug.Log ("Se genero D#");
                                  currentNote = "D#";
                                  audio.clip = this.dSharpv;
                                  audio.PlayDelayed (0.5f);
                                  break;
                          case 5:
                                  Debug.Log ("Se genero E");
                                  currentNote = "E";
                                  audio.clip = this.ev;
                                  audio.PlayDelayed (0.5f);
                                  break;
                          case 6:
                                  Debug.Log ("Se genero F");
                                  currentNote = "F";
                                  audio.clip = this.fv;
                                  audio.PlayDelayed (0.5f);
                                  break;
                          case 7:
                                  Debug.Log ("Se genero F#");
                                  currentNote = "F#";
                                  audio.clip = this.fSharpv;
                                  audio.PlayDelayed (0.5f);
                                  break;
                          case 8:
                                  Debug.Log ("Se genero G");
                                  currentNote = "G";
                                  audio.clip = this.gv;
                                  audio.PlayDelayed (0.5f);
                                  break;
                          case 9:
                                  Debug.Log ("Se genero G#");
                                  currentNote = "G#";
                                  audio.clip = this.gSharpv;
                                  audio.PlayDelayed (0.5f);
                                  break;
                          case 10:
                                  Debug.Log ("Se genero A");
                                  currentNote = "A";
                                  audio.clip = this.av;
                                  audio.PlayDelayed (0.5f);
                                  break;
                          case 11:
                                  Debug.Log ("Se genero A#");
                                  currentNote = "A#";
                                  audio.clip = this.aSharpv;
                                  audio.PlayDelayed (0.5f);
                                  break;
                          case 12:
                                  Debug.Log ("Se genero B");
                                  currentNote = "B";
                                  audio.clip = this.bv;
                                  audio.PlayDelayed (0.5f);
                                  break;
                          }
                          this.totalNotes++;
                  } 
          else {
              int num = Random.Range (1, 8);
              //StartCoroutine ("waitTimeDelay");
              switch (num) {
              case 1:
                  Debug.Log ("Se genero C");
                  int a = 0;
                  currentNote = "C";
                  audio.clip = this.cv;
                  audio.PlayDelayed (0.5f);
                  //this.aSource.PlayOneShot(this.cv);
                  break;
  
              case 2:
                  Debug.Log ("Se genero D");
                  currentNote = "D";
                  audio.clip = this.dv;
                  audio.PlayDelayed (0.5f);
                  break;
  
              case 3:
                  Debug.Log ("Se genero E");
                  currentNote = "E";
                  audio.clip = this.ev;
                  audio.PlayDelayed (0.5f);
                  break;
              case 4:
                  Debug.Log ("Se genero F");
                  currentNote = "F";
                  audio.clip = this.fv;
                  audio.PlayDelayed (0.5f);
                  break;
  
              case 5:
                  Debug.Log ("Se genero G");
                  currentNote = "G";
                  audio.clip = this.gv;
                  audio.PlayDelayed (0.5f);
                  break;
  
              case 6:
                  Debug.Log ("Se genero A");
                  currentNote = "A";
                  audio.clip = this.av;
                  audio.PlayDelayed (0.5f);
                  break;
  
              case 7:
                  Debug.Log ("Se genero B");
                  currentNote = "B";
                  audio.clip = this.bv;
                  audio.PlayDelayed (0.5f);
                  break;
              }
              this.totalNotes++;
  
  
  
          }
  
      }
      void waitTimeDelay(){
  
  
      }
      // Update is called once per frame
      void Update () {
          if (this.gameOn) {
              if(this.waitTime&gt;0){
                  this.waitTime-= Time.deltaTime; 
                  //Verificamos el boton. Si esta presionado el correcto sumamos a las notas correctas
                  if(inputNote==this.currentNote){
                      //audio.clip = this.correctSound;
                      //audio.Play();
                      correctSound.Play();
                      this.correctNotes++;
                      inputNote ="NONE.";
                      this.waitTime = resetWait;
                      this.generarNota();
  
                  }
                  else if(inputNote!= "NONE." &amp;&amp; inputNote != this.currentNote){
                      //Si la nota es incorrecta, agregamos uno a las incorrectas y generamos una nueva nota
                      //audio.clip = this.incorrectSound;
                      //audio.Play();
                      incorrectSound.Play();
                      this.incorrectNotes++;
                      inputNote ="NONE.";
                      this.generarNota();
                      this.waitTime = resetWait;
                  }
                  //Generamos nueva nota
  
                  //Reiniciamos 
  
              }
              else{
                  //Reiniciamos el tiempo 
                  this.waitTime = this.resetWait;
                  if(!this.firstNote){
                      // Como no presiono nada, nota erronea
                      this.incorrectNotes++;
                      incorrectSound.Play();
                      //audio.clip = this.incorrectSound;
                      //audio.Play();
  
                      //this.aSource.PlayOneShot(this.incorrectSound);
  
  
  
                  }
                  else{
                      this.firstNote = false;
  
                  }
                  //generamos una nueva nota
                  this.generarNota();
  
  
              }
  
  
          }
  
  
      }
  
      public void OnButtonPressed(VirtualButtonAbstractBehaviour vb){
          if (blackNotes&amp;&amp;!notePressed) {
  
          switch (vb.VirtualButtonName) {
              case "buttonC":
                      this.inputNote = "C";
                      //audio.PlayOneShot (c);
                      break;
              case "buttonCSharp":
                      this.inputNote = "C#";
                      //audio.PlayOneShot (cSharp);
                      break;          
              case "buttonD":
                      this.inputNote = "D";
                      //audio.PlayOneShot (d);
                      break;
  
              case "buttonDSharp":
                      this.inputNote = "D#";
                      //audio.PlayOneShot (dSharp);
                      break;
  
              case "buttonE":
                      this.inputNote = "E";
                      //audio.PlayOneShot (e);
                      break;
              case "buttonF":
                      this.inputNote = "F";
                      //audio.PlayOneShot (f);
                      break;
              case "buttonFSharp":
                      this.inputNote = "F#";
                      //audio.PlayOneShot (fSharp);
                      break;
              case "buttonG":
                      this.inputNote = "G";
                      //audio.PlayOneShot (g);
  
                      break;
              case "buttonGSharp":
                      this.inputNote = "G#";
                      //audio.PlayOneShot (gSharp);
                      break;
              case "buttonA":
                      this.inputNote = "A";
                      //audio.PlayOneShot (a);
                      break;
              case "buttonASharp":
                      this.inputNote = "A#";
                      //audio.PlayOneShot (aSharp);
                      break;
  
              case "buttonB":
                      this.inputNote = "B";
                      //audio.PlayOneShot (b);
                      break;
              case "buttonC2":
                      this.inputNote = "C";
                      //audio.PlayOneShot (c2);
                      break;
              }
              notePressed=true;
                  } 
          else if(blackNotes==false &amp;&amp; notePressed==false){
  
              switch (vb.VirtualButtonName) {
              case "buttonC":
                  this.inputNote = "C";
                  Debug.Log ("Se Presiono C");
                  c.Play();
                  break;      
              case "buttonD":
                  this.inputNote = "D";
                  d.Play();
                  Debug.Log ("Se Presiono D");
                  break;
  
              case "buttonE":
                  this.inputNote = "E";
                  e.Play();
                  Debug.Log ("Se Presiono E");
                  break;
              case "buttonF":
                  this.inputNote = "F";
                  f.Play();
                  Debug.Log ("Se Presiono F");
                  break;
              case "buttonG":
                  this.inputNote = "G";
                  g.Play();
                  Debug.Log ("Se Presiono G");
                  break;
              case "buttonA":
                  this.inputNote = "A";
                  a.Play();
                  Debug.Log ("Se Presiono A");
                  break;
  
              case "buttonB":
                  this.inputNote = "B";
                  b.Play();
                             Debug.Log ("Se Presiono B");
                  break;
              case "buttonC2":
                  this.inputNote = "C";
                  c2.Play();
                  Debug.Log ("Se Presiono C2");
                  break;
              }
  
              notePressed=true;
          }
      }
          //If para cada tecla del piano
  
          //audio.PlayOneShot(myClip);
  
          //Comparamos si las notas son iguales.
          //Si son iguales, sonido correcto+generar una nueva nota+sumar contador de puntos
  
  
          //Si no son iguales--&gt; sonido de error+ terminar juego
  
  
  
  
      public void OnButtonReleased(VirtualButtonAbstractBehaviour vb){
          notePressed = false;
          this.inputNote = "NONE.";
          Debug.Log ("BUTTON UNPRESSED");
  
  
  
      }
  }
  </code></pre>
  
  <p>Here´s also my editor screenshot so you can check that I have audioclips attached to each audio source.
  <img src="https://i.stack.imgur.com/ux24H.png" alt="alt text"></p>
  
  <p>Can anyone help me  find where the problem is ?</p>