Changeset 4961 in orxonox.OLD for orxonox/trunk/src/lib
- Timestamp:
- Jul 28, 2005, 1:19:50 AM (19 years ago)
- Location:
- orxonox/trunk/src/lib/sound
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
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();
Note: See TracChangeset
for help on using the changeset viewer.