module AudioEffects
  attr_accessor :presets

  def self.presets
    presets = ["generic",
               "paddedcell",
               "room",
               "bathroom",
               "livingroom",
               "stoneroom",
               "auditorium",
               "concerthall",
               "cave",
               "arena",
               "hangar",
               "carpetedhallway",
               "hallway",
               "stonecorridor",
               "alley",
               "forest",
               "city",
               "mountains",
               "quarry",
               "plain",
               "parkinglot",
               "sewerpipe",
               "underwater",
               "drugged",
               "dizzy",
               "psychotic",
               "castle_smallroom",
               "castle_shortpassage",
               "castle_mediumroom",
               "castle_largeroom",
               "castle_longpassage",
               "castle_hall",
               "castle_cupboard",
               "castle_courtyard",
               "castle_alcove",
               "factory_smallroom",
               "factory_shortpassage",
               "factory_mediumroom",
               "factory_largeroom",
               "factory_longpassage",
               "factory_hall",
               "factory_cupboard",
               "factory_courtyard",
               "factory_alcove",
               "icepalace_smallroom",
               "icepalace_shortpassage",
               "icepalace_mediumroom",
               "icepalace_largeroom",
               "icepalace_longpassage",
               "icepalace_hall",
               "icepalace_cupboard",
               "icepalace_courtyard",
               "icepalace_alcove",
               "spacestation_smallroom",
               "spacestation_shortpassage",
               "spacestation_mediumroom",
               "spacestation_largeroom",
               "spacestation_longpassage",
               "spacestation_hall",
               "spacestation_cupboard",
               "spacestation_alcove",
               "wooden_smallroom",
               "wooden_shortpassage",
               "wooden_mediumroom",
               "wooden_largeroom",
               "wooden_longpassage",
               "wooden_hall",
               "wooden_cupboard",
               "wooden_courtyard",
               "wooden_alcove",
               "sport_emptystadium",
               "sport_squashcourt",
               "sport_smallswimmingpool",
               "sport_largeswimmingpool",
               "sport_gymnasium",
               "sport_fullstadium",
               "sport_stadiumtannoy",
               "prefab_workshop",
               "prefab_schoolroom",
               "prefab_practiseroom",
               "prefab_outhouse",
               "prefab_caravan",
               "dome_tomb",
               "pipe_small",
               "dome_saintpauls",
               "pipe_longthin",
               "pipe_large",
               "pipe_resonant",
               "outdoors_backyard",
               "outdoors_rollingplains",
               "outdoors_deepcanyon",
               "outdoors_creek",
               "outdoors_valley",
               "mood_heaven",
               "mood_hell",
               "mood_memory",
               "driving_commentator",
               "driving_pitgarage",
               "driving_incar_racer",
               "driving_incar_sports",
               "driving_incar_luxury",
               "driving_fullgrandstand",
               "driving_emptygrandstand",
               "driving_tunnel",
               "city_streets",
               "city_subway",
               "city_museum",
               "city_library",
               "city_underpass",
               "city_abandoned",
               "dustyroom",
               "chapel",
               "smallwaterroom"]
    return presets
  end

  #I swear if I could compact this I would

  def self.eaxpreset(preset)
    preset.gsub!(/\\n/, "") #hhhhhhh rpg maker why

    puts preset # Debug logging

    if !presets.any? { |s| s.include?(preset) } && preset != ""
      print("Invalid preset \"" + preset + "\"")
      # Fun fact I dumped half an hour of my time figuring out why my escaping characters didn't work only to realize I was using /
      return
      # If it's an invalid preset setting it WILL segfault so we break execution here
    end

    effect = ALEffect::EAXReverb.new

    # VERY hacky method of calling load_preset with the supplied preset
    if $game_temp.disable_reverb == true
      effect.load_preset_generic
    else
      class_eval("effect.load_preset_#{preset}")
    end
    #Audio.bgm_set_al_effect(effect)
    Audio.bgs_set_al_effect(effect)
    #Audio.me_set_al_effect(effect)
    Audio.se_set_al_effect(effect)
  end
end
