class SE {
  AudioSample flick;
  AudioSample ignite;
  AudioSample damageEnemy;
  AudioSample damagePlayer;
  AudioSample openDoor;
  AudioSample noCandles;
  AudioSample collect;
  AudioSample menuConfirm;
  AudioSample gateOpen;
  AudioSample door;

  void initAllSounds() {
    flick = minim.loadSample("Assets/Sound/snd_ingame_throw_candle_01.wav");
    ignite = minim.loadSample("Assets/Sound/snd_triangle.wav");
    damageEnemy = minim.loadSample("Assets/Sound/snd_enemy_take_damage_01.wav");
    damagePlayer = minim.loadSample("Assets/Sound/snd_hero_take_damage_01.wav");
    openDoor = minim.loadSample("Assets/Sound/snd_ingame_gate_open.wav");
    noCandles = minim.loadSample("Assets/Sound/snd_no_more_candles.wav");
    collect = minim.loadSample("Assets/Sound/snd_collect_candle.wav");
    menuConfirm = minim.loadSample("Assets/Sound/snd_menu_confirm.wav");
    gateOpen = minim.loadSample("Assets/Sound/snd_ingame_gate_open.wav");
    door = minim.loadSample("Assets/Sound/snd_generic_button.wav");
  }
  void trigger(AudioSample a) {
    a.trigger();
  }
  void stop(AudioSample a) {
    a.stop();
  }

  void closeAll() {
    flick.close();
    ignite.close();
    damageEnemy.close();
    damagePlayer.close();
    openDoor.close();
    noCandles.close();
    collect.close();
    menuConfirm.close();
    gateOpen.close();
    door.close();
  }
}

void stop()
{
  SE.closeAll();
  BGMPlayer.close();
  minim.stop();
  super.stop();
}

String currentBGM;
void setBGM(String m){
  if (!m.equals(currentBGM)){
    BGMPlayer.pause();
    BGMPlayer = minim.loadFile("Assets/sound/"+m+".wav");
    BGMPlayer.loop();
    currentBGM = m;
  }
}

String currentBGS;
void setBGS(String m){
  if (!m.equals(currentBGS)){
    BGSPlayer.pause();
    BGSPlayer = minim.loadFile("Assets/sound/"+m+".wav");
    BGSPlayer.loop();
    currentBGM = m;
  }
}