/*
 * Copyright (C) 2006-2026 Metallizer, Solarus - http://www.solarus-games.org
 *
 * Solarus is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Solarus is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program. If not, see <http://www.gnu.org/licenses/>.
 */

#include "solarus/audio/ALWrapper.h"
#include "solarus/audio/AudioEffect.h"
#include "solarus/core/EnumInfo.h"
#include "solarus/core/Debug.h"
#include "solarus/core/Logger.h"

namespace Solarus
{

const std::string EnumInfoTraits<AudioEffectId>::pretty_name = "audio_effect";

const EnumInfo<AudioEffectId>::names_type EnumInfoTraits<AudioEffectId>::names = {
  { AudioEffectId::LOW_PASS, "low_pass" },
  { AudioEffectId::HIGH_PASS, "high_pass" },
  { AudioEffectId::REVERB, "reverb" },
  { AudioEffectId::ECHO, "echo" },
  { AudioEffectId::CHORUS, "chorus" },
  { AudioEffectId::FLANGER, "flanger" },
}; 

/**
 * \brief Default constructor.
 */
AudioEffect::AudioEffect() {
  effect = 0;
}

/**
 * \brief Constructor with a context identifier.
 * \param identifier The identifier of this context.
 */
AudioEffect::AudioEffect(AudioEffectId id)
  : id(id) {
}

void AudioEffect::create_slot() {
  // Create effect slot
  ALWrapper::generate_effect_slots(1, &auxiliary_slot, "create_slot");

  // Bind effect to slot
  ALWrapper::set_effect_slot_int(auxiliary_slot, AL_EFFECTSLOT_EFFECT, effect, "create_slot");
}

const ALuint& AudioEffect::get_auxiliary_slot() const {
  return auxiliary_slot;
}

} // namespace Solarus
