- Timestamp:
- May 18, 2009, 4:52:26 PM (15 years ago)
- Location:
- code/branches/sound
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/sound/cmake/LibraryConfig.cmake
r2950 r2984 111 111 FIND_PACKAGE(OGRE 1.4 EXACT REQUIRED) 112 112 FIND_PACKAGE(ENet 1.1 REQUIRED) 113 #FIND_PACKAGE(Ogg REQUIRED)114 #FIND_PACKAGE(Vorbis REQUIRED)113 FIND_PACKAGE(Ogg REQUIRED) 114 FIND_PACKAGE(Vorbis REQUIRED) 115 115 FIND_PACKAGE(ALUT REQUIRED) 116 116 FIND_PACKAGE(ZLIB REQUIRED) -
code/branches/sound/src/orxonox/sound/SoundBase.cc
r2980 r2984 26 26 * 27 27 */ 28 #include <vector> 28 29 #include <AL/alut.h> 29 30 #include <vorbis/vorbisfile.h> … … 71 72 ALenum error = alGetError(); 72 73 if(error == AL_INVALID_VALUE) 73 COUT(2) << " OpenAL: Invalid sound position" << std::endl;74 COUT(2) << "Sound: OpenAL: Invalid sound position" << std::endl; 74 75 75 76 Vector3 vel = this->entity_->getVelocity(); … … 77 78 error = alGetError(); 78 79 if(error == AL_INVALID_VALUE) 79 COUT(2) << " OpenAL: Invalid sound position" << std::endl;80 COUT(2) << "Sound: OpenAL: Invalid sound velocity" << std::endl; 80 81 81 82 Quaternion orient = this->entity_->getOrientation(); … … 84 85 error = alGetError(); 85 86 if(error == AL_INVALID_VALUE) 86 COUT(2) << " OpenAL: Invalid sound position" << std::endl;87 COUT(2) << "Sound: OpenAL: Invalid sound direction" << std::endl; 87 88 } 88 89 } … … 133 134 bool SoundBase::loadFile(std::string filename) { 134 135 filename = Core::getMediaPathString() + "/audio/" + filename; 135 COUT(3) << " OpenAL ALUT: loading file " << filename << std::endl;136 COUT(3) << "Sound: OpenAL ALUT: loading file " << filename << std::endl; 136 137 this->buffer_ = alutCreateBufferFromFile(filename.c_str()); 137 138 if(this->buffer_ == AL_NONE) { 138 COUT(2) << " OpenAL ALUT: " << alutGetErrorString(alutGetError()) << std::endl;139 COUT(2) << "Sound: OpenAL ALUT: " << alutGetErrorString(alutGetError()) << std::endl; 139 140 if(filename.find("ogg", 0) != std::string::npos) 140 141 { … … 149 150 alSourcei(this->source_, AL_BUFFER, this->buffer_); 150 151 if(alGetError() != AL_NO_ERROR) { 151 COUT(2) << " OpenAL: Error loading sample file" << std::endl;152 COUT(2) << "Sound: OpenAL: Error loading sample file" << std::endl; 152 153 return false; 153 154 } … … 160 161 return state; 161 162 } 162 163 163 164 ALuint SoundBase::loadOggFile(std::string filename) 164 165 { 165 // just a dummy 166 return AL_NONE; 166 COUT(2) << "Sound: Trying fallback ogg loader"; 167 168 char inbuffer[4096]; 169 std::vector<char> outbuffer; 170 OggVorbis_File vf; 171 int eof = false; 172 int current_section; 173 174 FILE* f = fopen(filename.c_str(), "rb"); 175 176 if(ov_open(f, &vf, NULL, 0) < 0) 177 { 178 COUT(2) << "Sound: libvorbisfile: File seems not to be an Ogg Vorbis bitstream" << std::endl; 179 ov_clear(&vf); 180 return AL_NONE; 181 } 182 183 while(!eof) 184 { 185 long ret = ov_read(&vf, inbuffer, sizeof(inbuffer), 0, 2, 1, ¤t_section); 186 if (ret == 0) 187 { 188 eof = true; 189 } 190 else if (ret < 0) 191 { 192 COUT(2) << "Sound: libvorbisfile: error reading the file" << std::endl; 193 ov_clear(&vf); 194 return AL_NONE; 195 } 196 else 197 { 198 outbuffer.insert(outbuffer.end(), inbuffer, inbuffer + sizeof(inbuffer)); 199 } 200 } 201 202 ov_clear(&vf); 203 204 return alutCreateBufferFromFileImage(&outbuffer, outbuffer.size()); 167 205 } 168 206 } // namespace: orxonox -
code/branches/sound/src/orxonox/sound/SoundManager.cc
r2982 r2984 46 46 if(!alutInitWithoutContext(NULL,NULL)) 47 47 { 48 COUT(2) << " OpenAL ALUT: " << alutGetErrorString(alutGetError()) << std::endl;48 COUT(2) << "Sound: OpenAL ALUT: " << alutGetErrorString(alutGetError()) << std::endl; 49 49 } 50 50 else 51 51 { 52 COUT(4) << " OpenAL ALUT version:" << alutGetMajorVersion() << "." << alutGetMinorVersion() << std::endl;53 COUT(4) << " OpenAL ALUT supported MIME types:" << alutGetMIMETypes(ALUT_LOADER_BUFFER) << std::endl;52 COUT(4) << "Sound: OpenAL ALUT version:" << alutGetMajorVersion() << "." << alutGetMinorVersion() << std::endl; 53 COUT(4) << "Sound: OpenAL ALUT supported MIME types:" << alutGetMIMETypes(ALUT_LOADER_BUFFER) << std::endl; 54 54 if(SoundManager::device_s == NULL) 55 55 { 56 COUT(3) << " OpenAL: Open sound device..." << std::endl;56 COUT(3) << "Sound: OpenAL: Open sound device..." << std::endl; 57 57 SoundManager::device_s = alcOpenDevice(NULL); 58 58 } … … 60 60 if(SoundManager::device_s == NULL) 61 61 { 62 COUT(2) << " OpenAL: Could not open sound device" << std::endl;62 COUT(2) << "Sound: OpenAL: Could not open sound device" << std::endl; 63 63 } 64 64 else 65 65 { 66 COUT(3) << " OpenAL: Sound device opened" << std::endl;66 COUT(3) << "Sound: OpenAL: Sound device opened" << std::endl; 67 67 this->context_ = alcCreateContext(SoundManager::device_s, NULL); 68 68 if(this->context_ == NULL) 69 69 { 70 COUT(2) << " OpenAL: Could not create sound context" << std::endl;70 COUT(2) << "Sound: OpenAL: Could not create sound context" << std::endl; 71 71 } 72 72 else 73 73 { 74 74 if(alcMakeContextCurrent(this->context_) == AL_TRUE) 75 COUT(3) << " OpenAL: Context " << this->context_ << "loaded" << std::endl;75 COUT(3) << "Sound: OpenAL: Context " << this->context_ << "loaded" << std::endl; 76 76 } 77 77 } … … 127 127 ALenum error = alGetError(); 128 128 if(error == AL_INVALID_VALUE) 129 COUT(2) << " OpenAL: Invalid listener position" << std::endl;129 COUT(2) << "Sound: OpenAL: Invalid listener position" << std::endl; 130 130 131 131 // update listener orientation … … 140 140 error = alGetError(); 141 141 if(error == AL_INVALID_VALUE) 142 COUT(2) << " OpenAL: Invalid listener orientation" << std::endl;142 COUT(2) << "Sound: OpenAL: Invalid listener orientation" << std::endl; 143 143 144 144 // update sounds
Note: See TracChangeset
for help on using the changeset viewer.