Changeset 513 for code/branches/FICN/src/audio/_AudioObject.cc
- Timestamp:
- Dec 13, 2007, 5:58:14 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/FICN/src/audio/_AudioObject.cc
r389 r513 1 /* 2 * ORXONOX - the hottest 3D action shooter ever to exist 3 * 4 * 5 * License notice: 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 * Author: 22 * ... 23 * Co-authors: 24 * ... 25 * 26 */ 27 28 1 29 #include <iostream> 2 30 #include <string> … … 33 61 34 62 // Initialize OpenAL and clear the error bit. 35 63 36 64 alutInit(NULL, 0); 37 65 alGetError(); 38 66 39 67 // Load the wav data. 40 68 41 69 if(LoadALData() == AL_FALSE) 42 70 { 43 71 printf("Error loading sound data."); 44 72 45 73 } 46 74 … … 48 76 std::cout << "Play sone ambient background sound"; 49 77 } 50 78 51 79 AudioObject::~AudioObject() 52 { 80 { 53 81 KillALData(); 54 82 } 55 83 56 84 ALboolean AudioObject::LoadALData() 57 85 { … … 61 89 ALsizei freq; 62 90 ALboolean loop; 63 64 91 92 65 93 alGenBuffers(1, &Buffer); 66 94 67 95 if(alGetError() != AL_NO_ERROR) 68 96 return AL_FALSE; 69 97 70 98 alutLoadWAVFile((ALbyte*)audioFile_.c_str(), &format, &data, &size, &freq, &loop); 71 99 alBufferData(Buffer, format, data, size, freq); 72 100 alutUnloadWAV(format, data, size, freq); 73 101 74 102 alGenSources(1, &Source); 75 103 76 104 if(alGetError() != AL_NO_ERROR) 77 105 return AL_FALSE; 78 106 79 107 alSourcei (Source, AL_BUFFER, Buffer ); 80 108 alSourcef (Source, AL_PITCH, 1.0 ); … … 83 111 alSourcefv(Source, AL_VELOCITY, SourceVel); 84 112 alSourcei (Source, AL_LOOPING, loop ); 85 113 86 114 if(alGetError() == AL_NO_ERROR) 87 115 return AL_TRUE; 88 89 116 117 90 118 return AL_FALSE; 91 } 119 } 92 120 93 121 void AudioObject::SetListenerValues() … … 97 125 alListenerfv(AL_ORIENTATION, ListenerOri); 98 126 } 99 127 100 128 void AudioObject::KillALData() 101 129 { … … 108 136 { 109 137 alSourcePlay(Source); 110 138 111 139 } 112 140 }
Note: See TracChangeset
for help on using the changeset viewer.