- Timestamp:
- Jul 28, 2005, 1:19:50 AM (19 years ago)
- Location:
- orxonox/trunk/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/defs/class_id.h
r4932 r4961 172 172 CL_SOUND_BUFFER = 0x00000a01, 173 173 CL_SOUND_SOURCE = 0x00000a02, 174 CL_SOUND_OGG_PLAYER = 0x00000a11, 174 175 175 176 -
orxonox/trunk/src/lib/sound/ogg_player.cc
r4750 r4961 23 23 #include "debug.h" 24 24 25 void OggStream::open(string path) 25 26 /** 27 * initializes an Ogg-player from a file 28 * @param fileName the file to load 29 */ 30 OggPlayer::OggPlayer(const char* fileName) 31 { 32 this->setClassID(CL_SOUND_OGG_PLAYER, "OggPlayer"); 33 if (fileName != NULL) 34 { 35 this->open(fileName); 36 this->setName(fileName); 37 } 38 } 39 40 /** 41 * opens a file for playback 42 * @param fileName the file to open 43 */ 44 void OggPlayer::open(const char* fileName) 26 45 { 27 46 int result; 28 47 29 if(!(oggFile = fopen( path.c_str(), "rb")))48 if(!(oggFile = fopen(fileName, "rb"))) 30 49 PRINTF(2)("Could not open Ogg file."); 31 50 … … 58 77 } 59 78 60 61 62 63 void Ogg Stream::release()79 /** 80 * releases a stream 81 */ 82 void OggPlayer::release() 64 83 { 65 84 alSourceStop(source); … … 73 92 } 74 93 75 76 77 78 void Ogg Stream::display()94 /** 95 * displays some info about the ogg-file 96 */ 97 void OggPlayer::display() 79 98 { 80 99 cout … … 96 115 97 116 98 99 100 bool OggStream::playback() 117 /** 118 * plays back the sound 119 * @return true if running, false otherwise 120 */ 121 bool OggPlayer::playback() 101 122 { 102 123 if(playing()) … … 115 136 } 116 137 117 118 119 120 bool OggStream::playing() 138 /** 139 * 140 * @returns true if the file is playing 141 */ 142 bool OggPlayer::playing() 121 143 { 122 144 ALenum state; … … 127 149 } 128 150 129 130 131 132 bool OggStream::update() 151 /** 152 * updates the stream, this has to be done every few parts of a second, for sound-consistency 153 * @returns true, if the Sound is playing flawlessly 154 */ 155 bool OggPlayer::update() 133 156 { 134 157 int processed; … … 153 176 } 154 177 155 156 157 158 bool OggStream::stream(ALuint buffer) 178 /** 179 * gets a new Stream from buffer 180 * @param buffer the buffer to get the stream from 181 * @return true, if everything worked as planed 182 */ 183 bool OggPlayer::stream(ALuint buffer) 159 184 { 160 185 char pcm[BUFFER_SIZE]; … … 186 211 187 212 188 189 190 void OggStream::empty() 213 /** 214 * empties the buffers 215 */ 216 void OggPlayer::empty() 191 217 { 192 218 int queued; … … 203 229 } 204 230 205 206 207 208 void Ogg Stream::check()231 /** 232 * checks for errors 233 */ 234 void OggPlayer::check() 209 235 { 210 236 int error = alGetError(); … … 214 240 } 215 241 216 217 218 const char* OggStream::errorString(int code) 242 /** 243 * returns errors 244 * @param code the error-code 245 * @return the error as a String 246 */ 247 const char* OggPlayer::errorString(int code) 219 248 { 220 249 switch(code) -
orxonox/trunk/src/lib/sound/ogg_player.h
r4836 r4961 1 1 /*! 2 2 * @file ogg_player.h 3 * 3 * Ogg-Player definition 4 4 */ 5 5 … … 8 8 #define _OGG_PLAYER_H 9 9 10 #include <string>11 10 #include <iostream> 12 11 using namespace std; 12 13 #include "base_object.h" 13 14 14 15 #include <AL/al.h> … … 21 22 22 23 24 // the definition of a Ogg-Player 25 class OggPlayer : public BaseObject 26 { 27 public: 28 OggPlayer(const char* fileName = NULL); 23 29 24 class OggStream 25 { 26 public: 30 void open(const char* fileName); 31 void release(); 32 void display(); 33 bool playback(); 34 bool playing(); 35 bool update(); 27 36 28 void open(string path); 29 void release(); 30 void display(); 31 bool playback(); 32 bool playing(); 33 bool update(); 37 protected: 34 38 35 protected: 39 bool stream(ALuint buffer); 40 void empty(); 41 void check(); 42 const char* errorString(int code); 36 43 37 bool stream(ALuint buffer); 38 void empty(); 39 void check(); 40 const char* errorString(int code); 44 private: 41 45 42 private: 46 FILE* oggFile; //!< general file-handler, to open the sound-file 47 OggVorbis_File oggStream; //!< The stream this Ogg-player is playing back 48 vorbis_info* vorbisInfo; //!< The information held in the opened ogg-file 49 vorbis_comment* vorbisComment; //!< Comments about the ogg-file 43 50 44 FILE* oggFile; 45 OggVorbis_File oggStream; 46 vorbis_info* vorbisInfo; 47 vorbis_comment* vorbisComment; 48 49 ALuint buffers[2]; 50 ALuint source; 51 ALenum format; 52 }; 51 ALuint buffers[2]; //!< buffers that handle sequentially buffering of the audio 52 ALuint source; //!< The source we play back on 53 ALenum format; //!< The format we play back 54 }; 53 55 54 56 -
orxonox/trunk/src/lib/sound/sound_engine.cc
r4960 r4961 250 250 { 251 251 return new SoundSource(sourceNode, (SoundBuffer*)ResourceManager::getInstance()->load(fileName, WAV, RP_LEVEL)); 252 }253 254 255 /**256 * sets The listener (normaly the Camera)257 */258 void SoundEngine::setListener(PNode* listener)259 {260 this->listener = listener;261 252 } 262 253 -
orxonox/trunk/src/lib/sound/sound_engine.h
r4960 r4961 77 77 SoundSource* createSource(const char* fileName, PNode* sourceNode = NULL); 78 78 79 void setListener(PNode* listener); 79 /** @param listener the listener in the scene */ 80 void setListener(PNode* listener) { this->listener = listener; }; 80 81 void setDopplerValues(ALfloat dopplerFactor, ALfloat dopplerVelocity); 81 82 82 83 84 void update(); 85 86 // administrative 83 87 void addBuffer(SoundBuffer* buffer); 84 88 void removeBuffer(SoundBuffer* buffer); 85 89 void addSource(SoundSource* source); 86 90 87 void update();88 89 // administrative90 91 void flushUnusedBuffers(); 91 92 void flushAllBuffers(); -
orxonox/trunk/src/story_entities/world.cc
r4959 r4961 66 66 67 67 #include "sound_engine.h" 68 #include "ogg_player.h" 68 69 69 70 #include "class_list.h" … … 206 207 207 208 LoadClassDescription::printAll(); 209 210 211 ResourceManager::getInstance()->unload(this->music); 208 212 ResourceManager::getInstance()->unloadAllByPriority(RP_LEVEL); 209 213 } … … 226 230 //strcpy(this->worldName, name); 227 231 this->debugWorldNr = worldID; 232 233 this->music = NULL; 228 234 } 229 235 … … 517 523 518 524 ClassList::debug(); 525 526 this->music = (OggPlayer*)ResourceManager::getInstance()->load("sound/00-luke_grey_-_hypermode.ogg", OGG, RP_LEVEL); 527 music->playback(); 519 528 } 520 529 … … 954 963 955 964 SoundEngine::getInstance()->update(); 965 music->update(); 956 966 } 957 967 -
orxonox/trunk/src/story_entities/world.h
r4836 r4961 24 24 class PilotNode; 25 25 26 class OggPlayer; 26 27 //! The game world Interface 27 28 /** … … 112 113 113 114 115 OggPlayer* music; 114 116 // IMPORTANT WORLD-ENTITIES 115 117 PNode* nullParent; //!< The zero-point, that everything has as its parent. -
orxonox/trunk/src/util/resource_manager.cc
r4836 r4961 34 34 #ifndef NO_AUDIO 35 35 #include "sound_engine.h" 36 #include "ogg_player.h" 36 37 #endif /* NO_AUDIO */ 37 38 … … 228 229 229 230 /** 230 * 231 * loads resources 231 232 * @param fileName: The fileName of the resource to load 232 233 * @param type: The Type of Resource to load (\see ResourceType) … … 346 347 if(isFile(fullName)) 347 348 tmpResource->pointer = new SoundBuffer(fullName); 349 break; 350 case OGG: 351 if (isFile(fullName)) 352 tmpResource->pointer = new OggPlayer(fullName); 348 353 break; 349 354 #endif /* NO_AUDIO */ … … 400 405 401 406 /** 402 * 407 * unloads a Resource 403 408 * @param pointer: The pointer to free 404 409 * @param prio: the PriorityLevel to unload this resource … … 419 424 420 425 /** 421 * 426 * unloads a Resource 422 427 * @param resource: The resource to unloade 423 428 * @param prio the PriorityLevel to unload this resource … … 446 451 case WAV: 447 452 delete (SoundBuffer*)resource->pointer; 453 break; 454 case OGG: 455 delete (OggPlayer*)resource->pointer; 448 456 break; 449 457 #endif /* NO_AUDIO */ … … 500 508 501 509 /** 502 * 510 * Searches for a Resource by some information 503 511 * @param fileName: The name to look for 504 512 * @param type the Type of resource to locate. … … 587 595 588 596 /** 589 * 597 * Searches for a Resource by Pointer 590 598 * @param pointer the Pointer to search for 591 599 * @returns a Pointer to the Resource if found, NULL otherwise. … … 610 618 611 619 /** 612 * 620 * Checks if it is a Directory 613 621 * @param directoryName the Directory to check for 614 622 * @returns true if it is a directory/symlink false otherwise … … 657 665 658 666 /** 659 * 667 * Checks if the file is either a Regular file or a Symlink 660 668 * @param fileName the File to check for 661 669 * @returns true if it is a regular file/symlink, false otherwise … … 693 701 694 702 /** 695 * 703 * touches a File on the disk (thereby creating it) 696 704 * @param fileName The file to touch 697 705 */ … … 713 721 714 722 /** 715 * 723 * deletes a File from disk 716 724 * @param fileName the File to delete 717 725 */ … … 726 734 727 735 /** 728 729 730 731 */736 * @param name the Name of the file to check 737 * @returns The name of the file, including the HomeDir 738 * IMPORTANT: this has to be deleted from the outside 739 */ 732 740 char* ResourceManager::homeDirCheck(const char* name) 733 741 { … … 755 763 756 764 /** 757 758 759 765 * @param fileName the Name of the File to check 766 * @returns The full name of the file, including the DataDir, and NULL if the file does not exist 767 * IMPORTANT: this has to be deleted from the outside 760 768 */ 761 769 char* ResourceManager::getFullName(const char* fileName) … … 778 786 779 787 /** 780 * 788 * outputs debug information about the ResourceManager 781 789 */ 782 790 void ResourceManager::debug() const … … 824 832 case WAV: 825 833 PRINT(0)("SoundFile\n"); 834 break; 835 case OGG: 836 PRINT(0)("MusicFile\n"); 837 break; 826 838 #endif 827 839 default:
Note: See TracChangeset
for help on using the changeset viewer.