#include <windows.h>
#include "shared.h"
#include "tll.h"
#include "vector.h"
#include "bass.h"
Go to the source code of this file.
Compounds | |
class | SOUND_CHANNEL |
class | SOUND_SAMPLE |
Enumerations | |
enum | { sample_gunshot = 1 } |
enum | { channel_gunshot = 1 } |
Functions | |
void | InitializeBASS () |
void | LoadSample (SOUND_SAMPLE *Sample) |
void | CreateChannel (int SampleNumber) |
void | UpdateListener () |
void | UpdateChannel (int ChannelNumber, VECTOR *Position, VECTOR *Orientation, VECTOR *Velocity) |
void | PlayChannel (int ChannelNumber) |
VOID CALLBACK | SoundTimerProc (HWND hWnd, UINT uMsg, UINT idEvent, DWORD dwTime) |
void | CreateSounds () |
BOOL CALLBACK | devicedialogproc (HWND h, UINT m, WPARAM w, LPARAM l) |
|
Definition at line 13 of file sound.h.
00013 {sample_gunshot = 1}; |
|
Definition at line 15 of file sound.h.
00015 {channel_gunshot = 1}; |
|
Definition at line 81 of file sound.cpp. References LinkedList< T >::Get(), SOUND_SAMPLE::hSample, SOUND_CHANNEL::hSample, LinkedList< T >::Insert(), SOUND_CHANNEL::linkPosition, and numChannels. Referenced by CreateSounds().
00082 { 00083 SOUND_SAMPLE* Sample = SampleList.Get(SampleNumber); 00084 SOUND_CHANNEL* Channel = new SOUND_CHANNEL; 00085 Channel->hSample = Sample->hSample; 00086 Channel->linkPosition = ++numChannels; 00087 ChannelList.Insert(Channel); 00088 } |
|
Definition at line 176 of file sound.cpp. References CreateChannel(), SOUND_SAMPLE::flags, LoadSample(), SOUND_SAMPLE::max, SOUND_SAMPLE::maxdist, SOUND_SAMPLE::mindist, SOUND_SAMPLE::name, sample_gunshot, and SOUND_SAMPLE::volume. Referenced by InitGL().
00177 { 00178 SOUND_SAMPLE* Sample; 00179 VECTOR Position; 00180 00181 // gunshot sound 00182 Sample = new SOUND_SAMPLE; 00183 sprintf(Sample->name, "%s", "gunshot.wav"); 00184 Sample->max = 10; 00185 Sample->volume = 100; 00186 Sample->mindist = 10.0; 00187 Sample->maxdist = 1000.0; 00188 Sample->flags = BASS_SAMPLE_OVER_DIST | BASS_SAMPLE_3D | BASS_SAMPLE_VAM; 00189 LoadSample(Sample); 00190 00191 CreateChannel(sample_gunshot); 00192 } |
|
Definition at line 196 of file sound.cpp. References device, and lowqual.
00197 { 00198 switch (m) { 00199 case WM_COMMAND: 00200 switch (LOWORD(w)) { 00201 case ID_DEVLIST: 00202 if (HIWORD(w)==LBN_SELCHANGE) 00203 device=SendMessage((HWND)l,LB_GETCURSEL,0,0); 00204 else if (HIWORD(w)==LBN_DBLCLK) 00205 EndDialog(h,0); 00206 break; 00207 case ID_LOWQUAL: 00208 lowqual=SendDlgItemMessage(h,ID_LOWQUAL,BM_GETCHECK,0,0); 00209 break; 00210 case IDOK: 00211 EndDialog(h,0); 00212 return 1; 00213 } 00214 break; 00215 00216 case WM_INITDIALOG: 00217 { 00218 char text[100],*d; 00219 int c; 00220 for (c=0;BASS_GetDeviceDescription(c,&d);c++) { 00221 strcpy(text,d); 00222 /* Check if the device supports 3D - don't bother with sync/update threads */ 00223 if (!BASS_Init(c,44100,BASS_DEVICE_3D|BASS_DEVICE_NOSYNC|BASS_DEVICE_NOTHREAD,h)) 00224 continue; // no 3D support 00225 if (BASS_GetEAXParameters(NULL,NULL,NULL,NULL)) 00226 strcat(text," [EAX]"); // it has EAX 00227 BASS_Free(); 00228 SendDlgItemMessage(h,ID_DEVLIST,LB_ADDSTRING,0,(LONG)text); 00229 } 00230 SendDlgItemMessage(h,ID_DEVLIST,LB_SETCURSEL,0,0); 00231 } 00232 device=lowqual=0; 00233 return 1; 00234 } 00235 return 0; 00236 } |
|
Definition at line 40 of file sound.cpp. References device, hWnd, and lowqual. Referenced by InitGL().
00041 { 00042 /* Check that BASS 1.4 was loaded */ 00043 if (BASS_GetVersion() != MAKELONG(1, 4)) 00044 MessageBox(0, "BASS version 1.4 was not loaded", "Incorrect BASS.DLL", 0); 00045 00046 /* Initialize the output device (syncs not used) */ 00047 if (!BASS_Init(device, lowqual?22050:44100, BASS_DEVICE_3D, hWnd)) 00048 MessageBox(0, "Could not initialize output device", "Error", 0); 00049 00050 /* Use meters as distance unit, real world rolloff, real doppler effect */ 00051 BASS_Set3DFactors(1.0, 1.0, 1.0); 00052 00053 /* Turn EAX off (volume=0.0), if error then EAX is not supported */ 00054 BASS_SetEAXParameters(-1, 0.0, -1.0, -1.0); 00055 00056 BASS_Start(); /* Start digital output */ 00057 } |
|
Definition at line 60 of file sound.cpp. References FALSE, SOUND_SAMPLE::flags, SOUND_SAMPLE::hSample, LinkedList< T >::Insert(), SOUND_SAMPLE::linkPosition, SOUND_SAMPLE::max, SOUND_SAMPLE::maxdist, SOUND_SAMPLE::mindist, SOUND_SAMPLE::name, numSamples, and SOUND_SAMPLE::volume. Referenced by CreateSounds().
00061 { 00062 /* Load a sample from a file */ 00063 Sample->hSample = BASS_SampleLoad(FALSE, Sample->name, 0, 0, Sample->max, Sample->flags); 00064 if (Sample->hSample) 00065 { 00066 BASS_SAMPLE sampleInfo; 00067 BASS_SampleGetInfo(Sample->hSample, &sampleInfo); 00068 00069 sampleInfo.volume = Sample->volume; 00070 sampleInfo.mindist = Sample->mindist; 00071 sampleInfo.maxdist = Sample->maxdist; 00072 BASS_SampleSetInfo(Sample->hSample, &sampleInfo); 00073 00074 Sample->linkPosition = ++numSamples; 00075 SampleList.Insert(Sample); 00076 } 00077 else 00078 MessageBox(NULL,"Could not load sound sample","Error",MB_OK|MB_ICONERROR); 00079 } |
|
Definition at line 149 of file sound.cpp. References LinkedList< T >::Get(), SOUND_CHANNEL::hChannel, SOUND_CHANNEL::hSample, SOUND_CHANNEL::position, and SOUND_CHANNEL::velocity. Referenced by SoundTimerProc(), and WinMain().
00150 { 00151 SOUND_CHANNEL* Channel = ChannelList.Get(ChannelNumber); 00152 Channel->hChannel = BASS_SamplePlay3D(Channel->hSample, &Channel->position, NULL, &Channel->velocity); 00153 00154 char temp[256]; 00155 int result = BASS_ErrorGetCode(); 00156 if (result) 00157 { 00158 sprintf(temp, "BASS error code No. %d", result); 00159 MessageBox(NULL, temp, "Error", MB_OK|MB_ICONERROR); 00160 } 00161 } |
|
Definition at line 163 of file sound.cpp. References LinkedList< T >::Get(), hWnd, SOUND_CHANNEL::intermittent, SOUND_CHANNEL::looped, SOUND_CHANNEL::lowerrand, PlayChannel(), SOUND_CHANNEL::random, SoundTimerProc(), and SOUND_CHANNEL::upperrand. Referenced by SoundTimerProc().
00164 { 00165 SOUND_CHANNEL* Channel = ChannelList.Get((int)idEvent); 00166 PlayChannel((int)idEvent); 00167 if ((Channel->looped && !Channel->intermittent) || !Channel->looped) 00168 KillTimer(hWnd, idEvent); 00169 if (Channel->looped && Channel->intermittent && Channel->random) 00170 { 00171 int randomtime = (rand()%(Channel->upperrand - Channel->lowerrand)) + Channel->lowerrand; 00172 SetTimer(hWnd, idEvent, randomtime, (TIMERPROC)SoundTimerProc); 00173 } 00174 } |
|
Definition at line 118 of file sound.cpp. References LinkedList< T >::Get(), SOUND_CHANNEL::hChannel, SOUND_CHANNEL::orientation, SOUND_CHANNEL::position, SOUND_CHANNEL::velocity, VECTOR::x, VECTOR::y, and VECTOR::z. Referenced by DrawGLScene().
00119 { 00120 SOUND_CHANNEL* Channel = ChannelList.Get(ChannelNumber); 00121 00122 if (Position) 00123 { 00124 Channel->position.x = Position->x; 00125 Channel->position.y = Position->y; 00126 Channel->position.z = Position->z; 00127 } 00128 if (Orientation) 00129 { 00130 Channel->orientation.x = Orientation->x; 00131 Channel->orientation.y = Orientation->y; 00132 Channel->orientation.z = Orientation->z; 00133 } 00134 if (Velocity) 00135 { 00136 Channel->velocity.x = Velocity->x; 00137 Channel->velocity.y = Velocity->y; 00138 Channel->velocity.z = Velocity->z; 00139 } 00140 00141 /* If the channel's playing then update it's position */ 00142 if (BASS_ChannelIsActive(Channel->hChannel)) 00143 BASS_ChannelSet3DPosition(Channel->hChannel, &Channel->position, NULL, &Channel->velocity); 00144 00145 /* Apply the 3D changes */ 00146 BASS_Apply3D(); 00147 } |
|
Definition at line 90 of file sound.cpp. References currentCamera, Front, OBJECT::Position, VECTOR::x, VECTOR::y, and VECTOR::z. Referenced by DrawGLScene().
00091 { 00092 BASS_3DVECTOR Player; 00093 BASS_3DVECTOR Bass_Front; 00094 BASS_3DVECTOR Bass_Top; 00095 BASS_3DVECTOR Bass_Velocity; 00096 00097 Player.x = camera[currentCamera].Position.x; // Get the player's position 00098 Player.y = camera[currentCamera].Position.y; 00099 Player.z = camera[currentCamera].Position.z; 00100 VECTOR Front = camera[currentCamera].GetZUnit(); // Get the player's front vector 00101 VECTOR Top = camera[currentCamera].GetYUnit(); // Get the player's up vector 00102 Bass_Front.x = -Front.x; // Reverse the front vector for OpenGL 00103 Bass_Front.y = -Front.y; 00104 Bass_Front.z = -Front.z; 00105 Bass_Top.x = Top.x; 00106 Bass_Top.y = Top.y; 00107 Bass_Top.z = Top.z; 00108 Bass_Velocity.x = camera[currentCamera].Position.x - LastCam.Position.x; 00109 Bass_Velocity.y = camera[currentCamera].Position.y - LastCam.Position.y; 00110 Bass_Velocity.z = camera[currentCamera].Position.z - LastCam.Position.z; 00111 00112 BASS_Set3DPosition(&Player, &Bass_Velocity, &Bass_Front, &Bass_Top); // Make changes to the player position/orientation 00113 00114 /* Apply the 3D changes */ 00115 BASS_Apply3D(); 00116 } |