SoundHandlerAL.h

Go to the documentation of this file.
00001 /* -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 5 -*- */
00002 
00003 /*
00004  * Combination of a first person action and a real time strategy battle game.
00005  */
00006 
00007 /*
00008  * SoundHandlerAL.h
00009  * MetalWarriors
00010  * $Revision: 1.6 $
00011  *
00012  * Created by Daniel Aarno on Sun Oct 12 2003.
00013  * Copyright (c) 2003 Daniel Aarno and Erik Ytterberg - All rights reserved.
00014  *
00015  *     This program is free software; you can redistribute it and/or modify
00016  *     it under the terms of the GNU General Public License as published by
00017  *     the Free Software Foundation; either version 2 of the License, or
00018  *     (at your option) any later version.
00019  *
00020  *     This program is distributed in the hope that it will be useful,
00021  *     but WITHOUT ANY WARRANTY; without even the implied warranty of
00022  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023  *     GNU General Public License for more details.
00024  *
00025  *     You should have received a copy of the GNU General Public License
00026  *     along with this program; if not, write to the Free Software
00027  *     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00028  */
00029 
00030 #ifndef SOUNDHANDLERAL_H
00031 #define SOUNDHANDLERAL_H
00032 
00033 #include "SoundHandler.h"
00034 
00035 #include <list>
00036 #include <map>
00037 #if defined(__APPLE__) || defined(MACOSX)
00038 #include <OpenAL/al.h>
00039 #else
00040 #include <AL/al.h>
00041 #endif
00042 /*#include <AL/alc.h>
00043 #include <AL/alut.h>
00044 #include <AL/alext.h>*/
00045 /*
00046 typedef enum
00047   {
00048   //AL_SOURCE_TYPE                            
00049     SHAL_SOURCE_ABSOLUTE  = AL_SOURCE_ABSOLUTE,
00050     SHAL_SOURCE_RELATIVE  = AL_SOURCE_RELATIVE,                       
00051     SHAL_CONE_INNER_ANGLE = AL_CONE_INNER_ANGLE,                       
00052     SHAL_CONE_OUTER_ANGLE = AL_CONE_OUTER_ANGLE,                      
00053     SHAL_PITCH            = AL_PITCH,                                 
00054     SHAL_POSITION         = AL_POSITION,                              
00055     SHAL_DIRECTION        = AL_DIRECTION,                             
00056     SHAL_VELOCITY         = AL_VELOCITY,                            
00057     SHAL_LOOPING          = AL_LOOPING,                                
00058     SHAL_STREAMING        = AL_STREAMING,                            
00059     SHAL_BUFFER           = AL_BUFFER,                                 
00060     SHAL_GAIN             = AL_GAIN,
00061     SHAL_BYTE_LOKI        = AL_BYTE_LOKI,
00062     SHAL_MIN_GAIN         = AL_MIN_GAIN,
00063     SHAL_MAX_GAIN         = AL_MAX_GAIN,
00064     SHAL_ORIENTATION      = AL_ORIENTATION,
00065     SHAL_CHANNEL_MASK     = AL_CHANNEL_MASK,
00066     SHAL_SOURCE_STATE     = AL_SOURCE_STATE,
00067     SHAL_INITIAL          = AL_INITIAL,
00068     SHAL_PLAYING          = AL_PLAYING,
00069     SHAL_PAUSED           = AL_PAUSED,
00070     SHAL_STOPPED          = AL_STOPPED
00071     AL_BUFFERS_QUEUED                         
00072  AL_BUFFERS_PROCESSED                      
00073  AL_FORMAT_MONO8                           
00074  AL_FORMAT_MONO16                          
00075  AL_FORMAT_STEREO8                         
00076  AL_FORMAT_STEREO16                        
00077  AL_REFERENCE_DISTANCE                     
00078  AL_ROLLOFF_FACTOR                         
00079  AL_CONE_OUTER_GAIN                        
00080  AL_MAX_DISTANCE                           
00081  AL_FREQUENCY                              
00082  AL_BITS                                   
00083  AL_CHANNELS                               
00084  AL_SIZE                                   
00085  AL_DATA                                   
00086  AL_UNUSED                                 
00087  AL_PENDING                                
00088  AL_PROCESSED                              
00089  AL_NO_ERROR                               
00090  AL_INVALID_NAME                           
00091  AL_ILLEGAL_ENUM                           
00092  AL_INVALID_ENUM                           
00093  AL_INVALID_VALUE                          
00094  AL_ILLEGAL_COMMAND                        
00095  AL_INVALID_OPERATION                      
00096  AL_OUT_OF_MEMORY                          
00097  AL_VENDOR                                 
00098  AL_VERSION                                
00099  AL_RENDERER                               
00100  AL_EXTENSIONS                             
00101  AL_DOPPLER_FACTOR                         
00102  AL_DOPPLER_VELOCITY                       
00103  AL_DISTANCE_SCALE                         
00104  AL_DISTANCE_MODEL                         
00105  AL_INVERSE_DISTANCE                       
00106  AL_INVERSE_DISTANCE_CLAMPED               
00107  AL_ENV_ROOM_IASIG                         
00108  AL_ENV_ROOM_HIGH_FREQUENCY_IASIG          
00109  AL_ENV_ROOM_ROLLOFF_FACTOR_IASIG          
00110  AL_ENV_DECAY_TIME_IASIG                   
00111  AL_ENV_DECAY_HIGH_FREQUENCY_RATIO_IASIG   
00112  AL_ENV_REFLECTIONS_IASIG                  
00113  AL_ENV_REFLECTIONS_DELAY_IASIG            
00114  AL_ENV_REVERB_IASIG                       
00115  AL_ENV_REVERB_DELAY_IASIG                 
00116  AL_ENV_DIFFUSION_IASIG                    
00117  AL_ENV_DENSITY_IASIG                      
00118  AL_ENV_HIGH_FREQUENCY_REFERENCE_IASIG     
00119   }sound_attrib_t;
00120 */
00121 
00122 class SoundEmitterAL : public SoundEmitter
00123 {
00124 public:
00125      SoundEmitterAL();
00126      virtual ~SoundEmitterAL();
00127      
00128      virtual int addSound(const char *file_name);
00129      virtual void delSound(int sound_index);
00130      virtual void playSound(int sound);
00131      virtual void setUpdate(int sound_index, bool do_update);
00132 
00133      virtual void setPosition(int idx, float *v) {}
00134      virtual void setDirection(int idx, float *v) {}
00135      virtual void setVelocity(int idx, float *v) {}
00136      //...
00137      virtual void setGain(int idx, float gain) {}
00138      
00139      virtual void setPosition(float *position);
00140      virtual void setVelocity(float *velocity);
00141 
00142      virtual void update();
00143 };
00144 
00145 class SoundHandlerAL : public SoundHandler
00146 {
00147 public:
00148      SoundHandlerAL();
00149      virtual ~SoundHandlerAL() {}
00150      
00151      virtual int init(int argc, char** argv) ;
00152      virtual void setDirectionVector(float *direction) ;
00153 
00154      virtual SoundEmitter* allocNewEmitter();
00155      virtual void delEmitter(SoundEmitter *emitter);
00156   
00157      virtual int addSound(const char *file_name);
00158      virtual void masterVolume(float volume);
00159      
00160      virtual void update() ;
00161 };
00162 
00163 #endif /*SOUNDHANDLERAL_H*/

Generated on Sun Mar 11 15:33:23 2007 for MetalWarriors by  doxygen 1.4.7