package electrosphere.audio;

import electrosphere.logger.LoggerInterface;
import electrosphere.main.Globals;
import org.joml.Vector3f;

/**
 *
 * @author amaterasu
 */
public class AudioUtils {
    
    
    public static AudioSource playAudioAtLocation(String audioFile, Vector3f position){
        AudioSource rVal = null;
        AudioBuffer buffer = Globals.assetManager.fetchAudio(audioFile);
        if(buffer != null){
            rVal = new AudioSource(false,false);
            rVal.setBuffer(buffer.getBufferId());
            rVal.setGain(Globals.audioEngine.getGain());
            rVal.setPosition(position);
            rVal.play();
        } else {
            LoggerInterface.loggerEngine.WARNING("Failed to start audio in playAudioAtLocation");
        }
        return rVal;
    }
    
}
