1. void musique()
  2. {
  3. ac1 = new AudioContext();
  4. ac2 = new AudioContext();
  5. try {
  6. // initialize our SamplePlayer, loading the file
  7. // indicated by the sourceFile string
  8. musique_menu = new SamplePlayer(ac1, new Sample(sketchPath("data/son/musique/Musique_menu.mp3")));
  9. son_tir1 = new SamplePlayer(ac2, new Sample(sketchPath("data/son/bruitage/Laser-Shot-1.mp3")));
  10. son_tir2 = new SamplePlayer(ac2, new Sample(sketchPath("data/son/bruitage/Laser-Shot-2.mp3")));
  11. }
  12. catch(Exception e)
  13. {
  14. println("Exception while attempting to load sample!");
  15. e.printStackTrace();
  16. exit();
  17. }
  18. musique_menu.setKillOnEnd(false);
  19. g_musique = new Gain(ac1, 1, 0.05);
  20. g_son = new Gain(ac2, 1, 0.05);
  21. son_tir1.setLoopType(SamplePlayer.LoopType.LOOP_FORWARDS);
  22. g_musique.addInput(musique_menu);
  23. g_son.addInput(son_tir1);
  24. g_son.addInput(son_tir2);
  25. ac1.out.addInput(g_musique);
  26. ac2.out.addInput(son_tir1);
  27. ac2.out.addInput(son_tir2);
  28. ac1.start();
  29. ac2.start();
  30. }