Blender  V2.59
AUD_Space.h
Go to the documentation of this file.
00001 /*
00002  * $Id: AUD_Space.h 35141 2011-02-25 10:21:56Z jesterking $
00003  *
00004  * ***** BEGIN GPL LICENSE BLOCK *****
00005  *
00006  * Copyright 2009-2011 Jörg Hermann Müller
00007  *
00008  * This file is part of AudaSpace.
00009  *
00010  * Audaspace is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version.
00014  *
00015  * AudaSpace is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License
00021  * along with Audaspace; if not, write to the Free Software Foundation,
00022  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00023  *
00024  * ***** END GPL LICENSE BLOCK *****
00025  */
00026 
00032 #ifndef AUD_SPACE
00033 #define AUD_SPACE
00034 
00036 #define AUD_FORMAT_SIZE(format) (format & 0x0F)
00037 
00038 #define AUD_DEVICE_SAMPLE_SIZE(specs) (specs.channels * (specs.format & 0x0F))
00039 
00040 #define AUD_SAMPLE_SIZE(specs) (specs.channels * sizeof(sample_t))
00041 
00042 #define AUD_THROW(exception, errorstr) { AUD_Exception e; e.error = exception; e.str = errorstr; throw e; }
00043 
00045 #define AUD_MIN(a, b) (((a) < (b)) ? (a) : (b))
00046 
00047 #define AUD_MAX(a, b) (((a) > (b)) ? (a) : (b))
00048 
00049 // 5 sec * 44100 samples/sec * 4 bytes/sample * 6 channels
00051 #define AUD_BUFFER_RESIZE_BYTES 5292000
00052 
00054 #define AUD_DEFAULT_BUFFER_SIZE 1024
00055 
00060 typedef enum
00061 {
00062         AUD_FORMAT_INVALID = 0x00,              
00063         AUD_FORMAT_U8      = 0x01,              
00064         AUD_FORMAT_S16     = 0x12,              
00065         AUD_FORMAT_S24     = 0x13,              
00066         AUD_FORMAT_S32     = 0x14,              
00067         AUD_FORMAT_FLOAT32 = 0x24,              
00068         AUD_FORMAT_FLOAT64 = 0x28               
00069 } AUD_SampleFormat;
00070 
00072 typedef enum
00073 {
00074         AUD_CHANNELS_INVALID    = 0,    
00075         AUD_CHANNELS_MONO       = 1,    
00076         AUD_CHANNELS_STEREO     = 2,    
00077         AUD_CHANNELS_STEREO_LFE = 3,    
00078         AUD_CHANNELS_SURROUND4  = 4,    
00079         AUD_CHANNELS_SURROUND5  = 5,    
00080         AUD_CHANNELS_SURROUND51 = 6,    
00081         AUD_CHANNELS_SURROUND61 = 7,    
00082         AUD_CHANNELS_SURROUND71 = 8,    
00083         AUD_CHANNELS_SURROUND72 = 9             
00084 } AUD_Channels;
00085 
00090 typedef enum
00091 {
00092         AUD_RATE_INVALID = 0,                   
00093         AUD_RATE_8000    = 8000,                
00094         AUD_RATE_16000   = 16000,               
00095         AUD_RATE_11025   = 11025,               
00096         AUD_RATE_22050   = 22050,               
00097         AUD_RATE_32000   = 32000,               
00098         AUD_RATE_44100   = 44100,               
00099         AUD_RATE_48000   = 48000,               
00100         AUD_RATE_88200   = 88200,               
00101         AUD_RATE_96000   = 96000,               
00102         AUD_RATE_192000  = 192000               
00103 } AUD_SampleRate;
00104 
00106 typedef enum
00107 {
00108         AUD_STATUS_INVALID = 0,                 
00109         AUD_STATUS_PLAYING,                             
00110         AUD_STATUS_PAUSED                               
00111 } AUD_Status;
00112 
00114 typedef enum
00115 {
00116         AUD_NO_ERROR = 0,
00117         AUD_ERROR_SPECS,
00118         AUD_ERROR_PROPS,
00119         AUD_ERROR_FILE,
00120         AUD_ERROR_SRC,
00121         AUD_ERROR_FFMPEG,
00122         AUD_ERROR_OPENAL,
00123         AUD_ERROR_SDL,
00124         AUD_ERROR_JACK,
00125 } AUD_Error;
00126 
00128 typedef enum
00129 {
00130         AUD_FADE_IN,
00131         AUD_FADE_OUT
00132 } AUD_FadeType;
00133 
00135 typedef enum
00136 {
00137         AUD_DISTANCE_MODEL_INVALID = 0,
00138         AUD_DISTANCE_MODEL_INVERSE,
00139         AUD_DISTANCE_MODEL_INVERSE_CLAMPED,
00140         AUD_DISTANCE_MODEL_LINEAR,
00141         AUD_DISTANCE_MODEL_LINEAR_CLAMPED,
00142         AUD_DISTANCE_MODEL_EXPONENT,
00143         AUD_DISTANCE_MODEL_EXPONENT_CLAMPED,
00144 } AUD_DistanceModel;
00145 
00147 typedef float sample_t;
00148 
00150 typedef unsigned char data_t;
00151 
00153 typedef struct
00154 {
00156         AUD_SampleRate rate;
00157 
00159         AUD_Channels channels;
00160 } AUD_Specs;
00161 
00163 typedef struct
00164 {
00166         AUD_SampleFormat format;
00167 
00168         union
00169         {
00170                 struct
00171                 {
00173                         AUD_SampleRate rate;
00174 
00176                         AUD_Channels channels;
00177                 };
00178                 AUD_Specs specs;
00179         };
00180 } AUD_DeviceSpecs;
00181 
00183 typedef struct
00184 {
00189         AUD_Error error;
00190 
00194         const char* str;
00195 
00196         // void* userData; - for the case it is needed someday
00197 } AUD_Exception;
00198 
00199 #endif //AUD_SPACE