2005-02-27 05:55:18 +00:00
|
|
|
//This file is part of Photon (http://photon.sourceforge.net)
|
|
|
|
//Copyright (C) 2004-2005 James Turk
|
|
|
|
//
|
|
|
|
// Author:
|
|
|
|
// James Turk (jpt2433@rit.edu)
|
|
|
|
//
|
|
|
|
// Version:
|
2005-08-08 19:19:21 +00:00
|
|
|
// $Id: AudioCore.hpp,v 1.13 2005/08/08 19:19:25 cozman Exp $
|
2005-07-04 03:06:48 +00:00
|
|
|
|
|
|
|
#ifdef PHOTON_USE_OPENAL
|
2005-02-27 05:55:18 +00:00
|
|
|
|
|
|
|
#ifndef PHOTON_AUDIO_AUDIOCORE_HPP
|
|
|
|
#define PHOTON_AUDIO_AUDIOCORE_HPP
|
|
|
|
|
2005-08-08 19:19:21 +00:00
|
|
|
#include "AL/al.h" // This file depends on OpenAL
|
2005-04-21 19:30:19 +00:00
|
|
|
#include "AL/alc.h"
|
2005-02-27 05:55:18 +00:00
|
|
|
|
|
|
|
#include "util/VersionInfo.hpp"
|
|
|
|
|
|
|
|
namespace photon
|
|
|
|
{
|
|
|
|
namespace audio
|
|
|
|
{
|
|
|
|
|
2005-03-01 07:51:23 +00:00
|
|
|
// Class: AudioCore
|
2005-08-02 23:07:51 +00:00
|
|
|
// Photon's core for audio manipulation/control. Defines the interface through
|
|
|
|
// which all audio related functions are performed.
|
|
|
|
class AudioCore
|
2005-02-27 05:55:18 +00:00
|
|
|
{
|
2005-03-01 07:51:23 +00:00
|
|
|
|
2005-03-14 05:34:08 +00:00
|
|
|
// Group: (Con/De)structors
|
|
|
|
public:
|
|
|
|
// Function: AudioCore
|
|
|
|
// Initialize underlying APIs and setup <Task> internals.
|
2005-08-02 23:07:51 +00:00
|
|
|
//AudioCore();
|
2005-07-19 05:56:08 +00:00
|
|
|
AudioCore(const std::string& deviceName);
|
2005-08-02 23:07:51 +00:00
|
|
|
|
2005-03-14 05:34:08 +00:00
|
|
|
// Function: ~AudioCore
|
|
|
|
// Shutdown underlying APIs.
|
|
|
|
~AudioCore();
|
|
|
|
|
2005-03-01 07:51:23 +00:00
|
|
|
// Group: Accessors
|
2005-02-27 05:55:18 +00:00
|
|
|
public:
|
2005-03-01 07:51:23 +00:00
|
|
|
// Function: getAudioDeviceName
|
|
|
|
// Get name of active audio device.
|
|
|
|
//
|
|
|
|
// Returns:
|
|
|
|
// Name of audio device currently in use.
|
2005-02-27 05:55:18 +00:00
|
|
|
std::string getAudioDeviceName() const;
|
2005-07-05 06:44:55 +00:00
|
|
|
|
|
|
|
// Group: Error Checking
|
|
|
|
public:
|
2005-07-18 05:14:18 +00:00
|
|
|
// Function: checkOpenALError
|
|
|
|
// Checks for OpenAL internal errors, returning a descriptive string if
|
|
|
|
// the OpenAL error state is currently set. Will return an empty string
|
|
|
|
// if there is no error set.
|
|
|
|
//
|
|
|
|
// Returns:
|
|
|
|
// String describing OpenAL error, empty string if no error exists.
|
2005-07-05 06:44:55 +00:00
|
|
|
static std::string checkOpenALError();
|
2005-07-18 05:14:18 +00:00
|
|
|
|
|
|
|
// Function: throwOpenALError
|
|
|
|
// Checks for OpenAL internal errors, throwing an <APIError> if the OpenAL
|
|
|
|
// error state is set and doing nothing if not. Optionally makes the
|
|
|
|
// thrown exception more descriptive by adding in a function string
|
|
|
|
// that describes then the OpenAL error was flagged.
|
|
|
|
//
|
|
|
|
// Parameters:
|
|
|
|
// func - Function in/after which the check for an OpenAL error takes place
|
|
|
|
//
|
|
|
|
// Throws:
|
|
|
|
// <APIError> if an OpenAL error state has been set.
|
2005-07-05 06:44:55 +00:00
|
|
|
static void throwOpenALError(const std::string& func);
|
2005-03-14 05:34:08 +00:00
|
|
|
|
2005-03-01 07:51:23 +00:00
|
|
|
// OpenAL specifics
|
2005-02-27 05:55:18 +00:00
|
|
|
private:
|
2005-07-19 05:56:08 +00:00
|
|
|
util::VersionInfo initOpenAL(const std::string& deviceName);
|
2005-02-27 05:55:18 +00:00
|
|
|
|
2005-03-01 07:51:23 +00:00
|
|
|
// data members
|
2005-02-27 05:55:18 +00:00
|
|
|
private:
|
2005-07-05 06:44:55 +00:00
|
|
|
ALfloat listenerPos_[3];
|
|
|
|
ALfloat listenerVel_[3];
|
|
|
|
ALfloat listenerOri_[6];
|
2005-02-27 05:55:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif //PHOTON_AUDIO_AUDIOCORE_HPP
|
2005-07-04 03:06:48 +00:00
|
|
|
|
|
|
|
#endif //PHOTON_USE_OPENAL
|